Autodesk.Revit.DB.Structure.StructuralConnectionApplyTo是Revit API中用于指定连接对齐方式的类。它用于定义构造连接要应用的对象类别。
以下示例演示如何使用StructuralConnectionApplyTo类。
//获取当前文档
Document doc = ActiveUIDocument.Document;
//定义连接对象
StructuralConnectionConnectionType connType = StructuralConnectionConnectionType.Weld;
StructuralConnectionEndType endType = StructuralConnectionEndType.Beam;
double value = 100;
StructuralConnectionApplyTo applyTo = new StructuralConnectionApplyTo();
applyTo.SteelElements = true;
applyTo.ConcreteElements = false;
//创建连接
StructuralConnection connection = StructuralConnection.Create(doc, connType, endType, value, applyTo);
//将连接应用到所选构造元素
ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
foreach(ElementId id in selectedIds)
{
Element elem = doc.GetElement(id);
if(elem is FamilyInstance)
{
FamilyInstance familyInstance = elem as FamilyInstance;
StructuralConnectionHandler handler = StructuralConnectionHandler.Create(familyInstance);
handler.AddConnection(connection);
}
}