下载app免费领取会员
在Revit里当我们选中一个柱子的时候,会出现附着和分离两个命令,那在API里应该怎么实现呢?
API里提供了一个ColumnAttachment 类来实现柱的附着和分离功能
下面是一个小例子:
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 = "所选构件无法附着!";
return Result.Failed;
}
Element elm = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element));
if (!ColumnAttachment.IsValidTarget(column, elm))
{
message = "所选构件无法被附着!";
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;
本文版权归腿腿教学网及原创作者所有,未经授权,谢绝转载。