下載app免費(fèi)領(lǐng)取會(huì)員
在Revit項(xiàng)目文件里創(chuàng)建標(biāo)注可以用
NewDimension
這個(gè)方法有兩個(gè)重載,一個(gè)使用默認(rèn)的標(biāo)注類型,一個(gè)可以指定標(biāo)注類型
在項(xiàng)目文件和在族文件能創(chuàng)建的標(biāo)注種類是不一樣的,讀者可以自己研究研究
下面是一個(gè)標(biāo)注墻的小例子:
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;
本文版權(quán)歸腿腿教學(xué)網(wǎng)及原創(chuàng)作者所有,未經(jīng)授權(quán),謝絕轉(zhuǎn)載。
上一篇:二次開發(fā)教程:Revit開發(fā)通過API 創(chuàng)建族
下一篇:二次開發(fā)教程:Revit開發(fā)柱附著和分離
推薦專題