///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoGetObject go = new MRhinoGetObject(); go.SetCommandPrompt("Select rectangular light"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.light_object); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } IOnLight light = go.Object(0).Light(); if (null == light) { return(IRhinoCommand.result.failure); } if (!light.IsRectangularLight()) { RhUtil.RhinoApp().Print("Not a rectangular light.\n"); return(IRhinoCommand.result.nothing); } On3dPoint origin = light.Location(); On3dVector xaxis = light.Length(); On3dVector yaxis = light.Width(); OnPlane plane = new OnPlane(origin, xaxis, yaxis); OnInterval x_interval = new OnInterval(0.0, xaxis.Length()); OnInterval y_interval = new OnInterval(0.0, yaxis.Length()); OnMesh mesh = RhUtil.RhinoMeshPlane(plane, x_interval, y_interval, 2, 2); if (null != mesh) { mesh.ConvertQuadsToTriangles(); context.m_doc.AddMeshObject(mesh); context.m_doc.Redraw(); } return(IRhinoCommand.result.cancel); }