判断拾取的管道是不是水平方向的,其实原理很简单,判断管道的两个端点的Z坐标是否相等即可:
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
Selection selection = uiDoc.Selection;
Reference reference = selection.PickObject(ObjectType.Element);
Element element = doc.GetElement(reference);
Pipe pipe = element as Pipe;
LocationCurve locationCureve = pipe.Location as LocationCurve;
Curve curve = locationCureve.Curve;
XYZ start = curve.GetEndPoint(0);
XYZ end = curve.GetEndPoint(1);
if (start.Z == end.Z)
{
TaskDialog.Show("Information:","是水平管道...");
}