1

I'm creating a viewer application in Angular following the basic application tutorial on the forge site (https://ase.autodesk.com/adp/v1/analytics/upload).

Everything is ok, until I call the loadDocument() function. It throws the following error:

XML Parsing Error: no root element found Location: https://ase.autodesk.com/adp/v1/analytics/upload Line Number 1, Column 1:

Anyone has any idea of what's going on? I've tried with different objects and I've made sure the translation to svf format was completed.

Thanks for the help!

-- EDIT: Here's the code for the app (<urn> and <token> were replaced with the correct values):

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);
    }
}
22
  • That is an error for the Autodesk analytics SDK, it's not related to load a model from the Forge. Could you do me a favor to post the full code or example code you used in your viewer app, please? Commented Jul 21, 2017 at 6:16
  • BTW, could you add this line Autodesk.Viewing.Private.logger.setLevel( Autodesk.Viewing.Private.LogLevels.NONE ); to your callback function of the Autodesk.Viewing.Initializer? The error message should be gone. Commented Jul 21, 2017 at 6:23
  • @EasonKang Thanks, I edited the question with the code. I'll try adding that to the callback function. Commented Jul 21, 2017 at 6:24
  • @EasonKang I added that line of code and the error still appears. Commented Jul 21, 2017 at 6:29
  • Sorry, I have some wrong typing before. Please add this line Autodesk.Viewing.Private.logger.setLevel( Autodesk.Viewing.Private.LogLevels.NONE ); , instead of Autodesk.Viewing.Private.logger.setLevel( avp.LogLevels.NONE ); . Your code is fine, and should work fine. Commented Jul 21, 2017 at 6:34

1 Answer 1

2

This error message XML Parsing Error: no root element found Location: https://ase.autodesk.com/adp/v1/analytics/upload Line Number 1, Column 1: shouldn't cause the issue you addressed. Your model should be loaded and shown in the viewer without any problem.

If you can provide a reproducible case demonstrating that, I will gladly investigate what happened to your app. Those following items should be in the reproducible case:

  1. A short exact description of what you are trying to achieve. The behavior you observe versus what you expect, and why this is a problem.
  2. A complete yet minimal sample source model to run a test in.
  3. A complete yet minimal Forge app that can be run and debugged with a simple procedure to analyze its behavior live in the sample model. Detailed step-by-step instructions for reproducing the issue, e.g. which element to pick, what command to launch etc.

If your reproducible case could not be posted here publicly, please send it to the [email protected] and remove sensitive data or information before you send.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, many thanks. Will try to fix it this week end and send you the project next week. Thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.