Guid cannot convert to curve

Hello guys,

I wanna refer crvs from layer by Horster Plug-ins and through that I got ID of the crvs.
However with the code “rs.coercecurve(ID)”, the ID cannot convert to curve as I needed.
There must be some piece of code that I missed so anyone know how to finish it?

Thanks so much!

Same error (V6) for me. This however works:

import Rhino
a = Rhino.RhinoDoc.ActiveDoc.Objects.FindId(id).Geometry

supposed to “id” is of type System.Guid

Hi Tom

Thanks for your reply and the code works!
just bit of change, a = Rhino.RhinoDoc.ActiveDoc.Objects.Find(id).Geometry.
I see when I dot at end of ‘Find(id)’, there is no attributes function list pops-up.
So I assume the ‘.Geometry’ is as the default function that build within GH DOC?


You could try something like this:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
#set focus on Rhino document
sc.doc = Rhino.RhinoDoc.ActiveDoc
   #do something in the Active Rhino Document
     a = rs.coercecurve(id)
#set focus back on GH document
sc.doc = ghdoc

Rhinoscriptsyntax is a wrapper around Rhinocommon. It was made to simplify calling rc functionality in a pythonic way. If it fails for some reason or it has not the right function you can always switch back to rc. However rc is difficult to use if you never coded with it by using C# or Vb. I remember this statement from previous scripts. Find and FindId can be a difference between V5 and V6. It returns a RhinoDocObject (?) from which you need to retreive the underlying geometrical object. This object also contains Objectcolor, Layer and other information. Autocomplete usually breaks here, but you can look at the rc sdk.


RhinoObject from the namespace Rhino.DocObjects (:

Thanks Chris,

This solution makes more sense to me.
I tried to cancel last piece of code: #sc.doc = ghdoc and the output remains the same.
So I guess if a is the final output, won`t be necessary to set focus back the GH DOC again?


Thanks Tom!

As far as I know, as the ghpython component exists now, you should always set it back to ghdoc when you are done when switching scriptcontext.

Also, I don’t have the horster plugin or you file, so I can’t say with authority what is exactly happening…
With that said, depending on which “context” the component is gathering that info, (GUID’s in this case), you are either getting the GUID from the RHINO object(in the active rhino document), OR, you are getting the GUID from the GH Object. I am by no means an expert, but I think the issue you may be running into is which GUID you are getting/expecting. Not sure I explained that correctly…
Lastly, I think that if you set the type hint to GUID on your id input, you may be able to just say a = id and get the curves.
And lastly…lastly, the native geometry pipeline component will allow you to get curves from a layer.


Yes, @chanley, correct. All your answers are absolutely right :slight_smile:


Giulio Piacentino
for Robert McNeel & Associates


Thanks Chris!
quite clear what you said:)