start
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
cmd : IExternalCommand
{
Result Execute(ExternalCommandData cmdData, msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
UIApplication uiApp = cmdData.Application;
Document doc = uiDoc.Document;
Selection selection = uiDoc.Selection;
Transaction ts = Transaction(doc, );
ts.Start();
DuctType ductType = ;
FilteredElementCollector collector = FilteredElementCollector(doc);
collector.OfClass((DuctType));
(Element el collector.ToElements())
{
ductType = el DuctType;
;
}
Reference refDuct = selection.PickObject(ObjectType.Element, );
Duct duct = doc.GetElement(refDuct) Duct;
XYZ xyz = selection.PickPoint(); LocationCurve lCurve = duct.Location LocationCurve;
IntersectionResult interResult = lCurve.Curve.Project(xyz); (interResult != )
{
doc.Create.NewDuct(xyz, interResult.XYZPoint, ductType);
}
ts.Commit();
Result.Succeeded;
}
}url:http://greatverve.cnblogs.com/p/Curve-Project.html