Share

Interface: ViewPanelManager

This Core Interface exposes the View Panel Manager to MAXScript.

It provides methods for the creation and manipulation of View Panels containing custom viewport configurations, as well as methods for View Panel Presets management.

This interface also provides methods for managing floating viewports.

Available in 3ds Max 2013 and higher.

Methods:

View Panel Creation

<index>ViewPanelManager.CreateViewPanel <string>tabName <enum>layout <boolean>isActive

layout enums: {
#layout_1 | #layout_2v | #layout_2h | #layout_2ht | #layout_2hb | 
#layout_3vl | #layout_3vr | #layout_3ht | #layout_3hb | 
#layout_4 | #layout_4vl | #layout_4vr | #layout_4ht | #layout_4hb }

Creates a new View Panel with the name specified by the first argument.

The second argument specifies the layout name - see table below.

The third argument controls whether the new View Panel will set as the active one.

Returns the index of the new View Panel.

Layout Name Description
#layout_1 One viewport
#layout_2v Two Viewports, Vertical Split, Equally Sized
#layout_2h Two Viewports, Horizontal Split, Equally Sized
#layout_2ht Two Viewports, Horizontal Split, Top Viewport Smaller
#layout_2hb Two Viewports, Horizontal Split, Bottom Viewport Smaller
#layout_3vl Three Viewports, Vertical Split, Horizontal Split On Left
#layout_3vr Three Viewports, Vertical Split, Horizontal Split On Right
#layout_3ht Three Viewports, Horizontal Split, Vertical Split On Top
#layout_3hb Three Viewports, Horizontal Split, Vertical Split On Bottom
#layout_4vl Four Viewports, Vertical Split, Two Horizontal Splits On Left
#layout_4vr Four Viewports, Vertical Split, Two Horizontal Splits On Right
#layout_4ht Four Viewports, Horizontal Split, Two Vertical Splits On Top
#layout_4hb Four Viewports, Horizontal Split, Two Vertical Splits On Bottom
#layout_4 Four Viewports, Equally Sized
Note: To get or set the layout of an existing View Panel, use viewport.getLayout() and viewport.setLayout().
<integer>ViewPanelManager.GetViewPanelCount()

Returns the number of View Panels, including the three available Floating Viewports, whether they are visible or not. This method will always return at least 4, since there is always at least one static View Panel.

See GetNumViewportsFromAllVisibleViewPanels() below to get a count of all visible viewports.

<boolean>ViewPanelManager.SetActiveViewPanel <index>Index

Sets the active View Panel to the indexed definition.

If you specify a non-visible floating viewport View Panel index, that View Panel will become visible.

Returns True on success, False on failure.

<index>ViewPanelManager.GetActiveViewPanelIndex()

Returns the index of the active View Panel.

<boolean>ViewPanelManager.CanCreateMoreViewPanels()

Returns True if new View Panels can be created, False if the limit has been reached.

<string>ViewPanelManager.GetViewPanelName <index>Index

Returns the name of the indexed View Panel.

<boolean>ViewPanelManager.SetViewPanelName <index>Index <string>newPanelName

Sets the name of the indexed View Panel to the string provided by the second argument.

<value>ViewPanelManager.GetActiveViewPanelDib()

Returns the Device Independent Bitmap (Viewport Snapshot) of the active View Panel.

The image will contain the content of all viewports in the View Panel.

<boolean>ViewPanelManager.IsViewPanelLocked <index>Index

Returns True if the indexed View Panel is locked, False if it is not locked.

<boolean>ViewPanelManager.SetSplitterBarPos <integer>splitterBarID <float>pos

Sets the position of the horizontal or vertical splitter bar to the specified position.

The first argument is in the range from 0 to 2 and depends on the current layout:

Layout Visible Bar Indices Comments
#layout_1 None No splitter bars are used, but 0,1 and 2 are still valid first arguments.
#layout_2v 1 - vertical splitter bar 0 and 2 are valid indices, but the corresponding splitter bars are not used.
#layout_2h

#layout_2ht

#layout_2hb
0 - horizontal splitter bar 1 and 2 are valid indices, but the corresponding splitter bars are not used.
#layout_3vl

#layout_3vr

#layout_3ht

#layout_3hb
0 - horizontal splitter bar1 - vertical splitter bar 2 is a valid index, but the corresponding splitter bar is not used.
#layout_4 0 - horizontal splitter bar1 - vertical splitter bar 2 is a valid index, but the corresponding splitter bar is not used.
#layout_4vl

#layout_4vr
0 - vertical splitter bar1 - top horizontal splitter bar2 - bottom horizontal splitter bar
#layout_4ht

#layout_4hb
0 - horizontal splitter bar1 - left vertical splitter bar2 - right vertical splitter bar

The second argument must be a float in the range from 0.0 to 1.0, with 0.5 being centered in the middle of the panel.

Returns True on success, False if the second argument is out of range. Note that attempting to set a non-visible splitter bar index still returns True.

<boolean>ViewPanelManager.SetExtendedView <integer>viewIndex <enum>extendedViewType

extendedViewType enums: {#ev_type_tree|#ev_type_schematic|#ev_type_sceneexplore}

Sets the indexed extended view to the extended view type specified by the second argument's enum value.

Note: Not all extended view types exposed in the UI are currently supported in MAXScript.

Possible values are:

Enum As Integer Result
#ev_type_tree 0 Set Extended Viewport to TrackView
#ev_type_schematic 1 Set Extended Viewport to Schematic View
#ev_type_sceneexplore 2 Set Extended Viewport to Scene Explorer
<boolean>ViewPanelManager.DestroyViewPanel <index>Index

Destroys the indexed View Panel.

Returns True on success, False on failure.

EXAMPLE

theActive = ViewPanelManager.GetActiveViewPanelIndex()
--> 1
canCreate = ViewPanelManager.CanCreateMoreViewPanels()
--> true 
if canCreate do theNew = ViewPanelManager.CreateViewPanel "Two Horizontal Large Top" #layout_2h false
--> 2
ViewPanelManager.SetSplitterBarPos 0 0.65
--> true
theCount = ViewPanelManager.GetViewPanelCount()
--> 2
for i = 1 to 2 do
(
    theName = ViewPanelManager.GetViewPanelName i
    isLocked = ViewPanelManager.IsViewPanelLocked i
    format "% Name:'%' Locked:% " i theName isLocked
    if i == theActive then format "(active)\n" else format "\n"
)    
--> 1 Name:'Quad 4' Locked:true (active)
--> 2 Name:'Two Horizontal Large Top' Locked:false 
--> OK
theBitmap = ViewPanelManager.GetActiveViewPanelDib()
--> BitMap:
display theBitmap
--> OK
ViewPanelManager.DestroyViewPanel theNew
--> true

View Panel Preset Management

<integer>ViewPanelManager.GetPresetCount()

Returns the number of available named View Panel presets.

<string>ViewPanelManager.GetPresetName <index>presetIndex

Returns the name of the indexed View Panel Preset.

<index>ViewPanelManager.GetPresetID <string>presetName

Returns the ID of the named View Panel Preset.

<boolean>ViewPanelManager.DoesViewPanelPresetExist <string>presetName

Returns True if a View Panel Preset with the name specified by the argument exists.

Returns False if the View Panel Preset with the specified name does not exist.

<integer>ViewPanelManager.GetViewPanelPresetLayout <integer>presetIndex

Returns the layout of the indexed View Panel Preset as an integer, or -1 if the specified presetIndex does not exist..

<index>ViewPanelManager.CreateViewPanelFromPreset <string>presetName <boolean>isActive

Creates a new View Panel from the specified named preset.

If the second argument is set to True, the View Panel will also be made active.

Returns the index of the new View Panel.

<boolean>ViewPanelManager.CreatePresetFromActiveViewPanel <string>presetName

Creates a new Preset with the specified name from the active View Panel.

If the name already exists, it will be appended a numeric suffix, e.g. "Test" will become "Test 01".

Returns True on success, False on failure.

<boolean>ViewPanelManager.CreatePresetFromViewPanel <index>panelIndex <string>presetName

Creates a new Preset from the indexed View Panel specified by the first argument.

The Preset will be named according to the second argument.

Returns True on success, False on failure.

<boolean>ViewPanelManager.RenameViewPanelPreset <string>presetName <string>newName

Renames the View Panel Preset specified by the first argument to the name given by the second argument.

Returns True if the renaming succeeded.

Returns False if a Preset with the name specified by the first argument does not exist.

<boolean>ViewPanelManager.DeletePreset <string>presetName

Deletes the named View Panel Preset.

Returns True on success.

Returns False if the named Preset does not exist.

<boolean>ViewPanelManager.DeleteAllViewPanelPresets()

Deletes all View Panel Presets.

Returns True on success, False on failure.

EXAMPLE

theNewPresetName = "Just A Test"
--> "Just A Test"
if not ViewPanelManager.DoesViewPanelPresetExist theNewPresetName do 
  ViewPanelManager.CreatePresetFromActiveViewPanel theNewPresetName
--> true
ViewPanelManager.RenameViewPanelPreset theNewPresetName "A Test Indeed"
--> true
theCount = ViewPanelManager.GetPresetCount()
--> 1
for i = 1 to theCount do
(
  theName = ViewPanelManager.GetPresetName i
  theLayout = ViewPanelManager.GetViewPanelPresetLayout i
  format "% Name:'%' Layout:'%' \n" i theName theLayout
)
--> 1 Name:'A Test Indeed' Layout:'-1' 
--> OK
ViewPanelManager.DeletePreset theNewPresetName
--> false
ViewPanelManager.DeletePreset "A Test Indeed"
--> true

Floating Viewport Management

These functions expose floating viewport functionality. Available in 3ds Max 2020.1 Update and higher.

Note that floating viewports are actually independent View Panels, that by default have a four viewport layout with the perspective view maximized (though this can be changed in the Viewport Configuration dialog). They are always present, and so will show up in the value returned by getViewPanelCount(), but not always visible.

Note: All indices passed as parameters or returned by methods are 0-based.
<boolean>IsViewPanelVisible <index>Index    

Returns whether the view panel specified by index is visible.

<boolean>IsViewPanelFloating <index>Index

Returns whether the view panel specified by index is a floating viewport.

<enum>GetViewPanelFloatingID <index>Index
GetViewPanelFloatingID enums: {#Not_Floating|#Floating_ViewPanel_1|#Floating_ViewPanel_2|#Floating_ViewPanel_3}

Returns the ID of the view panel specified by index, or #Not_Floating if it is not a floating view panel.

<index>GetViewPanelIndexFromFloatingID <enum>ViewPanelfloatingID 
ViewPanelfloatingID enums: {#Not_Floating|#Floating_ViewPanel_1|#Floating_ViewPanel_2|#Floating_ViewPanel_3}

Returns the view panel index of the view panel specified by ID, or -1 for #Not_Floating.

<integer>GetNumFloatingViewPanels()

Returns the number of possible floating View Panels. Note that this is not the same as the number of visible View Panels. Currently this method always returns 3.

<void>HideAllFloatingViewPanels()

Makes all visible floating view panels not visible.

<void>SetFloatingViewPanelVisibility <enum>ViewPanelfloatingID <boolean>bVisible
ViewPanelfloatingID enums: {#Not_Floating|#Floating_ViewPanel_1|#Floating_ViewPanel_2|#Floating_ViewPanel_3}

Sets the visibility of the view panel specified by ID.

<integer>GetNumViewportsFromAllVisibleViewPanels()

Returns the number of all visible viewports, including those on floating viewports. To get a count of all view panels (including visible and non-visible floating view panels), use GetViewPanelCount().

<integer>GetNumVisibleViewPanels()

Returns the number of all visible View Panels.

EXAMPLE

-- Floating View Panels example
-- hide any visible floating viewports first
ViewPanelManager.HideAllFloatingViewPanels()

-- This will be 3, whether they are visible or not:
ViewPanelManager.GetNumFloatingViewPanels()

-- How many view panels and viewports are visible?
vis_panels = ViewPanelManager.GetNumVisibleViewPanels()
vis_ports = ViewPanelManager.GetNumViewportsFromAllVisibleViewPanels()
format "% visible viewports on % visible view panels\n" vis_ports vis_panels

count = ViewPanelManager.GetViewPanelCount()
format "% View Panels (visible and/or floating)" count

for i = 1 to count do (
    vp_name = ViewPanelManager.GetViewPanelName i
    vp_visible = ViewPanelManager.IsViewPanelVisible i
    vp_floating = ViewPanelManager.IsViewPanelFloating i
    format "View Panel % name:%\n visible:%\n floating:%\n" i vp_name vp_visible vp_floating
    -- let's make all the floating ones visible
    if vp_floating do ViewPanelManager.SetActiveViewPanel i        
    )
    
-- The id of the first floating viewpanel
vp_id = #Floating_ViewPanel_1
    
-- hide it
format "Hiding %\n" vp_id
ViewPanelManager.SetFloatingViewPanelVisibility vp_id false
    
-- change the layout of Floating Viewport 3    
indexOfFloatingVP3 = ViewPanelManager.GetViewPanelIndexFromFloatingID #Floating_ViewPanel_3
ViewPanelManager.SetActiveViewPanel indexOfFloatingVP3
viewport.setLayout #layout_3vl

Was this information helpful?