//放置卫浴装置
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdSetPlumb : IExternalCommand
{
public Result Execute(ExternalCommandData cmdData,
ref string msg, ElementSet elements)
{
UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
Transaction ts =
new Transaction(uiDoc.Document,
"SetFamily");
ts.Start();
FilteredElementCollector collector =
new FilteredElementCollector(uiDoc.Document);
collector.OfCategory(BuiltInCategory.OST_PlumbingFixtures);
FamilySymbol fs =
null;
foreach (Element el
in collector)
{
fs = el
as FamilySymbol;
break;
}
XYZ xyz = uiDoc.Selection.PickPoint();
//选择一个点
//根据族符号放置族实例的方法
FamilyInstance fi = uiDoc.Document.Create.NewFamilyInstance(xyz, fs, StructuralType.NonStructural);
ts.Commit();
return Result.Succeeded;
}
}url:http://greatverve.cnb
logs.com/p/PlumbingFixtures.html