Get the layer name of curve with c#

Hi,

I want to get the layer message of curve through c# code as following. But there is a problem that the “Rhino.Geometry.Curve” type cannot implicitly be converted to “Rhino.DocObjects.CurveObject”.

Please give me some suggestions. Any help is appreciated.
Thank you!

private void RunScript(List x, ref object A)
{
Rhino.DocObjects.CurveObject rhobj = x[i];
int index = rhobj.Attributes.LayerIndex;
string name = doc.Layers[index].Name;
}

private void RunScript(Guid id, ref object A)
{
  var obj = RhinoDocument.Objects.Find(id);
  A = RhinoDocument.Layers[obj.Attributes.LayerIndex];
}

Layer.gh (2.4 KB)

Thanks!

The code that you provided can work!

Hi Mahdiyar!

I have one more question about the method of “RhinoDocument.Objects.Find()”. I tried to find this method in RhinoCommon API document. Unfortunately, I cannont find this method. Could you give me some tips where I can get the message about RhinoDocument class in c#.

Thank you very much!

Hi @nikko_1983,

Are you looking for this?

– Dale