Revit API布置喷头(放置任何元素的方法类似)
FilteredElementCollector 可以过滤到系统或者文档中包含的族符号。
比如喷头,只要知道内参就可以找到。
比如喷头,只要知道内参就可以找到。
//放置族实例
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdSetFamily : 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);
//喷头,根据内参可以得到系统族符号,内参可以通过选择元素得到:http://revit.5d6d.com/thread-1261-1-1.html
collector.OfCategory(BuiltInCategory.OST_Sprinklers);
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;
}
}
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class cmdSetFamily : 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);
//喷头,根据内参可以得到系统族符号,内参可以通过选择元素得到:http://revit.5d6d.com/thread-1261-1-1.html
collector.OfCategory(BuiltInCategory.OST_Sprinklers);
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;
}
}
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。