def get_objects(name=None, color=None, layer=None): guids = rs.AllObjects() if name: guids = list(set(guids) & set(rs.ObjectsByName(name))) if color: guids = list(set(guids) & set(rs.ObjectsByColor(color))) if layer: guids = list(set(guids) & set(rs.ObjectsByLayer(layer))) return guids
import rhinoscriptsyntax as rs #helps in selecting stuff exported from bim obj = rs.GetObject("Pick any object") if obj: color = rs.ObjectColor(obj) rs.ObjectsByColor(color, True)
def get_objects(name=None, color=None, layer=None, type=None): """Get identifiers of Rhino objects, potentially filtered by name, color, layer, or type. Parameters ---------- name : str, optional color : tuple or list, optional RGB color components in integer format (0-255). layer : str, optional type : Rhino.DocObjects.ObjectType, optional The object type. Returns ------- list The GUIDs of the objects matching the filter parameters. Examples -------- .. code-block:: python import compas_rhino guids_all = compas_rhino.get_objects() guids_compas = compas_rhino.get_objects(name='COMPAS.*') guids_red = compas_rhino.get_objects(color=(255, 0, 0)) guids_points = compas_rhino.get_objects(type=compas_rhino.rs.filter.point) guids_redpoints = compas_rhino.get_objects(color=(255, 0, 0), type=compas_rhino.rs.filter.point) .. code-block:: python guids_all = set(compas_rhino.get_objects()) guids_compas = set(compas_rhino.get_objects(name='COMPAS.*')) guids_red = set(compas_rhino.get_objects(color=(255, 0, 0))) guids_points = set(compas_rhino.get_objects(type=compas_rhino.rs.filter.point)) guids_redpoints = set(compas_rhino.get_objects(color=(255, 0, 0), type=compas_rhino.rs.filter.point)) print guids_compas.issubset(guids_all) print guids_all.issubset(guids_compas) # True, False print guids_red.issubset(guids_all) print guids_points.issubset(guids_all) print guids_redpoints.issubset(guids_all) # True, True, True print guids_redpoints.issubset(guids_points) print guids_redpoints.issubset(guids_red) print guids_points.issubset(guids_red) # True, True, False """ guids = rs.AllObjects() if name: guids = list(set(guids) & set(rs.ObjectsByName(name))) if color: guids = list(set(guids) & set(rs.ObjectsByColor(color))) if layer: guids = list(set(guids) & set(rs.ObjectsByLayer(layer))) if type: guids = list(set(guids) & set(rs.ObjectsByType(type))) return guids
polylines = [] polyline = rs.AddCurve(lines4, 1) polylines.append(polyline) angle = rs.Angle2(lines3[0], lines3[1]) rotation = angle[0] #rs.ObjectColor(innerCircle, color=(255,0,0)) #rs.ObjectColor(outterCircle, color=(255,0,0)) for t in range(len(dividedPoints)): polylines.append(rs.RotateObject(polyline, point, rotation*t, axis=None, copy=True)) rs.ObjectColor(polyline, color=(255,0,0)) white = rs.CreateColor(255,255,255) translation = rs.VectorCreate(dividedPoints[1], dividedPointsInner[6]) rs.CopyObjects(polylines, translation) translation = rs.VectorCreate(dividedPoints[4], dividedPointsInner[9]) rs.CopyObjects(polylines, translation) translation = rs.VectorCreate(dividedPoints[6], dividedPointsInner[1]) rs.CopyObjects(polylines, translation) translation = rs.VectorCreate(dividedPoints[9], dividedPointsInner[4]) rs.CopyObjects(polylines, translation) #rs.CopyObjects(outterCircle, translation) #rs.CopyObjects(innerCircle, translation) rs.DeleteObjects(rs.ObjectsByColor(white))