Autodesk forge 在Autodesk forge viewer中查看文件时出错-调用doc.getRootItem()时出错
在Autodesk forge viewer中查看文件时,出现以下错误:Autodesk forge 在Autodesk forge viewer中查看文件时出错-调用doc.getRootItem()时出错,autodesk-forge,autodesk,forge,Autodesk Forge,Autodesk,Forge,在Autodesk forge viewer中查看文件时,出现以下错误: 无法读取未定义的属性“setEndpoint” 文档。getRootItem不是一个函数 并且将能够在空缓存和硬重新加载(Ctrl+Shift+R)页面后查看。有时,即使在硬重新加载和清除浏览器缓存后,相同的错误也会持续存在 第二个错误的代码 var options = { env: 'AutodeskProduction', accessToken: getAccessToken() //Method t
var options = {
env: 'AutodeskProduction',
accessToken: getAccessToken() //Method to get access token- no errors here
};
var documentId = 'urn:' + urn;
Autodesk.Viewing.Initializer(options, function onInitialized() {
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});
//Autodesk.Viewing.Document.load - success function.
function onDocumentLoadSuccess(doc) {
setTimeout(function() {
debugger;
}, 5000);
//Error is thrown in the line below.
var viewables = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), {
'type': 'geometry'
}, true); //throws error on calling doc.getRootItem()
if (viewables.length === 0) {
console.error('Document contains no viewables.');
return;
}
// Choose any of the avialble viewables
var initialViewable = viewables[0];
var svfUrl = doc.getViewablePath(initialViewable);
var modelOptions = {
sharedPropertyDbPath: doc.getPropertyDbPath()
};
var viewerDiv = document.getElementById('divViewer');
viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerDiv);
viewer.start(svfUrl, modelOptions, onLoadModelSuccess, onLoadModelError);
}
您必须在无意中升级到Viewer V7,getRootItem和其他几个功能已被弃用-请参阅其发行说明和迁移指南 坚持使用带有
的V6-如果默认情况下未指定版本,将提供最新的稳定版本,即现在的V7.0