-
Notifications
You must be signed in to change notification settings - Fork 16
03: Selecting and visualizing
#Selecting and visualizing When you loaded a model into the viewer, the model is being displayed in the central window pane. There are a number of ways to interact between the graphic display ('the viewer') and the script.
For this purpose, the variables viewer and selection are available by default.
The last object that was selected by the users (either by clicking on a 3D representation or using the tree views to the left) is available in the selection variable:
product = selection
print (selection.GlobalId)Note that GlobalId is available for all objects that have a 3D or 2D representations, since only sub-classes of IfcProduct can have a IfcProductRepresentation. Since IfcProduct in turn is a subclass of IfcRoot, the instance must have a GlobalId
When more then one object is selected in the viewer, the list of all IfcProducts can be retrieved using the get_selection_set() function of the viewer object:
products = viewer.get_selection_set(model)
for product in products:
print(product.GlobalId)In order to get a visual feedback of the the objects manipulated by the script you can use a convenience function to color your results:
products = viewer.get_selection_set(model)
for product in products:
viewer.set_color(product, 0.8,0,0)This colors all currently selected objects red
You can switch the visibility of objects by:
products = model.by_type("IfcWall")
for product in products:
viewer.toggle_visibility(product,True) This hides all wall objects in the model. To switch them on again, replace True by False
Setting