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

如何在ACC的AggregatedView中实现Selective Loading功能?

解决方案:在AggregatedView中实现选择性加载过滤链接节点

问题根源

  1. 加载方式错误:AggregatedView不能直接调用view.load加载模型,必须通过Viewer的loadDocumentNode方法,并指定aggregatedView参数,否则模型会被加载到主视图而非目标聚合视图。
  2. 过滤规则偏差:原代码过滤的是Type Name包含Generic Models的元素,而非你需要排除的Revit/DWG链接节点,导致过滤逻辑无效。

修正后的代码示例

1. 正确的过滤配置

针对Revit链接(RevitLinkInstance)和DWG链接(DWGLinkInstance)类型的节点进行过滤:

// 过滤掉所有Revit和DWG链接实例
const documentLoadOptions = {
    filter: {
        property_query: [
            {
                "$not": ["__type__", "RevitLinkInstance"]
            },
            {
                "$not": ["__type__", "DWGLinkInstance"]
            }
        ]
    }
};

如果需要排除所有类型的外部链接,也可以通过节点role属性过滤:

const documentLoadOptions = {
    filter: {
        property_query: [
            {
                "$not": ["role", Autodesk.Viewing.Document.Role.LINK]
            }
        ]
    }
};

2. 适配AggregatedView的加载函数

使用viewer.loadDocumentNode并指定aggregatedView参数,确保模型加载到目标聚合视图:

export async function loadNode(item, documentLoadOptions, bubbleoptions) {
    const documentId = 'urn:' + item;
    try {
        // 异步加载文档
        const doc = await Autodesk.Viewing.Document.load(documentId);
        // 查找目标视图节点
        const bubbleRoot = doc.getRoot().search(bubbleoptions);
        if (bubbleRoot.length === 0) {
            console.error('未找到匹配bubbleoptions的视图');
            return;
        }
        // 加载模型到指定的AggregatedView
        await view.viewer.loadDocumentNode(doc, bubbleRoot[0], {
            ...documentLoadOptions,
            aggregatedView: view // 关键:指定模型加载到当前聚合视图
        });
        // 显示加载的视图
        view.show(bubbleRoot[0]);
        console.log("已加载节点: " + item);
    } catch (err) {
        console.error('加载节点失败:', err);
    }
}

额外注意事项

  • 确保bubbleoptions能精准匹配到ACC中发布的目标视图(比如通过视图名称、ID或其他属性过滤)
  • 使用async/await处理异步加载逻辑,避免回调嵌套导致的时序问题
  • 如果需要验证过滤是否生效,可以加载后通过viewer.getProperties查看节点属性,确认链接节点未被加载

内容的提问来源于stack exchange,提问作者Allmächd

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 08:23:19