简体   繁体   English

在同一个查看器中加载多个模型时是否更新了属性数据库?

[英]Is the Property Database being Updated when Multiple Models are Loaded in The Same Viewer?

I managed to load multiple models into the same viewer and now I am trying to extract properties and values of the elements of each model; 我设法将多个模型加载到同一个查看器中,现在我正在尝试提取每个模型的元素的属性和值; however, when I use getPropertyDb() and executeUserFunction() , I get back only the properties of the initial model. 但是,当我使用getPropertyDb()executeUserFunction() ,我只返回初始模型的属性。

I started with the code from this repo and used this article to understand how to load multiple models. 我从这个repo的代码开始,并使用这篇文章来了解如何加载多个模型。

First model is loaded after a redirect from the server. 从服务器重定向后加载第一个模型。

function onDocumentLoadSuccess(doc) {
    const geometries = doc.getRoot().search({ type: 'geometry' });
    if (geometries.length === 0) {
        console.error('Document contains no viewables.');
        return;
    }
    const initViewable = geometries[0];
    const svfUrl = doc.getViewablePath(initViewable);
    const mat = new THREE.Matrix4();
    const modelOptions = {
        placementTransform: mat,
        globalOffset: { x: 0, y: 0, z: 0 },
        sharedPropertyDbPath: doc.getPropertyDbPath()
    };

    const viewerDiv = document.getElementById('MyViewerDiv');
    const config = {
        extensions: myExtensions
    };
    viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv, config);
    viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);
}

After the geometry of each model is loaded an extension does some stuff. 加载每个模型的几何后,扩展会做一些事情。

function MyExtension(viewer, options) {
    Autodesk.Viewing.Extension.call(this, viewer, options);
}

MyExtension.prototype = Object.create(Autodesk.Viewing.Extension.prototype);
MyExtension.prototype.constructor = MyExtension;

MyExtension.prototype.onGeometryLoadEvent = function(event) {
    const myPromise = this.viewer.model
        .getPropertyDb()
        .executeUserFunction(userFunction);

    myPromise
        .then(function(retValue) {
            if (!retValue) {
                console.log('Model doesn\'t contain valid elemens.');
            }
            // do stuff...
        })
        .catch(err => console.log(err));
};

MyExtension.prototype.load = function() {
    this.onGeometryLoadBinded = this.onGeometryLoadEvent.bind(this);
    this.viewer.addEventListener(
        Autodesk.Viewing.GEOMETRY_LOADED_EVENT,
        this.onGeometryLoadBinded
    );
    return true;
};

MyExtension.prototype.unload = function() {
    this.viewer.removeEventListener(
        Autodesk.Viewing.GEOMETRY_LOADED_EVENT,
        this.onGeometryLoadBinded
    );
    this.onGeometryLoadBinded = null;
    return true;
};

Autodesk.Viewing.theExtensionManager.registerExtension(
    'MyExtension',
    MyExtension
);

function userFunction(pdb) {
    // get properties of the elements
}

New models are loaded in the same viewer using an extension as well. 新模型也使用扩展名加载到同一个查看器中。

MyOtherExtension.prototype.onDocumentLoadSuccess = function(doc) {
    // get the svfUrl of the initial geometry and set the loading options

    this.viewer.loadModel(
        svfUrl,
        loaderOptions,
        this.onLoadModelSuccessBinded,
        this.onLoadModelErrorBinded
    );
};

How do I update the Property Database in order to get the properties and values for all the models that are currently loaded into the viewer? 如何更新属性数据库以获取当前加载到查看器中的所有模型的属性和值?

尝试通过模型对象访问特定数据库:

viewer.impl.modelQueue().getModels()[index].getPropertyDb()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加载多个模型时,如何在查看器中按dbid选择? - How to select by dbid in viewer when several models are loaded? 伪造查看器同时获取多个模型的元素 dbId NOP_VIEWER.getSelection(); [] - forge viewer get element dbId for multiple models same time NOP_VIEWER.getSelection(); [] Forge Viewer-我们可以在加载的模型上进行选择/突出显示并保存在数据库中,以便下次用户加载时可以显示该选择吗? - Forge Viewer - can we make selections/highlight on loaded models and save in database so that we can show that selection next time user loads it? 激活 MemoryLimited 时未加载属性数据库 - Property database not loaded when MemoryLimited is activated 在伪造查看器中加载的某些模型不返回任何视口 - Some models loaded in a forge viewer do not return any viewport Forge Autodesk 使用 ReactJS 在查看器中加载多个模型 - Forge Autodesk load multiple models in Viewer with ReactJS 加载多个模型时选定元素的相关 model - Related model of a selected element when multiple models are loaded 在同一查看器中加载多个URN - Load multiple URN in a same Viewer Autodesk forge 查看器:有没有办法增加查看器的超时以加载多个模型/大型模型 - Autodesk forge viewer: Is there a way to increase the timeout of viewer to load multiple models/large models Forge Viewer-无法正确查看多个不同的模型 - Forge Viewer - Cannot view multiple different models properly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM