Parameters
strObject Required. String. The object’s identifier.
intSide Required. Number. The side to extend.
0 Extend from the start of the curve.
1 Extend from the end of the curve.
arrPoint Required. Array. The 3-D point.
intType Optional. Number. Type of extension.
0 Line - Creates an line extension tangent to the original curve.
1 Arc - Creates an arc extension tangent to the original curve.
2 (Default) Smooth - Creates a smooth curve extension curvature continuous with the original curve.
hello,
I am trying exactly to do this. extendcurvepoint with arc instead of smooth line.
it’s not working. Could you add this funtionality? Or let me know if there is another way to make it.
thank you very much.
José Verdú Cano
Apparently this change has not yet been made. There are two possibilities currently:
Edit the curve.py file in your rhinoscriptsyntax library folder and replace the entire ExtendCurvePoint method with the following:
def ExtendCurvePoint(curve_id, side, point, type=2):
"""Extends a non-closed curve by smooth extension to a point
-- modified by Mitch Heynick 09.11.20 --
Parameters:
curve_id (guid): curve to extend
side (number):
0=extend from start of the curve
1=extend from end of the curve
point (guid|point): point to extend to
type (number):
0=line extension tangent to the original curve
1=arc extension tangent to the original curve
2=smooth (curvature continuous) extension from the original curve.
Returns:
guid: The identifier of the new object if successful.
None: if not successful, or on error.
Example:
import rhinoscriptsyntax as rs
curve = rs.GetObject("Select curve to extend", rs.filter.curve)
if curve:
point = rs.GetPoint("Point to extend to")
if point: rs.ExtendCurvePoint(curve, 1, point, 1)
See Also:
ExtendCurve
ExtendCurveLength
"""
curve = rhutil.coercecurve(curve_id, -1, True)
point = rhutil.coerce3dpoint(point, True)
if side==0: side = Rhino.Geometry.CurveEnd.Start
elif side==1: side = Rhino.Geometry.CurveEnd.End
else: raise ValueError("side must be 0 or 1")
if type==0: extension_type = Rhino.Geometry.CurveExtensionStyle.Line
elif type==1: extension_type = Rhino.Geometry.CurveExtensionStyle.Arc
elif type==2: extension_type = Rhino.Geometry.CurveExtensionStyle.Smooth
else: raise ValueError("type must be 0, 1, or 2")
newcurve = curve.Extend(side, extension_type, point)
if newcurve and newcurve.IsValid:
curve_id = rhutil.coerceguid(curve_id, True)
if scriptcontext.doc.Objects.Replace( curve_id, newcurve ):
scriptcontext.doc.Views.Redraw()
return curve_id
return scriptcontext.errorhandler()
@alain - the above should work hopefully, so it could be added to curve.py - check it though and eliminate the comment with my name in it…
or,
If you do not want to edit the curve.py file, you can use the following as your own custom definition in any script:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def ExtendCurveToPoint(curve_id, side, point, type=2):
#Extends a non-closed curve by smooth extension to a point
#Fixes limitation of rs.ExtendCurvePoint() by adding type argument
curve = rs.coercecurve(curve_id, -1, True)
point = rs.coerce3dpoint(point, True)
if side==0: side = Rhino.Geometry.CurveEnd.Start
elif side==1: side = Rhino.Geometry.CurveEnd.End
else: return
if type==0: extension_type = Rhino.Geometry.CurveExtensionStyle.Line
elif type==1: extension_type = Rhino.Geometry.CurveExtensionStyle.Arc
elif type==2: extension_type = Rhino.Geometry.CurveExtensionStyle.Smooth
else: return
newcurve = curve.Extend(side, extension_type, point)
if newcurve and newcurve.IsValid:
curve_id = rs.coerceguid(curve_id, True)
if sc.doc.Objects.Replace( curve_id, newcurve ):
sc.doc.Views.Redraw()
return curve_id
(for this to work, you do need to import scriptcontext as sc and Rhino)
Hi Mitch, coincidentally I pushed a fix a little while before you posted.
It fixes the immediate problem with ‘Arc’ but the ‘Line’ option still doesn’t work and I didn’t address it because the RhinoScript version also isn’t quite right and needs to be revised.
Thanks!
Ah, I see that - well, there isn’t really a extend by line to point function in native Rhino anyway - would only work correctly if the point is exactly on the line… It doesn’t actually work using Extend>Arc>ToPoint in Rhino either (if the extension point is exactly on the line), it would make an arc of an infinite radius of course…
Maybe the line option should just be eliminated from both the Rhinoscript and rhinoscriptsyntax methods…
Hello Helvetosaur,
The boton extend line to a point works perfect for me, but when i make it with commands doesn’t work.
I have checked the code you have post and doesn’t work with the line on the left. I send attached the file with what I am working. if you have any ideas to make it with other way let me know.
thank you very much for your time.