首页 > 代码库 > Revit读取当前rvt的所有视图与其名称
Revit读取当前rvt的所有视图与其名称
1)读取所有视图:
public static ViewSet GetAllViews(Document doc) { ViewSet views = new ViewSet(); FilteredElementCollector collector = new FilteredElementCollector(doc); FilteredElementIterator it = collector.OfClass(typeof(View)).GetElementIterator(); it.Reset(); while (it.MoveNext()) { View view = it.Current as View3D; if (null != view && !view.IsTemplate && view.CanBePrinted) { views.Insert(view); } else if (null == view) { View view2D = it.Current as View; if (view2D.ViewType == ViewType.FloorPlan | view2D.ViewType == ViewType.CeilingPlan | view2D.ViewType == ViewType.AreaPlan | view2D.ViewType == ViewType.Elevation | view2D.ViewType == ViewType.Section) { views.Insert(view2D); } } } return views; }
2)读取视图的名称:
public static string GetViewDisplayName(View view) { String name = view.ViewName; //special treament to sheet name if (view.ViewType == ViewType.DrawingSheet) { ViewSheet sheet = view as ViewSheet; name = String.Format("{0} - {1}", sheet.SheetNumber, name); } if(view.ViewType == ViewType.ThreeD) { if (name.Contains("{")&&name.Contains("}")) { int bracketStart = name.IndexOf("{"); int bracketEnd = name.IndexOf("}"); name = name.Substring(bracketStart + 1, bracketEnd - bracketStart - 1); } } else if(view.ViewType == ViewType.FloorPlan) { name = string.Format("楼层平面:{0}", name); } else if (view.ViewType == ViewType.CeilingPlan) { name = string.Format("天花板平面:{0}", name); } else if (view.ViewType == ViewType.AreaPlan) { name = string.Format("面积平面:{0}", name); } else if (view.ViewType == ViewType.Elevation) { name = string.Format("建筑立面:{0}", name); } else if (view.ViewType == ViewType.Section) { name = string.Format("建筑剖面:{0}", name); } return name; }
Revit读取当前rvt的所有视图与其名称
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。