在查看器中加载对象时出错
Error loading object in viewer
我正在按照 Forge 站点 (https://ase.autodesk.com/adp/v1/analytics/upload) 上的基本应用程序教程在 Angular 中创建查看器应用程序。
一切正常,直到我调用 loadDocument() 函数。它抛出以下错误:
XML Parsing Error: no root element found Location: https://ase.autodesk.com/adp/v1/analytics/upload Line Number 1, Column 1:
有人知道发生了什么事吗?我尝试了不同的对象,并确保已完成对 svf 格式的转换。
感谢您的帮助!
-- 编辑:
这是应用程序的代码(<urn>
和 <token>
已替换为正确的值):
import { Component, ViewChild, AfterViewInit, OnDestroy, ElementRef, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import 'rxjs/Rx';
declare var Autodesk: any;
@Component({
selector: 'app-autodesk-forge-viewer',
templateUrl: './panel.autodesk.viewer.component.html'
})
export class PanelAutodeskViewerComponent
implements AfterViewInit,
OnInit
{
private viewer: any;
options = {
env: 'AutodeskProduction',
language: "en",
accessToken: "<token>"
}
constructor(route: ActivatedRoute) { }
ngOnInit() {
}
ngAfterViewInit() {
Autodesk.Viewing.Initializer(this.options, function onInitialized() {
this.viewer = new Autodesk.Viewing.ViewingApplication('ForgeViewer');
this.viewer.registerViewer(this.viewer.k3D, Autodesk.Viewing.Private.GuiViewer3D);
this.viewer.loadDocument('urn:<urn>', this.onDocumentLoadSuccess, this.onDocumentLoadFailure);
});
}
private onDocumentLoadSuccess(doc) {
// We could still make use of Document.getSubItemsWithProperties()
// However, when using a ViewingApplication, we have access to the **bubble** attribute,
// which references the root node of a graph that wraps each object from the Manifest JSON.
var viewables = this.viewer.bubble.search({ 'type': 'geometry' });
if (viewables.length === 0) {
console.error('Document contains no viewables.');
return;
}
// Choose any of the avialble viewables
this.viewer.selectItem(viewables[0].data, this.onItemLoadSuccess, this.onItemLoadFail);
}
private onDocumentLoadFailure(viewerErrorCode) {
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
}
private onItemLoadSuccess(viewer, item) {
console.log('onItemLoadSuccess()!');
console.log(viewer);
console.log(item);
// Congratulations! The viewer is now ready to be used.
console.log('Viewers are equal: ' + (viewer === this.viewer.getCurrentViewer()));
}
private onItemLoadFail(errorCode) {
console.error('onItemLoadFail() - errorCode:' + errorCode);
}
}
这条错误信息XML Parsing Error: no root element found Location: https://ase.autodesk.com/adp/v1/analytics/upload Line Number 1, Column 1:
不应该导致您解决的问题。您的模型应该可以毫无问题地加载并显示在查看器中。
如果您能提供可重现的案例来证明这一点,我很乐意调查您的应用发生了什么。以下项目应在可重现的情况下:
- 对您要实现的目标的简短准确描述。您观察到的行为与您期望的行为,以及为什么这是一个问题。
- 用于 运行 测试的完整但最小的示例源模型。
- 一个完整但最小的 Forge 应用程序,可以 运行 并使用简单的程序进行调试,以在示例模型中实时分析其行为。
重现问题的详细分步说明,例如选择哪个元素,启动什么命令等
如果您的可重现案例无法在此处公开发布,请将其发送至 forge.help@autodesk.com
并在发送前删除敏感数据或信息。
我正在按照 Forge 站点 (https://ase.autodesk.com/adp/v1/analytics/upload) 上的基本应用程序教程在 Angular 中创建查看器应用程序。
一切正常,直到我调用 loadDocument() 函数。它抛出以下错误:
XML Parsing Error: no root element found Location: https://ase.autodesk.com/adp/v1/analytics/upload Line Number 1, Column 1:
有人知道发生了什么事吗?我尝试了不同的对象,并确保已完成对 svf 格式的转换。
感谢您的帮助!
-- 编辑:
这是应用程序的代码(<urn>
和 <token>
已替换为正确的值):
import { Component, ViewChild, AfterViewInit, OnDestroy, ElementRef, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import 'rxjs/Rx';
declare var Autodesk: any;
@Component({
selector: 'app-autodesk-forge-viewer',
templateUrl: './panel.autodesk.viewer.component.html'
})
export class PanelAutodeskViewerComponent
implements AfterViewInit,
OnInit
{
private viewer: any;
options = {
env: 'AutodeskProduction',
language: "en",
accessToken: "<token>"
}
constructor(route: ActivatedRoute) { }
ngOnInit() {
}
ngAfterViewInit() {
Autodesk.Viewing.Initializer(this.options, function onInitialized() {
this.viewer = new Autodesk.Viewing.ViewingApplication('ForgeViewer');
this.viewer.registerViewer(this.viewer.k3D, Autodesk.Viewing.Private.GuiViewer3D);
this.viewer.loadDocument('urn:<urn>', this.onDocumentLoadSuccess, this.onDocumentLoadFailure);
});
}
private onDocumentLoadSuccess(doc) {
// We could still make use of Document.getSubItemsWithProperties()
// However, when using a ViewingApplication, we have access to the **bubble** attribute,
// which references the root node of a graph that wraps each object from the Manifest JSON.
var viewables = this.viewer.bubble.search({ 'type': 'geometry' });
if (viewables.length === 0) {
console.error('Document contains no viewables.');
return;
}
// Choose any of the avialble viewables
this.viewer.selectItem(viewables[0].data, this.onItemLoadSuccess, this.onItemLoadFail);
}
private onDocumentLoadFailure(viewerErrorCode) {
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
}
private onItemLoadSuccess(viewer, item) {
console.log('onItemLoadSuccess()!');
console.log(viewer);
console.log(item);
// Congratulations! The viewer is now ready to be used.
console.log('Viewers are equal: ' + (viewer === this.viewer.getCurrentViewer()));
}
private onItemLoadFail(errorCode) {
console.error('onItemLoadFail() - errorCode:' + errorCode);
}
}
这条错误信息XML Parsing Error: no root element found Location: https://ase.autodesk.com/adp/v1/analytics/upload Line Number 1, Column 1:
不应该导致您解决的问题。您的模型应该可以毫无问题地加载并显示在查看器中。
如果您能提供可重现的案例来证明这一点,我很乐意调查您的应用发生了什么。以下项目应在可重现的情况下:
- 对您要实现的目标的简短准确描述。您观察到的行为与您期望的行为,以及为什么这是一个问题。
- 用于 运行 测试的完整但最小的示例源模型。
- 一个完整但最小的 Forge 应用程序,可以 运行 并使用简单的程序进行调试,以在示例模型中实时分析其行为。 重现问题的详细分步说明,例如选择哪个元素,启动什么命令等
如果您的可重现案例无法在此处公开发布,请将其发送至 forge.help@autodesk.com
并在发送前删除敏感数据或信息。