Autodesk.Revit.DB.Architecture.RoomTagType
是Revit API 中用于表示房间标记类型的类。房间标记类型是基于房间数据与标记展示方式的组合,被用于在Revit项目中创建不同样式的房间标记。
Name
: 获取或设置当前房间标记类型的名称。GetDefaultTagTypeId(Document)
: 获取当前项目中的默认房间标记类型 ID。GetRoomTagType(Document, ElementId)
: 根据给定的ID返回房间标记类型。以下示例演示了如何使用Autodesk.Revit.DB.Architecture.RoomTagType
创建一个新的房间标记类型,然后将其添加到当前模型中。
//创建一个RoomTagType对象
RoomTagType newRoomTagType = new RoomTagType();
//设置房间标记类型的名称
newRoomTagType.Name = "Custom Room Tag";
//获取当前Docuement对象
Document doc = uidoc.Document;
//在Revit中创建一个新的房间标记类型
Transaction trans = new Transaction(doc, "Create New Room Tag Type");
trans.Start();
ElementId newTagTypeId = RoomTagType.Create(doc, newRoomTagType);
//将新创建的房间标记类型添加到LegendCategory中
Category legendCategory = Category.GetCategory(doc, BuiltInCategory.OST_LegendComponents);
doc.Settings.Categories.Assign(newTagTypeId, legendCategory.Id);
trans.Commit();
//输出新创建的房间标记类型的ID
Console.WriteLine("Created new tag type ID: " + newTagTypeId.ToString());