Cast in old SDK MRhinoObject -> On3dPoint

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());
            }
        }

Does this help?

public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
{
  MRhinoLayerTable layer_table = context.m_doc.m_layer_table;

  int layer_index = layer_table.FindLayer("Default");
  if (layer_index >= 0 && layer_index < layer_table.LayerCount())
  {
    IRhinoLayer layer = layer_table[layer_index];
    MRhinoObject[] obj_list = null;
    int obj_count = context.m_doc.LookupObject(layer, ref obj_list);
    for (int i = 0; i < obj_count; i++)
    {
      MRhinoObject obj = obj_list[i];
      if (null != obj)
      {
        string obj_name = obj.Attributes().m_name;
        if (string.IsNullOrEmpty(obj_name))
          obj_name = "<Empty>";

        RhUtil.RhinoApp().Print(string.Format("Object name = {0}\n", obj_name));

        RhUtil.RhinoApp().Print(string.Format("Object type = {0}\n", obj.ObjectType().ToString()));

        MRhinoPointObject point_obj = MRhinoPointObject.Cast(obj);
        if (null != point_obj)
        {
          string pt_str = null;
          RhUtil.RhinoFormatPoint(point_obj.Point().point, ref pt_str);
          RhUtil.RhinoApp().Print(string.Format("Point = {0}\n", pt_str));
        }
      }
    }
  }
  return IRhinoCommand.result.success;
}

Thanks Dale! That helped… It is probably something basic which I do not understand yet.

Does not work:
On3dPoint p = new On3dPoint(pobj.Point.point);

Does work:
On3dPoint p = new On3dPoint(pobj.Point().point);

MRhinoPointObject.Point() is a function. You are trying to use it like a property, which it isn’t.