Wishlist rs.ExtendCurveOnSurface()

Hey,
It would be great if we could get the ExtendCurveOnSurface function implemented in rhinoscriptsyntax library.

I have worked up an example using Rhino.Geometry and it seems to work fine for me. The rs.coercecurve would need to be changed to rhutil.coercecurve and some if/elifs for selecting which end to extend but the core functions all seem to be present for this to be added.

import rhinoscriptsyntax as rs
import Rhino
from scriptcontext import doc 

def ExtendCurveOnSurface(Crv,Srf):
    Surface=rs.coercesurface(Srf)
    Curve=rs.coercecurve(Crv)
    Extended=Curve.ExtendOnSurface(Rhino.Geometry.CurveEnd.Both,Surface)
    if Extended!=None:
        doc.Objects.Replace(Crv,Extended)
        doc.Views.Redraw()

Thanks,
5chmidt

Hi Peter,

I’ve added this to the wish list for V6.

Has this been implimented in V6 as I cannot find it .

No. It is currently on the “Future” list: RH-26627

Doesn’t look like it, no,. Neither in VB Rhinoscript nor Python rhinoscriptsyntax.

However, it is available in RhinoCommon, so a python function could be written to emulate it:

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_ExtendOnSurface_1.htm

Here is a bit of sample code (obviously more/better UI could be added):

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def ExtendCrvOnSrf(crv,crv_end,srf):
    return crv.ExtendOnSurface(crv_end,srf)
    
def ClosestEnd(crv,pick_pt):
    #determines the closest curve end to the pick point
    dom=crv.Domain
    rc,par=crv.ClosestPoint(pick_pt)
    if rc:
        start_len=crv.GetLength(Rhino.Geometry.Interval(dom.T0,par))
        end_len=crv.GetLength(Rhino.Geometry.Interval(par,dom.T1))
        if start_len<end_len:
            return Rhino.Geometry.CurveEnd.Start
        else:
            return Rhino.Geometry.CurveEnd.End
    
def TestFunction():
    crvID=rs.GetObject("Select curve to extend",4)
    if not crvID: return
    
    srfID=rs.GetObject("Select surface that curve is on",8)
    if not srfID: return
    
    pick_pt=rs.GetPointOnCurve(crvID,"Pick end of curve to extend")
    if not pick_pt: return
    
    crv=rs.coercecurve(crvID)
    srf=rs.coercesurface(srfID)
    #determine if pick point was closer to start or end
    crv_end=ClosestEnd(crv,pick_pt)
    if crv_end:
        ext_crv=ExtendCrvOnSrf(crv,crv_end,srf)
        if ext_crv:
            sc.doc.Objects.AddCurve(ext_crv)
            rs.DeleteObject(crvID)
TestFunction()

Thanks very much for your help this will keep me progressing, nice to see the proper VB script eventually though.