过滤器代码
public class ColumnSelectionFilter : ISelectionFilter
{
public RevitLinkInstance instance = null;
public bool AllowElement(Element elem)
{
instance = elem as RevitLinkInstance;
if (instance != null)
{
return true;
}
return false;
}
public bool AllowReference(Reference reference, XYZ position)
{
if (instance == null)
{
return false;
}
else
{
Document linkdocument = instance.GetLinkDocument();
FamilyInstance familyinstance = linkdocument.GetElement(reference.LinkedElementId) as FamilyInstance;
//这里简单限制一下筛选条件
if ((familyinstance.Symbol.Family.Name.Contains("混凝土") && familyinstance.Symbol.Family.Name.Contains("柱")))
{
return true;
}
return false;
}
}
}
获取链接文件中的族实例
Reference refer = uidoc.Selection.PickObject(ObjectType.LinkedElement, new ColumnSelectionFilter(), "请选择混凝土柱");
RevitLinkInstance linkInstance = doc.GetElement(refer) as RevitLinkInstance;
Document linkDoc = linkInstance.GetLinkDocument();
FamilyInstance instance = linkDoc.GetElement(refer.LinkedElementId) as FamilyInstance;
过滤器获取链接文件族实例
详细谈及两种情况下实例筛选
过滤器坐标转换内容
过滤器坐标转换相关内容