Revit读取当前rvt的所有视图与其名称_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > Revit读取当前rvt的所有视图与其名称

Revit读取当前rvt的所有视图与其名称

 2016/8/30 5:31:55  airforce094  程序员俱乐部  我要评论(0)
  • 摘要:1)读取所有视图:publicstaticViewSetGetAllViews(Documentdoc){ViewSetviews=newViewSet();FilteredElementCollectorcollector=newFilteredElementCollector(doc);FilteredElementIteratorit=collector.OfClass(typeof(View)).GetElementIterator();it.Reset();while(it
  • 标签:

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;
        }

        

 

  • 相关文章
发表评论
用户名: 匿名