实现Revit中多类别标记的方法

  1. 标记方法的关键词:IndependentTag
  2. 在创建标记中有两个方法,输入的参数基本一致,但是还是有所区别,下面描述和图片可以更好的区分
    第一个函数:通过实际的项目坐标点不需要制定标记类型创建多类别标记
    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 )
![在这里插入图片描述](https://cdn.bimath.com/blog/pg/Snipaste_2026-01-04_15-33-53.png)
  1. 代码实例通过document读取视图中的元素,放置多类别注释,如果需要多视图同时操作,则需要找到所有的view并将view传入获得所有的构件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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();
}