其他分享
首页 > 其他分享> > 二次开发视图名切换到对应视图

二次开发视图名切换到对应视图

作者:互联网


public static void ActiveViewByName(UIApplication app, string viewname)
        {
            Document doc = app.ActiveUIDocument.Document;
            UIDocument uidoc = app.ActiveUIDocument;
 
            FilteredElementCollector collector
              = new FilteredElementCollector(doc)
                .OfClass(typeof(View));
 
            foreach (View v in collector)
            {
                Debug.Assert(null != v,
                  "never expected a null view to be returned"
                  + " from filtered element collector");
 
                // Skip view template here because view 
                // templates are invisible in project 
                // browser
 
                if (v.Name == viewname && !v.IsTemplate)
                {
                    uidoc.ActiveView = v;
                }
            }
        }

标签:ActiveUIDocument,app,视图,切换,二次开发,Document,collector,view
来源: https://blog.csdn.net/waiting233/article/details/117922495