By Augusto Goncalves (@augustomaia)
It's quite straightforward to write an extension to View & Data, just write a custom code for load and for unload. You'll find several extensions on this blog, including this: Integrating a chart library, by Philippe Leefsma.
This post uses Philippe's sample and replaces the loadChartFromProperty to create charts using RGraph library. The code assumes the model is already loaded on the viewer and search for all properties on the geometries, so make sure you call loadExtension after calling load. For instance:
// Load the document (urn) on the view object function loadDocument(documentId) { // Find the first 3d geometry and load that. Autodesk.Viewing.Document.load( documentId, function (doc) { // onLoadCallback var geometryItems = []; geometryItems = Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(), { 'type': 'geometry', 'role': '3d' }, true); if (geometryItems.length > 0) { _viewer.load(doc.getViewablePath(geometryItems[0]), null, function () { _viewer.loadExtension('Autodesk.ADN.Viewing.Extension.Chart.RGraph', ''); }); } }, function (errorMsg) { // onErrorCallback alert("Load Error: " + errorMsg); } ); }
Here is what the result should look like. See code below (hosted on Github)
See code below (hosted on Github)
function getleafcomponentsrec(parent) is not at all defined. I get an error stating that "Cannot read property 'children' of undefined"
Posted by: k r harsha | 08/09/2017 at 03:38 AM
Please see updated function at https://forge.autodesk.com/blog/enumerating-leaf-nodes-viewer
Posted by: Augusto Goncalves | 08/09/2017 at 08:47 AM
OK I have pasted that code but then again I'm stuck up in another problem. The function getPropertyValue has a callback argument which is not defined at all. I wonder why is that happening. The callback is always a function instead of a value. callback = f (value).
Posted by: k r harsha | 08/10/2017 at 01:51 AM
It is not entering into the function _cb(result) as the result does not have any value.
Posted by: k r harsha | 08/10/2017 at 02:06 AM