Reputation: 5
I would like to add the cluster extension onto my forge application.
I am able to add it in the forge VSCode extension when I am viewing the model through vscode, but I would like to add it to my main application.
https://forge-extensions.autodesk.io/ here it states that the cluster function is already built in. I have tried to activate it but it isnt working.
Does anyone know how to get the clustering to work?
Thank you!
Upvotes: 0
Views: 627
Reputation: 2659
There is 2 ways to load an extension. It can load either via a Viewer configuration or calling in the extension from code. However, the extension may disable itself, if your model does not meet the requirement for the extension to run. For example, does your model has the property which is used for Clustering? That extension was written for Revit files, but can work on other file type as long the Property exists - the one you need by default is 'Category' (see below how to change it).
For the configuration approach, you need to pass an object to the viewer construction ,like this:
new Autodesk.Viewing.GuiViewer3D(mydiv, { extensions: ['Autodesk.VisualClusters'] });
However, using this method, you cannot configure the extension itself. Most of the time, you do not need, but if you need to, you need to use the second technique.
The second technique is to load the extension from code after the Viewer started and/or after viewables were loaded, like this:
myViewer.loadDocumentNode(doc, viewable, options)
.then((data) => {
...
myViewer.loadExtension('Autodesk.VisualClusters');
...
})
.catch((err) => {
...
});
and if you want to change the extension configuration, do it like this:
myViewer.loadExtension(
'Autodesk.VisualClusters',
{
attribName: 'Level',
searchAncestors: false
}
);
While the 'Autodesk.VisualClusters' extension is all fine from loading and reloading models; but there are some extensions which need a bit more attention such as the 'Autodesk.Debug' and 'Autodesk.Measure' for example. If you want to learn more on this, take a look to this code.
Upvotes: 4