So I am trying to access FixedLengthCrvEdit from inside a GHPython Component in grasshopper. Much like Lunchbox RhCom component, but I wanted to be able to bake the curve to rhino from GH and select it and edit it with the command without the user having to keep selecting it or keep typing the command.
I have got the attached code to work and it does what it needs to, but sometimes are clicking an option (Reset or Edit) and changing the curve with FixedLengthCrvEdit. GH kind of freezes, it brings up tooltips etc when you move over a component but you can’t click on anything and you have to restart Rhino to bring it back to life.
Also if the Edit option is set as a switch instead of a button the code seems to be waiting for the command in Rhino to complete before it gives a profiler readout. This is different from the lunchbox RhCom component that is not waiting.
import Rhino as rh import rhinoscriptsyntax as rs import scriptcontext as sc if Reset or Edit: sc.doc = rh.RhinoDoc.ActiveDoc if Reset: rs.AddLayer(Layer) orgCrv = rs.ObjectsByName("Control_Crv") rs.DeleteObjects(orgCrv) attr = rh.DocObjects.ObjectAttributes() #select layer to bake and add to the attributes layertable = sc.doc.Layers layerindex = layertable.Find(Layer,True) attr.LayerIndex = layerindex rh.DocObjects.ObjectAttributes.Name.SetValue(attr,"Control_Crv") #bake object rh.RhinoDoc.ActiveDoc.Objects.AddCurve(Crv,attr) elif Edit: rs.ObjectsByName("Control_Crv",True) rs.Command("FixedLengthCrvEdit") sc.doc = ghdoc
FixedLenghtCrvEdit Issue.gh (31.1 KB)