18 May 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
// If you wanted to search for animations then just change the 'role' from 'cam' to 'animation'
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: 

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 Article