How to scale a curve in Rhinocommon

unhandled

(Shahid Ghouse) #1

Hi,

I wish to scale a polyline from the center point uniformly. All the methods I have seen so far return a boolean and not a scaled geometry. Can somebody please help?


#2

If you use a scale transform and then use polyline.Transform(xform), yes, it does the transformation “in-place”, the Boolean indicates success or failure. To have a scaled copy, create a new instance of the polyline and then transform that…

new_polyline=polyline.Duplicate()
xform=Rhino.Geometry.Transform.Scale(polyline.CenterPoint(),2)
new_polyline.Transform(xform)

Edit: changed transform to scale around polyline center point…


(Shahid Ghouse) #3

Polyline does not have the Duplicate method @Helvetosaur. Thanks a lot for the help!


#4

http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Polyline_Duplicate.htm


(Shahid Ghouse) #5

I saw that but the I get the following


(Shahid Ghouse) #6

The work around is to set the type hint as a curve. That will allow duplication but then the centerpoint method won’t work


#7

OK, I didn’t know you were running in Grasshopper… Let me look…


(Laurent Delrieu) #8

You wrote dupicate not duplicate you miss a L.


#9

Just remember, there is also a difference between a Polyline object and a PolylineCurve object. The first is essentially just a list of 3D points, while the second is a real curve object. If you want to output the curve, you will need to transform the scaled polyline into a PolylineCurve, otherwise you will just get a list of points as output.

ScalePolyline.gh (6.7 KB)


(Shahid Ghouse) #10

Thanks a lot for helps everyone! I managed to do this like so