May 18, 2017

Show Animation and CAM content

Default blog image

When you load a document, they often contain multiple models that you can load: could be multiple 3d contents or views, multiple 2d sheets, etc
In case of a Fusion Design, the loaded document may also contain multiple animations or CAM setups. You can find them in a similar way as you find the basic 2d/3d content:

// Loading basic 3d content
var geometryItems = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), {
  'type': 'geometry',
  'role': '3d'
}, true);

if (geometryItems.length > 0) {
  var path = doc.getViewablePath(geometryItems[0]);
  viewer.loadModel(path, {}, onModelLoaded);
}

// Loading CAM setups
// First find the folder containing the Setups
var camItems = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), {
  'type': 'folder',
  'role': 'cam'
}, true);

// Now you can just iterate through them and find the geometry
// Here we are just loading the first one
if (camItems.length > 0) {
  var path = doc.getViewablePath(camItems[0].children[0]);
  viewer.loadModel(path, {}, onModelLoaded);
}

Here you can find a Node.js sample app which shows how to do this: 
https://github.com/adamenagy/data.management-nodejs-animation

When you run it then after logging into your A360 account you can find your models from the Files menu:


   

If the model contains Animations then they will be listed under the Animation menu:

If they contain CAM data as well, those will be listed under the CAM menu:

In order to get full support for the CAM and Animation data, you might need to load the relevant Viewer extension.
"Autodesk.CAM360" for CAM and "Autodesk.Fusion360.Animation" for Animation.

var viewerElement = document.getElementById('forgeViewer');
var config = {
  extensions: ['Autodesk.Fusion360.Animation', 'Autodesk.CAM360']
};
var viewer = new Autodesk.Viewing.Private.GuiViewer3D(viewerElement, config);

 

Related Posts

May 10, 2019

Consume AEC Data which are from Model Derivative API

Model Derivative API has been able to extract AEC data of Revit model such as level, grid, views, phase, linked documents etc. And Forge Viewer also provides the corresponding methods ...

Read More

May 9, 2019

Basic point clouds in Forge Viewer

Developers often ask us whether point clouds are supported in Forge Viewer. Unfortunately, the official answer is "no".

Read More

May 6, 2019

Properties shown in case of multiple selection

When selecting multiple objects in the UI then the behaviour of the Property Palette (i.e. which object's properties the palette is showing) can seem a bit random.

Read More