Autodesk Forge - updating AggregatedView from jstree events - autodesk-forge

I'm having some difficulties understanding how to update the AggregatedView instance and adding models.
I have checkboxes in my jstree that - when checked - updates an array with selected node id's. But in order to add or remove these models from the viewer I am reloading the viewer. This clears the cache and incurs a lot of waiting time (models that were selected but not removed needs to be reloaded). Anyone have any suggestions how I can update the viewer withouth completelty resetting everything?

The solution is to call a show/hide function of the aggregated viewer as I'm checking/unchecking models in the tree.

Related

Deferring downloads instead of being uploaded with the job?

My goal is to update the viewer only and then offer the option to generate the items for download and I was wondering what is the best way to handle this.
Currently when we send a workitem it returns with the updated svf and updates the viewer along with creating and uploading the selected export formats(stl, stp, dwg), BOM, etc. This increases the time that the user is waiting for the workitem to return.
Is a new AppBundle required or can this be handled within the same one?
Thanks in advance for your help!
This can be achieved using 1 appbundle only. You just need multiple activities. Each activity can use the same appbundle, and will be defined to use different portion of appbundle which can be decided based on the command line flags. Then you can in each of the phase send workitem using needed activity.

How to override ModelStructurePanel in Forge Viewer to first show the list of available models(but not load them,until i click on any of them)

I want to use the ModelStructurePanel in my Forge Viewer to show the user a list of models and they can choose which model is to be loaded or unloaded, but (even after they are unloaded) i need the models to still show up in the model browser.
Basically i want the usual behavior of the ModelStructurePanel when multiple models are loaded, but i want to override it in a way i can use it to display multiple models before loading them through user input.
Once a model is loaded, all the functionalities of the ModelStructurePanel should work the same.
Is this possible to implement?
Your approach seems a bit convoluted, I see 2 ways you could get job done:
1/ You can have a custom control (treeview or list for instance) that only displays your models, so user can pick one and it gets loaded by the viewer, then it loads model structure in the built-in panel
2/ You create a custom instanceTree which represent your models (but it has to mimic the Forge instanceTree) and you pass it to the built-in modelstructure so it shows your models hierarchy, then user can pick one and it will load in viewer, at which point you load the current model tree inside the panel. Loading data in the modelstructure can be done with:
viewer.modelstructure.setModel(instanceTree);
Personally I would go with approach 1/, as you could customize better your own control rather than fiddling around with the modelstructure which is not designed for that purpose

Forge Viewer - Hiding Root Node via model's Visibility Manager does not update IsolatedNodes property

We are currently consuming utilizing the Forge Viewer in our product and also have an extension that allows us to interact with the Viewer. If we have already isolated some nodes on a loaded model, and then go to hide the entire model, the IsolateNodes property on the model's visibility manager is not updated. It continues to have the ids of the nodes that were previously isolated.
What can i do to have the IsolatedNodes property updated?
FYI....
The call we make to hide the entire model is as follows: "model.visbilityManager.hide(model.getRootId());"
The viewer3D.js version we are currently utilizing is v3.3.5
With the information from your question, I would say that you haven't fully unloaded the model or need to finish the viewer. One suggestion can be:
viewer.tearDown()
viewer.finish()
viewer = null

Programmatically trigger Show all objects

When I load two large models. The first one loads completely, but the second model does not show all objects. After I select "Show all objects" from context menu, the viewer refreshes and shows all objects.
Is there a way to trigger "Show all objects" with javascript? Or some other way to refresh the viewer?
I am not seeing this behavior on my side, maybe I am not testing with models large enough or the issue is specific to some of your models. If you have the models on A360, you can give it a try in my forge demo sample at https://forge.autodesk.io.
Simply authorize the app and should should see your models, double click an item to insert into the scene.
The first suggestion would be:
viewer.impl.sceneUpdated(true)
You can also try the command that is fired by the contextmenu:
viewer.showAll()

Adobe Flex : how to have data shared between 3 tabs on a TabNavigator

I have a tabbed dialog that has 4 tabs. The parent component is an mx:TabNavigator and each of the tab's views are custom MXML components inside an s:NavigatorContent. The data for 3 of the tabs has to be sent as one unit to a back end service. I'm trying to work out the best way to have the 3 tabs access the data that's to be sent down as one unit. I currently have one .mxml file that defines the top level mx:TabNavigator with each of the 4 tabs representing the s:NavigatorContent defined in it's own separate.mxml file to keep the file sizes fairly short. My current approach is to have each of the tabs load their data from the back end service in their creationComplete handlers and store it in a common class for the data model shared by the 3 tabs. This solution is OK except:
The creation complete handler for the first tab is called on application startup even though it's not the first visible component (i.e. there are other parts of the UI that the user sees first). I'd prefer to have true lazy loading where the data is not loaded until the tab becomes visible to the user.
If the user edits data on the first tab, then navigates to the second tab for the first time without hitting the apply button, changes made in the first tab are lost, because the creation complete handler of the 2nd tab will load the data model shared by the 3 tabs.
What I ideally want is:
True lazy loading; data is not loaded until the user clicks on a tab and it becomes visible.
Have it so that when the user hits apply on any of the 3 tabs the current entries on each of the 3 tabs is sent down to the back end service.
Thanks very much if anyone can advise on this. I can explain in further detail if needed.
I'm trying to work out the best way to have the 3 tabs access the data
that's to be sent down as one unit.
Best is always subjective. The easiest way is going to be to create a single variable for your shared data, and pass that instance into each relevant tab.
In some cases you may store the data in some central location, and the use Dependency Injection to inject that data into the relevant tab components that need it. Dependency Injection is implemented by a bunch of Flex frameworks, such as RobotLegs or Swiz.
An alternate option is to use a Singleton approach or static variables on a class to share the data between your multiple tabs.
My current approach is to have each of the tabs load their data from
the back end service in their creationComplete handlers
Why use creationComplete? The creationComplete event is fired after the component has completed it's layout routines and layout routines of it's children, and then everything is ready to use. I assume the act of loading more data, will force a lot of your components to have to go through their rendering process again. You may consider moving this into an earlier spot during the lifecycle, such as initialize or preinitialize.
1) The creation complete handler for the first tab is called on
application startup even though it's not the first visible component
(i.e. there are other parts of the UI that the user sees first). I'd
prefer to have true lazy loading where the data is not loaded until
the tab becomes visible to the user.
This would be expected behavior, based on the way that TabNavigators initialize. You can look at creationPolicy for more information. You can rewrite your 'load data' method to operate on the show method of the component, perhaps?
2) If the user edits data on the first tab, then navigates to the
second tab for the first time without hitting the apply button,
changes made in the first tab are lost, because the creation complete
handler of the 2nd tab will load the data model shared by the 3 tabs.
You can force a save of the data on the hide event of the component. Or possibly on the change event o the TabNavigator.