@Helvetosaur wrote:
Is it possible to have script-selected subobjects remain selected after the script finishes?
I am using the following to select certain edges from a brep. (just draw a box that sits on the world XY plane, it should select all the edges but the bottom ones, one at a time)
import rhinoscriptsyntax as rs import scriptcontext as sc import Rhino def EdgeFilter(edges,plane,joined,tol): #returns only those brep edges that correspond to filter criteria #modify filter function as needed filtered_edges=[] for edge in edges: crv=edge.ToNurbsCurve() if not crv.IsInPlane(plane,tol): if joined: if not edge.TrimCount>1: continue filtered_edges.append(edge) return filtered_edges def TestFunction(): objID=rs.GetObject("Select polysurface",16) if not objID: return plane=Rhino.Geometry.Plane.WorldXY tol=sc.doc.ModelAbsoluteTolerance rhobj=rs.coercerhinoobject(objID) brep=rs.coercebrep(objID) #apply the edge filter to get only the edges you want. filtered_edges=EdgeFilter(brep.Edges,plane,True,tol) #select the desired edges for edge in filtered_edges: rhobj.SelectSubObject(edge.ComponentIndex(),True,True) #for visualizing purposes only sc.doc.Views.Redraw() rs.Sleep(500) TestFunction()
However the selected edges are unselected when the script ends. I see there is another post with a similar question, but the answer was
…but the selection does only remain while the script is running and does not stay, so it cannot be used to make eg. a transformation with a pre-selected subobject after the script finished.
Posts: 2
Participants: 2