///<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 surface edge"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.edge_object); go.EnableSubObjectSelect(); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } MRhinoObjRef obj_ref = go.Object(0); IOnBrepEdge brep_edge = obj_ref.Edge(); if (null == brep_edge) { return(IRhinoCommand.result.failure); } IOnBrep brep = brep_edge.Brep(); if (null == brep) { return(IRhinoCommand.result.failure); } // TODO: add functionality here... return(IRhinoCommand.result.success); }
///<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 edge curve"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.edge_object); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) return go.CommandResult(); IRhinoObject obj = go.Object(0).Object(); IOnBrep brep = go.Object(0).Brep(); IOnBrepEdge edge = go.Object(0).Edge(); if (null == obj || null == brep || null == edge) return IRhinoCommand.result.failure; MRhinoObjectAttributes attribs = new MRhinoObjectAttributes(obj.Attributes()); if (attribs.GroupCount() > 0) attribs.RemoveFromAllGroups(); for (int i = 0; i < edge.TrimCount(); i++) { IOnBrepTrim trim = edge.Trim(i); if (null != trim) { IOnBrepFace face = trim.Face(); if (null != face) { OnBrep face_brep = brep.DuplicateFace(face.m_face_index, true); if (null != face_brep) { MRhinoBrepObject face_brep_obj = context.m_doc.AddBrepObject(face_brep, attribs); if (null != face_brep_obj) face_brep_obj.Select(); } } } } context.m_doc.Redraw(); return IRhinoCommand.result.success; }