rs.ExtendSurface returns bool!?

Hey,
Im trying to create a rhinoscript/python node that extends an untrimmed surface, but reading the documentation on rs.extendSurface I found this in the online documentation:

Parameters:
surface_id = identifier of a surface
parameter = tuple of two values definfing the U,V parameter to evaluate.
The surface edge closest to the U,V parameter will be the edge that is
extended
length = amount to extend to surface
smooth[opt] = If True, the surface is extended smoothly curving from the
edge. If False, the surface is extended in a straight line from the edge
Returns:
True or False indicating success or failure

rs.ExtendSurface returns only true or false indicating success or failure, but no actual surface or surface_id!?
How can I retrieve the exteneded surface for further GH operations?

The complete code of rhinoscriptsyntax is available on GitHub.

For ExtendSurface, you find the code below. It needs as input a surface_id, so that means that this function only works on surfaces that are in the Rhino document; and not on surfaces that are in the Grasshopper document. This means that you can’t use rs.ExtendSurface in Grasshopper Python scripting. I would advise you to look at the code below and ‘roll your own’ ExtendSurface for use in Grasshopper Ptyhon scripting.

def ExtendSurface(surface_id, parameter, length, smooth=True):
    """Lengthens an untrimmed surface object
    Parameters:
      surface_id = identifier of a surface
      parameter = tuple of two values definfing the U,V parameter to evaluate.
        The surface edge closest to the U,V parameter will be the edge that is
        extended
      length = amount to extend to surface
      smooth[opt] = If True, the surface is extended smoothly curving from the
        edge. If False, the surface is extended in a straight line from the edge
    Returns:
      True or False indicating success or failure
    Example:
      import rhinoscriptsyntax as rs
      pick = rs.GetObjectEx("Select surface to extend", rs.filter.surface)
      if pick:
      parameter = rs.SurfaceClosestPoint(pick[0], pick[3])
      rs.ExtendSurface(pick[0], parameter, 5.0)
    See Also:
      IsSurface
    """
    surface = rhutil.coercesurface(surface_id, True)
    edge = surface.ClosestSide(parameter[0], parameter[1])
    newsrf = surface.Extend(edge, length, smooth)
    if newsrf:
        surface_id = rhutil.coerceguid(surface_id)
        if surface_id: scriptcontext.doc.Objects.Replace(surface_id, newsrf)
        scriptcontext.doc.Views.Redraw()
return newsrf is not None
1 Like

Thanks for clearifying this!