I am trying to activate a view using Revit API. What I want to do exactly is to display the level or floor plan view. So the view I want to activate ( I mean, I want this view to be actually shown on screen) already exists, and I can access its Id.
I have seen threads about creating, browsing, filtering views, but nothing on activating it... It's a Floor Plan view. (What I want is that by selecting a level/ floor plan, it displays that level/ floor plan on-screen(it's like opening that floor plan from the already existing Revit model to display on the user screen).
Here is an example how to switch to the default 3d-view https://thebuildingcoder.typepad.com/blog/2011/09/activate-a-3d-view.html
you can do the same with all other available views like this
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
uidoc.ActiveView = yourview;
Super easy to do:
# normally you have the ui set at the start of your script
ui = __revit__.ActiveUIDocument
# then just set the ActiveView as your view (not the ViewId)
ui.ActiveView = yourView
FilteredElementCollector viewCollector = new FilteredElementCollector(doc);
viewCollector.OfClass(typeof(View));
foreach (Element viewElement in viewCollector)
{
yourview = (View)viewElement;
break;
}
}
uidoc.ActiveView = yourview;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.