程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> Revit讀取當前rvt的所有視圖與其名稱,revit讀取當前rvt

Revit讀取當前rvt的所有視圖與其名稱,revit讀取當前rvt

編輯:C#入門知識

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

        

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved