我得到这个错误:Uncaught TypeError:>无法读取属性'getRootId'的未定义 即使我使用Autodesk.Viewing.GEOMETRY_LOADED_EVENT ..仍然没有效果。无法读取instanceTree autodesk
回答
你只需要等待Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT
被解雇的时候,你要访问的instanceTree
:中
viewer.addEventListener(Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT, function() {
var instanceTree = model.getData().instanceTree //cool
})
感谢这一个也是完美的工作。 –
您不应该使用instanceTree
数据结构,但应该使用支持的功能/操作。如果你需要的是枚举叶节点,尝试类似的东西为described here:
function getAllLeafComponents(viewer, callback) {
var cbCount = 0; // count pending callbacks
var components = []; // store the results
var tree; // the instance tree
function getLeafComponentsRec(parent) {
cbCount++;
if (tree.getChildCount(parent) != 0) {
tree.enumNodeChildren(parent, function (children) {
getLeafComponentsRec(children);
}, false);
} else {
components.push(parent);
}
if (--cbCount == 0) callback(components);
}
viewer.getObjectTree(function (objectTree) {
tree = objectTree;
var allLeafComponents = getLeafComponentsRec(tree.getRootId());
});
}
我已经通过简单的黑客解决了它: –
'function waitForElement(){ if(instanceTree.getRootId( )!==“undefined”){...} else { setTimeout(waitForElement,250); } };' –
或'Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT'? –
- 1. 无法读取
- 2. 有关instanceTree的问题
- 3. io.UnsupportedOperation:无法读取
- 4. cookie无法读取
- 5. 无法读取空
- 6. 无法读取struts.properties
- 7. 无法读取NULL
- 8. 无法读取根
- 9. 无法读取角
- 10. 无法读取Startup.cs
- 11. 无法读取JSON
- 12. 无法读取空
- 13. 无法读取空
- 14. 无法读取kABPersonPhoneProperty
- 15. ifstream无法读取
- 16. 无法读取application.yml
- 17. Array无法读取
- 18. NSMutableData无法读取
- 19. 无法读取QGraphicsScene
- 20. 无法读取InputStream
- 21. 无法读取空
- 22. 无法读取request.getInputStream
- 23. Beautifulsoup无法读取
- 24. 无法读取web.sitemap
- 25. 无法读取httpwebresponse
- 26. 无法读取值
- 27. 无法读取空
- 28. contracts.d无法读取
- 29. 无法读取空
- 30. 无法读取JSON
哪个版本观众正在使用?建议使用上面的v2.16,viewingService(View和Data API)现在已经过期。查看更多的细节,https://forge.autodesk.com/blog/viewer-giving-error-403-unauthorized –