Revit API布置卫浴装置


//放置卫浴装置
[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.cnblogs.com/p/PlumbingFixtures.html
posted @ 2013-11-01 10:07  大气象  阅读(1262)  评论(0编辑  收藏  举报
http://www.tianqiweiqi.com