You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Autodesk Tandem中如何用getPropertiesDt()获取库存表指定列及参数文档查询

在Autodesk Tandem自定义应用中获取Inventory表完整列的问题

我正在使用Autodesk Tandem开发自定义应用,已实现设施及其关联视图的展示功能。现在我希望获取Inventory表的所有列。

当前代码如下:

await app.displayFacility(matchingFacility, aModelIds, viewer);
await app.views.setCurrentView(matchingFacility, matchingView);
const viewer: Autodesk.Viewing.GuiViewer3D = this.oViewer;
const model: Autodesk.Viewing.Model = viewer.model;
const visibleDbIds = await model.getVisibleDbIds();
const inventoryElements = await model.getPropertiesDt(visibleDbIds);

这段代码运行正常,但返回结果缺少以下列:

  • [Common][Category Name]
  • [Common][SourceFile]

我的问题:

  1. getPropertiesDt()的可选参数是否有相关文档?
  2. 如何确保上述提及的列被包含在返回结果中?

解答

1. getPropertiesDt()的可选参数文档

getPropertiesDt()是Autodesk Tandem基于Viewer扩展的专用方法,其参数细节可通过Viewer的类型定义文件(.d.ts)或调试时查看方法签名获取。它支持传入配置对象,用于指定属性过滤规则、要包含的属性集等。官方内部文档会有完整说明,若无法访问,直接查看代码签名是最直接的方式。

2. 包含缺失列的处理方式

默认情况下getPropertiesDt()只会返回部分常用属性,要包含[Common][Category Name]和[Common][SourceFile],可通过以下方式处理:

方法一:指定要包含的属性列表

显式声明需要获取的属性,确保目标列被返回:

const inventoryElements = await model.getPropertiesDt(visibleDbIds, {
    includeProps: [
        'Common.Category Name',
        'Common.SourceFile'
        // 可追加其他需要的属性名
    ]
});

方法二:获取所有Common类别属性

如果需要Common类别下的全部属性,可启用专用参数:

const inventoryElements = await model.getPropertiesDt(visibleDbIds, {
    includeAllCommonProps: true
});

方法三:强制获取所有属性

若需要Inventory表的完整列数据,可启用全量属性参数(注意:会增加数据返回量,可能影响性能):

const inventoryElements = await model.getPropertiesDt(visibleDbIds, {
    includeAllProps: true
});

备选方案:直接访问属性数据库

如果上述参数不生效,可通过属性数据库手动查询目标属性:

const propDb = model.getPropertyDb();
const fullInventory = [];

for (const dbId of visibleDbIds) {
    const baseProps = await model.getProperties(dbId);
    // 手动提取目标属性
    const categoryName = propDb.getObjectProperty(dbId, 'Common', 'Category Name');
    const sourceFile = propDb.getObjectProperty(dbId, 'Common', 'SourceFile');
    
    fullInventory.push({
        ...baseProps,
        'Common.Category Name': categoryName,
        'Common.SourceFile': sourceFile
    });
}

内容的提问来源于stack exchange,提问作者Peter Kolbe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 21:12:38