Revit 二次开发 选点、边、面

选点

UIDocument uiDoc = commandData.Application.ActiveUIDocument;
XYZ point0 = uiDoc.Selection.PickPoint("请选择一个点");

选边

UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Reference edgeRef = uiDoc.Selection.PickObject(ObjectType.Edge, "请选择边");
Element elem = uiDoc.Document.GetElement(edgeRef);
Edge edge = elem.GetGeometryObjectFromReference(edgeRef) as Edge;
Line line = edge.AsCurve() as Line;

选面

UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Reference edgeRef = uiDoc.Selection.PickObject(ObjectType.Face, "请选择面");
Element elem = uiDoc.Document.GetElement(edgeRef);
Face face = elem.GetGeometryObjectFromReference(edgeRef) as Face;

你可能感兴趣的:(学习历程,c#)