下載app免費領(lǐng)取會員
在Revit里當(dāng)我們選中一個柱子的時候,會出現(xiàn)附著和分離兩個命令,那在API里應(yīng)該怎么實現(xiàn)呢?
API里提供了一個ColumnAttachment 類來實現(xiàn)柱的附著和分離功能
下面是一個小例子:
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = commandData.Application.ActiveUIDocument.Document;
FamilyInstance column = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element)) as FamilyInstance;
if (!ColumnAttachment.IsValidColumn(column))
{
message = "所選構(gòu)件無法附著!";
return Result.Failed;
}
Element elm = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element));
if (!ColumnAttachment.IsValidTarget(column, elm))
{
message = "所選構(gòu)件無法被附著!";
return Result.Failed;
}
Transaction trans = new Transaction(doc, "trans");
trans.Start();
ColumnAttachment.AddColumnAttachment(doc, column, elm, 0, ColumnAttachmentCutStyle.None, ColumnAttachmentJustification.Tangent, 10);
trans.Commit();
return Result.Succeeded;
本文版權(quán)歸腿腿教學(xué)網(wǎng)及原創(chuàng)作者所有,未經(jīng)授權(quán),謝絕轉(zhuǎn)載。
上一篇:二次開發(fā)教程:Revit開發(fā)之標(biāo)注創(chuàng)建
下一篇:Revit中如何為風(fēng)管系統(tǒng)生成布局?
推薦專題