I'm using the Forge Viewer to display properties on selected items in my model.
When an object is selected, I want to automatically show the properties panel but keep a category collapsed. Here's the code I'm using in an attempt to achieve this:
viewer.addEventListener(
Autodesk.Viewing.SELECTION_CHANGED_EVENT,
() => {
const panel = viewer.getPropertyPanel();
panel.setVisible(true);
panel.setCategoryCollapsed("Category Name", true);
},
);
The event is raised and the panel is shown, however, the function setCategoryCollapsed
does not work (understandable as it was last documented in v5). Is there a similar function in v7 to collapse a category?
That function expects an object with name and type properties - e.g. if I wanted to collapse the "Graphics" category, I could do it like this:
const panel = viewer.getPropertyPanel();
panel.setVisible(true);
panel.setCategoryCollapsed({name: "Graphics", type: "category"}, true);
Have also just written a blog post about it now: Collapse category in the Property Panel