Hi
I have a question concerning a cast from a MRhinoObject to On3dPoint. I have limited experience with .net but I need to fix/change something in an old c# code based on the rhino 4 sdk. My goal is actually to print the x,y,z coordinates of several points on a specific Layer. I am getting an error in this line:
On3dPoint p = new On3dPoint(pobj.Point.point);
There is something wrong in how I handle the type conversion from RhinoObject to On3dPoint. But I cannot figure out what needs to be changed. Any help is more than welcome!
Thanks
M
public object GetFormN()
{
MRhinoLayerTable layer_table = RhUtil.RhinoApp().ActiveDoc().m_layer_table;
string layer_name;
layer_name = "Default";
// Find the layer
int layer_index = layer_table.FindLayer(layer_name);
// Get the layer
IRhinoLayer layer = layer_table[layer_index];
// Get all of the objects on the layer
MRhinoObject[] obj_list = null;
int obj_count = RhUtil.RhinoApp().ActiveDoc().LookupObject(layer, ref obj_list);
// Iterate through all objects
for (int i = 0; (i <= (obj_count - 1)); i++) {
MRhinoObject obj = obj_list[i];
MRhinoObjectAttributes obj_attribs = new MRhinoObjectAttributes(obj.Attributes());
string name = obj_attribs.m_name;
RhUtil.RhinoApp().Print(obj.ObjectType().ToString());
RhUtil.RhinoApp().Print(name.ToString());
MRhinoPointObject pobj = MRhinoPointObject.Cast(obj);
On3dPoint p = new On3dPoint(pobj.Point.point);
RhUtil.RhinoApp().Print(p.x.ToString());
}
}