Description
Sélectionne des objets selon la valeur contenue dans leur key “building”.
Voir aussi les scripts Building, BuildingIsolate, BuildingRemove.
Le script suivant fonctionne sur :
- Rhino pour Windows ;
- Rhino pour macOS.
Script par MLAV.LAND, sous licence GNU GPL 3.
Code
import rhinoscriptsyntax as rs
def sel_building():
# Get all objects in the document
all_objects = rs.AllObjects()
if not all_objects:
print("No objects in the document.")
return
unique_building_values = set()
# Collect unique 'building' values
for obj in all_objects:
building_value = rs.GetUserText(obj, "building")
if building_value:
unique_building_values.add(building_value)
if not unique_building_values:
print("No 'building' values found in the document.")
return
# Convert the set to a sorted list for the user to choose from
unique_building_values = sorted(list(unique_building_values))
# Let the user choose multiple values
search_values = rs.MultiListBox(unique_building_values, "Select one or more building(s):", "Select Buildings")
if not search_values:
print("No 'building' values selected.")
return
# Filter objects that match any of the selected 'building' values using list comprehension
matching_objects = [obj for obj in all_objects if rs.GetUserText(obj, "building") in search_values]
if not matching_objects:
print("No objects found with the selected 'building' values.")
return
# Select matching objects
rs.UnselectAllObjects()
rs.SelectObjects(matching_objects)
# Run the function
sel_building()