@Helvetosaur wrote:
Last one for today - I am trying to figure out how to include a preselected set of subobjects (say, brep edges) into a selection process where one can continue selecting more edges and removing some of the existing ones from the selection.
I have tested many different variations, the best I have been able to do is run the process twice, once to get the preselection, and once to get the post selection, but I don’t know how to be able to interact with the preselected ones after (in case I want to deselect some).
The end goal is that the preselected subobjects will be chosen programmatically, not by hand, but for testing one can simply preselect a few with Ctrl+Shift+Pick. then in the script, I want to ask the user to edit the selection, either adding to or subtracting from it.
The following works for pre- or post selction, but not both. I have tried a bunch of other stuff, but to keep things short here, I will not post them all.
import Rhino import scriptcontext import rhinoscriptsyntax as rs def TestSO(prompt,filt): go = Rhino.Input.Custom.GetObject() go.SetCommandPrompt(prompt) go.GeometryFilter=filt go.SubObjectSelect=True go.ChooseOneQuestion = True go.GetMultiple(1,0) if go.CommandResult()!=Rhino.Commands.Result.Success: return go.CommandResult() objrefs = go.Objects() if not objrefs: return Rhino.Commands.Result.Nothing rc=[] for objref in objrefs: indices=[] for item in objref.Object().GetSelectedSubObjects(): #select subobject objref.Object().SelectSubObject(item, True, True, True) #append index to return indices.append(item.Index) rc.append([objref.ObjectId,indices]) return rc prompt="Select some brep edges" result=TestSO(prompt,Rhino.DocObjects.ObjectType.Curve) print "{} edges selected".format(len(result))
Posts: 1
Participants: 1