skäpz
skäpz

Reputation: 23

How to properly translate and display .sldasm files in Forge?

With the code below we can translate and display .dwg, .sldprt, .3ds, .pdf. Uploading and translating a .sldasm file seems to succeed, but when trying to load it in the viewer we get this message: "Model is empty, there is no geometry to show". This seems to happen with all .sldasm files. Does anyone have any pointers, or can spot any mistakes?

Translate:

 private async Task<TranslateResponse> StartTranslateFileJob(string bucketUrn)
    {
        var json = JsonConvert.SerializeObject(new
        {
            input = new
            {
                urn = ToUrlSafeBase64(bucketUrn)
            },
            output = new
            {
                formats = new List<Dictionary<string, dynamic>>()
                {
                    new Dictionary<string, dynamic>() { { "type", "svf" }, {"views", new List<string>() { "2d", "3d"} } }
                }
            }
        });
        Header header = new Header()
        {
            ContentType = "application/json",
            Body = json.ToString(),
            Authorization = new AuthenticationHeaderValue("Bearer", await GetAccessToken())
        };
        string response = await request.Request(HttpMethod.Post, "/modelderivative/v2/designdata/job", header);
        return JsonConvert.DeserializeObject<TranslateResponse>(response);
    }

Display:

    private async load(urn: string) {
    let options = {
        env: 'AutodeskProduction',
        accessToken: this.access_token
    };

    let viewerDocument = await new Promise<Autodesk.Viewing.Document>((resolve, reject) =>
        Autodesk.Viewing.Initializer(options, () => {
            Autodesk.Viewing.Document.load(urn, (viewerDocument) => resolve(viewerDocument), (e) => reject(new Error("Blueprint load error: " + e)));
        })
    );

    let documentNode = viewerDocument.getRoot().search({ 'type': 'geometry' })[0];
    this.viewer.loadDocumentNode(viewerDocument, documentNode);
}

Upvotes: 1

Views: 327

Answers (2)

sk&#228;pz
sk&#228;pz

Reputation: 23

In case anyone has the same question, here is the answer:

I've discussed your issue with the development team. It appears that the SLDASM file format supports "temporary/baked visualization primitives" that are included in the main file even when the referenced SLDPRT files are missing. Unfortunately, the Forge translation expects the up-to-date referenced files, and currently does not support the temporary visualization data stored directly within the SLDASM file. In order to translate and view this file in Forge, you could take one of the following approaches:

  1. (preferred) provide your SLDASM file with all its referenced files in a ZIP file as I explained in the Stack Overflow post
  2. Use the "Pack and Go" feature in SolidWorks to bundle all the references into the single SLDASM file
  3. (this might help but we can't confirm that) Load the assembly in SolidWorks and ask for a forced full rebuild (Ctrl+Q), and then process the single SLDASM file in Forge as usual

Upvotes: 1

Petr Broz
Petr Broz

Reputation: 9909

Files like *.sldasm (SolidWorks assemblies) or *.iam (Inventor assemblies) typically reference additional files (*.sldprt or *.ipt), and Forge cannot figure out those references automatically. You could do one of the following:

  1. Upload the *.sdlasm together with all its referenced parts in a ZIP archive, and use the compressedUrn and rootFilename properties when triggering the translation job (tutorial).

or

  1. Establish the references using the POST references endpoint.

Upvotes: 1

Related Questions