Changing selection resolution for component properties - autodesk-forge

Using the viewer, we can interact with the model browser to change the selection resolution in order to see different properties about a selected component. However, for most of our users, this is incredibly unintuitive. Is there a programmatic way to set the selection resolution used by the viewer's built in properties window so that we can control what properties are displayed when a user selects a component in the viewer? Or maybe there is a better way that is intended to allow developers to control which properties are shown within the viewer's built in properties window?

You can build your own property panel that will allow you to pass in the desired properties you want your users to see. I have done this in a sample listed below, where I populate in a separate table, not using the Viewer Toolbar, the different categories for the properties of the model. Try the Revit House model.
https://viewer-rocks.autodesk.io/
Also here is another demo where a Meta-properties panel got built that even allows you to modify the properties, remove, add new ones to that panel.
https://forge-rcdb.autodesk.io/configurator?id=5904729b0007f5ead5b1196d
You can see both source projects from Github.

Related

Is there a way in Autodesk forge to get entity name with the id that appears in the property panel?

I am trying to get the entire name of a dbId. I am able to get the name using getNodeName() but is there a way to fetch the id as well? I have highlighted the id I need in the image below.
Property panel snapshot:
Since everything you see in the viewer is open source and available through JavaScript, including the property panel that you show in the screen snapshot, the highlighted Revit element id can definitely be accessed. In the worst case, you would simply grab the caption of the property panel window and parse it from that. However, the Revit element id is also accessible from the viewer node properties. It can be extracted from the externalId property, which includes a hex encoding of it. For more details, please refer to the similar previous question on missing Revit ID in instance elements.

Is there an option to filter Revit elements based on a view on forge?

I have multiple 3D views and user can select any views in the forge application to view. here i am trying to get the elements only associated to the selected view. from the view i am able to get the model and all the elements. But i am not able to filter based on the views as Revit do.
Is it possible to filter elements based on the selected view?
Appreciating you help.
Regards,
Durai
Check the __viewable_in__ property of the elements, it should indicate where the given element is visible and allow you, for instance, to navigate to other views, like in this sample.

Autodesk Viewer: Show a list of elements with specified Database IDs

The functionality I seek is very similar to the default ModelStructurePanel model browser, except that I need to list only a subset of elements, by passing a list of dbIds of the elements I want listed. By clicking on an element on that list, have the view focus on that element.
I figure there might be two ways of achieving this by using the ModelStructurePanel (although I'm open to using something else):
Creating a new instanceTree with only the specified elements, then doing something like viewer.modelstructure.setModel(newInstanceTree)
Overwriting the ModelStructurePanel.shouldInclude method to hide all elements but the specified ones.
I have googled for Viewer code boilerplate that would provide this functionality, but have not found it. Any help is very much appreciated.
There is a basic sample here very close to what you described, and I would go with customizing just one action instead create a new one, seems easier.

Issue with selection in Screenshot manager

We have built custom state saving functionality into our web app, based largely on the "Screenshot Manager" extension that Philippe created. We are having an issue with selection, wherein some components that where hidden when the state was saved are being shown when the state is loaded. I have replicated it on viewer.autodesk.io with the vanilla states manager code.
To be precise, components already visible in the viewer that are hidden by CTRL-clicking them on the model browser initially disappear in the viewer. However, when you save this state and then recall the state at a later time, the components hidden in this way re-appear.
Can you please investigate - is this a bug in the states manager code (we had a look but can't find it - the hidden components are being recorded in the state) or in the viewer itself?
Thanks,
Chris
I check what happen when you select components, those 2 states are incompatible: the child gets hidden but the parent gets isolated, hence it is displaying all its children and hide the rest of the components in the model.
In order to get the behavior you "would" expect, you would need to hide all components without isolating the parent sub-assemlbly, then create your first state, then hide the child, create your second state. You may achieve that by writing your handler when clicking a browser node. For that you would need to implement your own ModelStructurePanel.
I've got a basic example which can help you getting started:
ModelStructurePanel
I will take a look at the click handler and add an example there. For the time being, you can check in the source of the viewer3D.js which methods you need to overwrite.
Hope that helps

How to use the same ViewModel for different Pages (views)

I am searching for a way to use one ViewModel for two different Views (Pages). I know there is Multi-view support in Caliburn.Micro and I read a lot of it but I'm not sure if it is what I am looking for or how it works on Windows Phone.
Currently, I have one View ItemPage.xaml and one ViewModel ItemPageViewModel. I use this View/ViewModel to add a new Item and display an existing Item. Depending on the mode (add, show, ...) I need to show/hide or enable/disable some UI elements and display different AppBar buttons.
Instead of control these UI elements by binding to properties, I want to create two seperate Pages(Views) with the corrrect UI elements.
It would be nice to use the same ViewModel for both Pages to avoid repitive code. So is my use-case above possible with Caliburn.Micro for Windows Phone?