I want to create geometry on certain sub-curves of a polycurve.
What I would like to do is
1 - select the polycurve
2 - explode the curve
3 - let the user edit the selection of exploded subcurves (de-select/re-select)
Does anybody have an idea how to approach this?
Specifically I’m looking for a way to have a selection active and toggle selection from it by user pick.
I have it working but only blindly; I cannot have the current selection selected while in a rs.GetObjects()
Working with Displayconduit I got a little further:
Question now would be how to catch an object click/pick.
In other words how catch clicking on an object.
import rhinoscriptsyntax as rs import scriptcontext as sc import System.Drawing as SD import Rhino class DrawCurves(Rhino.Display.DisplayConduit): def __init__(self, curves): self.color = SD.Color.FromArgb(255 ,255, 0) self.curves = curves def DrawOverlay(self, e): #print 'drawing' for curve in [rs.coercecurve(curve) for curve in self.curves]: #curve.Translate(2,2,0) e.Display.DrawCurve(curve,self.color) def EditSelection(selection): # filter to only select objects in selection def selFilter(rhino_object, geometry, component_index): return rhino_object.Attributes.ObjectId in selection new_selection = selection [:] conduit = DrawCurves(new_selection) while True: conduit.Enabled = True objs=rs.GetObjects("Toggle Objects",custom_filter=selFilter) if not objs: break conduit.Enabled = False for obj in objs: if obj in new_selection: #delete from new_selection new_selection.pop(new_selection.index(obj)) elif obj in selection: #add to new_selection new_selection.append(obj) conduit.Enabled = False return new_selection def Test(): polycrvs = rs.GetObjects('curves',filter=4) if not polycrvs: return exploded = rs.ExplodeCurves(polycrvs, delete_input=False) curves = EditSelection(exploded) rs.UnselectAllObjects() rs.SelectObjects(curves) rs.Sleep(500) rs.DeleteObjects(exploded) Test()