如何检索 Forge Viewer objectTree? [英] How to Retrieve Forge Viewer objectTree?

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

问题描述

我的目标是通过基于我在 revit 中创建的线条向查看器添加新几何图形来突出显示房间,就像他们在这里做的那样

您可以尝试以下几点:

  1. viewer 是否未定义?抓取 viewer 时,您是否在正确的范围内?
  2. 必须先加载文档,然后才能抓取实例树.加载文档后,将触发一个名为 Autodesk.Viewing.GEOMETRY_LOADED_EVENT 的事件,然后您就可以开始操作实例树了.

只需这样做:

viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () {var instanceTree = viewer.model.getData().instanceTree;});

有关更结构化的代码,请按照本指南添加扩展.

有一个更详细的博文监听哪个事件.不过,它仍然使用旧方法来获取实例树.

My goal is to highlight a room by adding new geometry to the viewer based on lines I have created in revit like they do here Link

but i can not figure out how to access those lines ids. I know what they are in revit (element_id) but not how they are mapped as dbid.

Following this Blog Post

I want to access the objectTree in my extension to find out, but it always comes back as undefined.

var tree;
//old way - viewer is your viewer object - undefined
viewer.getObjectTree(function (objTree) {
 tree = objTree;
});

//2.5 - undefined

  var instanceTree = viewer.model.getData().instanceTree;
  var rootId = this.rootId = instanceTree.getRootId();

//- undefined

  var objectTree = viewer.getObjectTree();

Can anyone tell me if its still works for them I am using the v2 of the API for the rvt conversion to svf and 2.9 of the viewer3D.js

note I can see a list of dbid if I call this

var model = viewer.impl.model;
var data = model.getData();
var fragId2dbIdArray = data.fragments.fragId2dbId ;

but have no way of mapping back to the Revit element_id

解决方案

As of version 2.9 this is still working. Here's my console:

Here's a couple of things you can try:

  1. Is viewer undefined? Are you in the correct scope when grabbing the viewer?
  2. The document have to be loaded before you can grab the instance tree. When the document is loaded, an event called Autodesk.Viewing.GEOMETRY_LOADED_EVENT will be fired, then you can start manipulating the instance tree.

Simply do this:

viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () {
var instanceTree = viewer.model.getData().instanceTree;
});

For more structured code, follow this guide to add an extension.

There's a more detailed blog post on which event to listen for. It's still using the old way to get instance tree, though.

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

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