is there a method to convert coerced objects to guid so that they can be used in rhinoscriptsyntax functions? Look on my code below (If I run the script I get an error "Parameter must be a Guid or string representing a Guid. It’s clear for me why.):
import rhinoscriptsyntax as rs
import Rhino as rh
import scriptcontext as sc
if C and S and D and N:
curve = C
surface = S
distance = float(D)
number = int(N)
curve_coe = rs.coercecurve(curve)
surface_coe = rs.coercesurface(surface)
curve_ext = curve_coe.ExtendOnSurface(rh.Geometry.CurveEnd.Both, surface_coe)
rs.PullCurve(surface_coe, curve_ext) #<= Error
I know it can be done easily with rhino common, but what is when I want to continue with rhinoscriptsyntax. Thx.
def PullCurve(surface, curve, delete_input=False):
"""Pulls a curve object to a surface object
Parameters:
surface (guid): the surface's identifier
curve (guid): the curve's identifier
delete_input (bool, optional) should the input items be deleted
Returns:
list(guid, ...): of new curves if successful
None: on error
Example:
import rhinoscriptsyntax as rs
curve = rs.GetObject("Select curve to pull", rs.filter.curve )
surface = rs.GetObject("Select surface that pulls", rs.filter.surface )
rs.PullCurve(surface, curve)
See Also:
IsSurface
"""
crvobj = rhutil.coercerhinoobject(curve, True, True)
brep = rhutil.coercebrep(surface, True)
curve = rhutil.coercecurve(curve, -1, True)
tol = scriptcontext.doc.ModelAbsoluteTolerance
curves = Rhino.Geometry.Curve.PullToBrepFace(curve, brep.Faces[0], tol)
rc = [scriptcontext.doc.Objects.AddCurve(curve) for curve in curves]
if rc:
if delete_input and crvobj:
scriptcontext.doc.Objects.Delete(crvobj, True)
scriptcontext.doc.Views.Redraw()
return rc
The problem lies with the code expecting a GUID for the curve in
thanks for the answer. It would be make sense if I need only one function. But if I want to use more that one function that it will be really tricky to rewrite each function, then I could also jump the the rhinocommon without wrapping it in a function. What I want to know, if it is possible to convert the curve guid in a object with “rs.coerce…()” why it is not possible to reverse this step back.