在Revit项目文件里创建标注可以用
NewDimension
这个方法有两个重载,一个使用默认的标注类型,一个可以指定标注类型
在项目文件和在族文件能创建的标注种类是不一样的,读者可以自己研究研究
下面是一个标注墙的小例子:
UIDocument uidoc = commandData.Application.ActiveUIDocument;
Document doc = uidoc.Document;
Wall wall = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element)) as Wall;
if (wall != null)
{
ReferenceArray refArry = new ReferenceArray();
Line wallLine =(wall.Location as LocationCurve).Curve as Line;
XYZ wallDir = ((wall.Location as LocationCurve).Curve as Line).Direction;
Options opt = new Options();
opt.ComputeReferences = true;
opt.DetailLevel = ViewDetailLevel.Fine;
GeometryElement gelem = wall.get_Geometry(opt);
foreach (GeometryObject gobj in gelem)
{
if (gobj is Solid)
{
Solid solid = gobj as Solid;
foreach (Face face in solid.Faces)
{
if (face is PlanarFace)
{
XYZ faceDir =face.ComputeNormal(new UV());
if (faceDir.IsAlmostEqualTo(wallDir)||faceDir.IsAlmostEqualTo(-wallDir))
{
refArry.Append(face.Reference);
}
}
}
}
}
Transaction trans = new Transaction(doc, "trans");
trans.Start();
doc.Create.NewDimension(doc.ActiveView, wallLine, refArry);
trans.Commit();
}
return Result.Succeeded;