我得到這個錯誤: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 –