实现Revit中多类别标记的方法
-
标记方法的关键词:
IndependentTag
-
在创建标记中有两个方法,输入的参数基本一致,但是还是有所区别,下面描述和图片可以更好的区分
第一个函数:通过实际的项目坐标点不需要制定标记类型创建多类别标记
Create Method (Document, ElementId, ElementId, Reference, Boolean, TagOrientation, XYZ)
第二个函数:通过UVPoint也就是在构件上面的点控制显示位置并且需要制定标记类别
Create( Document document, ElementId ownerDBViewId, Reference referenceToTag, bool addLeader, TagMode tagMode, TagOrientation tagOrientation, XYZ pnt )
-
代码实例通过document读取视图中的元素,放置多类别注释,如果需要多视图同时操作,则需要找到所有的view并将view传入获得所有的构件
using (Transaction transaction= new Transaction(doc))
{
transaction.Start("TT");
var collector = new FilteredElementCollector(doc);
var views = collector.OfClass(typeof(View)).OfCategory(BuiltInCategory.OST_Views).Cast<View>().Where(v=>
(v.ViewType == ViewType.EngineeringPlan || v.ViewType == ViewType.FloorPlan) && v.CanBePrinted);
foreach (var view in views)
{
var instances = new FilteredElementCollector(doc, view.Id).WhereElementIsNotElementType()
.Where(x => x.GetType() == typeof(FamilyInstance) || x.GetType() == typeof(Pipe))
.ToList();
foreach (Element instance in instances)
{
var reference = new Reference(instance);
IndependentTag.Create(doc,view.Id,reference,true,TagMode.TM_ADDBY_MULTICATEGORY,TagOrientation.Vertical,XYZ.Zero);
IndependentTag.Create(doc,new ElementId(7315142) ,view.Id,reference,true,TagOrientation.Vertical,XYZ.Zero);
}
}
transaction.Commit();
}