Using Python script.
I know how to get and select the grips of an object, but how do I get and select the grips of a subobject. I tried using the RhinoObject.GetSubObjects(), turning grips on for the first subobject, getting the grips for the first subobject, and then using Select for the first grip of the first subobject. I’m getting the following error message back:
This object cannot be modified because it is controlled by a document.
I would like to select the first and last grip of the first subobject. How do I do this?
Here is the code. SelectPolyCurveStartAndEndGrips works great in selecting the first and last grips of the polycurve, but SelectPolyCurveStartStartSegmentStartAndEndGrips does not select the first and last grips of the first segment.
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.Geometry as rg
def isPolyCurve(rhObject, geometry, componentIndex):
return isinstance(geometry, rg.PolyCurve)
def SelectPolyCurveStartAndEndGrips():
pc = rs.GetObject('Select polycurve.', custom_filter=isPolyCurve)
print pc
sc.doc.Objects.UnselectAll()
rhObj = sc.doc.Objects.Find(pc)
rhObj.GripsOn = True
grips = rhObj.GetGrips()
grips[0].Select(True, True)
grips[len(grips) - 1].Select(True, True)
sc.doc.Views.Redraw()
def SelectPolyCurveStartStartSegmentStartAndEndGrips():
pc = rs.GetObject('Select polycurve.', custom_filter=isPolyCurve)
print pc
sc.doc.Objects.UnselectAll()
rhObj = sc.doc.Objects.Find(pc)
subObjs = rhObj.GetSubObjects()
firstSubObj = subObjs[0]
firstSubObj.GripsOn = True
grips = firstSubObj.GetGrips()
grips[0].Select(True, True)
grips[len(grips) - 1].Select(True, True)
sc.doc.Views.Redraw()
if __name__ == '__main__':
#SelectPolyCurveStartAndEndGrips()
SelectPolyCurveStartStartSegmentStartAndEndGrips()