Transaction ts = new Transaction(doc, "http://www.49028c.com");
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;
}
}
新聞熱點
疑難解答