时间:2021-01-23 10:17:19 | 栏目:.NET代码 | 点击:次
Transaction ts = new Transaction(doc, "https://www.jb51.net");
ts.Start();
//得到一种风管类型
DuctType ductType = null;
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfClass(typeof(DuctType));
foreach (Element el in collector.ToElements())
{
ductType = el as DuctType;
break;
}
//
Reference refDuct = selection.PickObject(ObjectType.Element, "选择一根风管:");
Duct duct = doc.GetElement(refDuct) as Duct;
XYZ xyz = selection.PickPoint();//选择一点
LocationCurve lCurve = duct.Location as LocationCurve;
IntersectionResult interResult = lCurve.Curve.Project(xyz);//点在直线上的投影
if (interResult != null)
{
doc.Create.NewDuct(xyz, interResult.XYZPoint, ductType);
}
ts.Commit();
return Result.Succeeded;
}
}