Hi…,
I’ve tried to start here: Rhino - Rhino.Python Guides. Surprisingly I don’t find a topic about curves.
How to get the subcurves of a polycurve in Python?
Thanks
Michael
Hi…,
I’ve tried to start here: Rhino - Rhino.Python Guides. Surprisingly I don’t find a topic about curves.
How to get the subcurves of a polycurve in Python?
Thanks
Michael
Hi @dale,
thank you for the RhinoCommon method. I am still lost, I don’t know how to mix rhinoscriptsyntax with RhinoCommon.
My try doesn’t work:
curve_guid = rs.GetCurveObject("Select PolyCurve")[0]
if curve_guid and rs.IsPolyCurve( curve_guid ):
polycurve = rs.coercerhinoobject( curve_guid )
segment_0 = polycurve.SegmentCurve( 0 ) #error: 'CurveObject' object has no attribute 'SegmentCurve'
Do I have to recreate a RhinoCommon PolyCurve from my rhinoscriptsyntax PolyCurve?
Thanks
Michael
Hi @Michael_Meyer,
How about this?
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
def testme():
rc = rs.GetCurveObject("Select PolyCurve")
if not rc:
return
curve_id = rc[0]
if rs.IsPolyCurve(curve_id):
polycurve = rs.coercecurve(curve_id)
seg0 = polycurve.SegmentCurve(0)
if seg0:
seg_id = sc.doc.Objects.AddCurve(seg0)
seg_obj = sc.doc.Objects.FindId(seg_id)
seg_obj.Select(True)
sc.doc.Views.Redraw()
if( __name__ == "__main__" ):
testme()
– Dale