根据forge网站上的基本应用程序教程,我正在Angular中创建一个查看器应用程序(
https://ase.autodesk.com/adp/v1/analytics/upload
).
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);
}
}