Revit二次开发|区域标高不一致缩略图的实现

来源:建筑界编辑:黄子俊发布时间:2020-03-22 19:39:30

[摘要] 使用Revit出图时,往往会遇到项目地库标高不一致,在标注机电管线时,需要按照地库地面标高去标注,但地库地面标高又无法统一,需要手动取

使用Revit出图时,往往会遇到项目地库标高不一致,在标注机电管线时,需要按照地库地面标高去标注,但地库地面标高又无法统一,需要手动取框选区域形成标高缩略图注明标高。

本文简单分享一下利用土建模型中的楼板实现缩略图的快速方法;

1、读取地库建筑面层的所有轮廓,筛选出建筑面层的范围线,利用范围线生成详图线;

2、新建常规注释类别的标高标记族,将建筑面层的标高赋值给常规注释族;

以下是所有代码:

 public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiApp = commandData.Application; UIDocument uiDoc = uiApp.ActiveUIDocument; Document doc = uiDoc.Document; Selection sel = uiDoc.Selection; try { Transaction trans = new Transaction(doc); trans.Start("绘制详图线"); FilteredElementCollector col = new FilteredElementCollector(uiDoc.Document); col.OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_GenericAnnotation); FamilySymbol familySymbol = col.FirstElement() as FamilySymbol; FilteredElementCollector collector = new FilteredElementCollector(doc); ICollection<Element> floorcol = collector.OfClass(typeof(Floor)).ToElements(); foreach (Element elem in floorcol) { Floor floor = elem as Floor; if (floor.Name.Contains("楼板")) { Level level = doc.GetElement(floor.LevelId) as Level; if (level.Name.Contains("B1") && level.Name.Contains("ST")) { //获得楼板的相对标高; double offset = floor.LookupParameter("自标高的高度偏移").AsDouble(); double levelHeigh = (level.Elevation + offset) * 304.8/1000; string levelParam = levelHeigh.ToString("0.000"); XYZ point = (floor.get_BoundingBox(doc.ActiveView).Max+floor.get_BoundingBox(doc.ActiveView).Min)/2; FamilyInstance instance = doc.Create.NewFamilyInstance(point, familySymbol, doc.ActiveView); Parameter parm = instance.LookupParameter("标高1"); parm.Set(levelParam); GeometryElement geometry = floor.get_Geometry(new Options()); foreach (GeometryObject geomObj in geometry)//获取到几何元素的边和面 { Solid geomSolid = geomObj as Solid; if (null != geomSolid) { foreach (Face geoFace in geomSolid.Faces) { if (geoFace is PlanarFace) { PlanarFace plFace = geoFace as PlanarFace; //得到楼板面 if (plFace.FaceNormal.Z == 1) { EdgeArray array = plFace.EdgeLoops.get_Item(0); foreach (Edge ed in array) { Curve curve = ed.AsCurve(); doc.Create.NewDetailCurve(doc.ActiveView, curve); } } } } } } } } } trans.Commit(); } catch (Autodesk.Revit.Exceptions.OperationCanceledException e) { return Result.Cancelled; } catch (Exception ex) { TaskDialog.Show("Revit",ex.Source+"n"+ex.Message+"n"); return Result.Failed; } return Result.Succeeded; }

 

实际效果如下:

Revit二次开发|区域标高不一致缩略图的实现

Revit二次开发|区域标高不一致缩略图的实现

 

以上就是生成缩略图的简单方法,本方法对楼板的建模要求很高,如果土建模型楼板不完整或者重叠,需要手动取修改缩略图。

 

标高,缩略图,区域

延展阅读

相关文章


热门资讯推荐