Description

Isole des objets selon la valeur de leur key “building”.

Voir aussi les scripts Building, BuildingSelect, 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 isolate_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
 
    # Isolate matching objects
    rs.UnselectAllObjects()
    rs.SelectObjects(matching_objects)
    rs.Command("_Isolate", False)
 
# Run the function
isolate_building()