如何在Forge Viewer中更改对象名称? [英] How to change object names in Forge Viewer?

查看:123
本文介绍了如何在Forge Viewer中更改对象名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Forge Viewer中更改对象和父节点的名称?

How can I change the names of objects and parent nodes in Forge Viewer?

在6.1及以下版本中,有一篇博客文章起作用:通过更改ModelStructureTreeDelegate类,将其重新加载为扩展,有效地覆盖它.在6.2及更高版本(当前为6.3.3)上,该功能不起作用,因为现在该类不再可访问,否则将无法正常工作.

In version 6.1 and below, there was a blog post that worked: by altering the ModelStructureTreeDelegate class, reloading it as an extension, effectively overriding it. That doesn't work on 6.2 and later (current is 6.3.3), because now that class is not accessible anymore, or otherwise doesn't work.

我发现的是,通过访问InstanceTreeStorage.prototype.processName方法,我可以更改树中对象的名称,但是该类在外部不可用.它似乎仅在模型加载期间使用.

What I found was that, by accessing the InstanceTreeStorage.prototype.processName method, I could change the name of objects in the tree, but that class is not available externally. It seems to be used only during Model loading.

我没有发现其他可以更改名称的类,也没有其他可以更改名称的函数.

I found no other class that changes the name, or any other function that lets me do it.

有人用最新版本的Viewer做过类似的事情吗?

Has anyone done something similar with the most recent version of the Viewer?

推荐答案

您可以通过从Autodesk.Viewing.Extensions.ViewerModelStructurePanel类派生,覆盖getNodeLabel方法并将该类的实例设置为来创建自己的模型结构面板.查看器的模型结构用户界面:

You can create your own model structure panel by deriving from the Autodesk.Viewing.Extensions.ViewerModelStructurePanel class, overriding the getNodeLabel method, and setting an instance of the class as the model structure UI for the viewer:

class CustomModelStructurePanel extends Autodesk.Viewing.Extensions.ViewerModelStructurePanel {
    constructor(viewer, title, options) {
        super(viewer, title, options);
    }

    getNodeLabel(node) {
        return 'custom node name';
    }
}

viewer.setModelStructurePanel(new CustomModelStructurePanel(viewer, 'Custom Model Structure', options));

这篇关于如何在Forge Viewer中更改对象名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆