Manage Views with Model View Manager

You can programmatically control the Model View capability using the ModelViewManager data object which can be accessed via the Graphics Object as shown below.

view_manager = Graphics.ModelViewManager

To get the number of graphical views that are currently defined:

views_count = view_manager.NumberOfViews

You can create a graphical view from current graphics using either a default name or a specified name. To create a view using a default name:

view_manager.CreateView

The name assigned to the new view is View followed by the next sequential number. To create a view using a specified name, where viewName is the name to assign to the new view:

view_manager.CreateView(string viewName)

You can apply a graphical view by specifying its name or index. To apply a view by specifying its name, where viewLabel is the name of the view to apply:

view_manager.ApplyModelView(string viewLabel)

For example, to apply a view named Fit View:

view_manager.ApplyModelView("Fit View")

To apply a view by specifying its index, where viewIndex is the index of the listed view to apply:

view_manager.ApplyModelView(int viewIndex)

For example, to apply a view with index 1:

view_manager.ApplyModelView(1)

Additionally there are API’s to cover the other features of Model View Manager such as:

Deleting a view:

DeleteView(“Fit View”)

Renaming a view:

RenameView(“Fit View”, “New Name”)

Exporting a saved view list:

ExportModelViews("D:\My_Projects\Views\myviews.xml")

Importing a saved view list:

ImportModelViews("D:\My_Projects\Views\allviews.xml")