## View

Object Hierarchy | Related C++ Class: View

### Inheritance

###

SIObject

UIObject

UIPersistable

View

### Introduced

v4.0

### Description

The View object represents an instance of a view in Softimage. Most windows embedded in the current Layout as well as free floating windows are represented as View objects.
Softimage comes with many types of views built in, including Netview, the Script Editor, the Render Tree, and the Explorer. Toolbars and Shelves are also a type of view (except for Toolbars created with early versions of Softimage). And Relational Views are a type of view that combine other view types together within a single view window.
The Property Page window (see the PPG object) is not a type of View, but it can be embedded inside a view of type "Property Panel", as demonstrated in the example below.
The View object also allows you to manipulate the four Softimage viewports by creating an instance of the View Manager via Layout.Views("vm") and then customizing it using View.SetAttributeValue with the View Manager Attributes.
Views are accessible from the Layout.Views method (or from the View.Views method if the view is a relational view). To instantiate a View object inside a free floating window call Layout.CreateView.
With view objects, you can:
- Change the view state such as closed and minimized state.
- Change the view position and size.
- Hide/unhide the view.
- Access to specific view attributes such as the Explorer scope and NetView URL.
- Edit view attributes in bulk mode to avoid the UI to flicker.
- Iterate over the sub views of a relational view.
Some of these tasks can be performed using methods implemented on the View object (View.Move, View.Resize, View.Visible, etc.); however, many specialized tasks, such as changing the scope and selection in the Explorer or maximizing a single viewport window can only be accomplished via the View.SetAttributeValue and View.GetAttributeValue methods. See View Attributes Reference for a list of attributes available for different views.

### Methods

BeginEdit | EndEdit | FindView | FindView2
GetAttributeValue | IsClassOf | IsEqualTo | Move
Rearrange | Refresh | Resize | SetAttributeValue

### Properties

Application | Categories | Floating | FullName
Help | MemoCameras | Name | NestedObjects
Origin | OriginPath | Parent | Rectangle
State | Type | Views | Visible

### Examples

#### 1. JScript Example

    /*

    	This example restores and cascades all floating views excepted

    	the script editor.

    */

    // Create some sample views

    var layout = Desktop.ActiveLayout;

    layout.CreateView( "Explorer", "My Explorer" );

    layout.CreateView( "Browser", "My Browser" );

    layout.CreateView( "NetView", "My NetView" );

    // Position for the first view to cascade

    px = 50

    py = 20

    // Delta between each view

    dx = 20

    dy = 20

    var views = layout.Views;

    for( var i=0; i<views.Count; i++) {

    	var vw = views(i);

    	if( vw.Floating && vw.Name != "script_editor") {

    		vw.Move( px, py );

    		px += dx;

    		py += dy

    		vw.State = siNormal; // put view at the top so far

    	}

    }

#### 2. Python Example

    # Set up a few basics

    from win32com.client import constants as c

    import os.path

    app = Application

    false = 0

    true = 1

    null = None

    # Convenience function to create a simple synoptic page on disk

    def MakeSynViewPages() :

    	mysynviewpath = XSIUtils.BuildPath(

    		app.InstallationPath(c.siFactoryPath),

    		"Data", "XSI_SAMPLES", "Synoptic"

    	)

    	file1 = XSIUtils.BuildPath(mysynviewpath, "SynViewStartWith.htm")

    	file2 = XSIUtils.BuildPath(mysynviewpath, "SynViewSwitchTo.htm")

    	f = open(file1, 'w')

    	f.write("<html>\n<body version=\"2\">\n<script language=\"VBScript\">\n\n")

    	f.write("sub hotspot(in_obj,in_mousebutton,in_keymodifier)\nset self = GetValue(i")

    	f.write("n_obj)\nApplication.LogMessage \"VB: Touched \" & self.FullName & \" at \" _")

    	f.write("\n\t& self.posx.Value & \",\" & self.posy.Value _\n\t& \",\" & self.posz")

    	f.write(".Value & \" (x,y,z)\"\nend sub\n</SCRIPT>\n\n<map name=\"SynopticMap\">\n")

    	f.write("<area shape=\"circle\" coords=\"260,251,129\" title=\"\" NOHREF onClick=")

    	f.write("\"hotspot\">\n</map>\n\n<img src=\"..\\pictures\\xsilogo.jpg\" usemap=\"#S")

    	f.write("ynopticMap\">\n\n</body>\n</html>")

    	f = open(file2, 'w')

    	f.write("<html>\n<body version=\"2\">\n<script language=\"JavaScript\">\n")

    	f.write("\nfunction hotspot(in_obj,in_mousebutton,in_keymodifier)\n{\nvar self = G")

    	f.write("etValue(in_obj);\nApplication.LogMessage( \"JS: Touched \" + self.FullName + ")

    	f.write("\" at \" \n\t+ self.posx.Value + \",\" + self.posy.Value \n\t+ \",\" + ")

    	f.write("self.posz.Value + \" (x,y,z)\" );\n}\n</SCRIPT>\n\n<map name=\"SynopticMap")

    	f.write("\">\n<area shape=\"circle\" coords=\"260,251,129\" title=\"\" NOHREF onCli")

    	f.write("ck=\"hotspot\">\n</map>\n\n<img src=\"..\\pictures\\xsilogo.jpg\" usemap=")

    	f.write("\"#SynopticMap\">\n\n</body>\n</html>")

    	return [file1, file2]

    # Create a synoptic property and attach it to a torus

    app.NewScene("", false)

    torus = app.CreatePrim("Torus", "MeshSurface")

    app.Rotate(torus, 90, 0, 0, c.siAbsolute, c.siPivot, c.siObj, c.siX)

    app.Translate(torus, 4, 3, 2, c.siAbsolute, c.siPivot, c.siObj, c.siZ)

    synfiles = MakeSynViewPages()

    applied = torus.AddProperty("Synoptic Property")

    applied.Parameters(1).Value = "SynViewAttrib"

    applied.Parameters(2).Value = synfiles[0]

    app.OpenAttachments()

    # Open the Synoptic viewer

    lay = app.Desktop.ActiveLayout

    vw = lay.Views("Synoptic View")

    vw.SetAttributeValue("path", synfiles[1]+","+torus.Name)

#### 3. JScript Example

    /*

    	This example demonstrates how we can host a Custom Property

    	inside a View.

    	This has some advantages over the InspectObj command:

    	-we can specify the exact size and positioning of the window

    	-the view is exposed in the Layout.Views collection so we can

    	find out if the property page is already being "inspected".

    	However it does not support the "Modal" mode supported by

    	InspectObj.

    */

    // Step 1: Create the custom property

    var oPSet = ActiveSceneRoot.AddProperty( "CustomProperty", false, "MyProp" );

    oPSet.AddParameter3( "textparam", siString ) ;

    oPSet.AddFCurveParameter( "MyFCurve" ) ;

    var oLayout = oPSet.PPGLayout ;

    oLayout.Clear() ;

    oLayout.AddItem( "textparam" );

    oLayout.AddItem( "MyFCurve" );

    oLayout.AddRow()

    oLayout.AddButton( "MoveView", "Move View" ) ;

    oLayout.AddButton( "Close" ) ;

    oLayout.EndRow()

    oLayout.Language = "JScript"

    oLayout.Logic = MoveView_OnClicked.toString()

    	+ Close_OnClicked.toString() ;

    // Step 2: Show the custom property in a view

    var oActiveLayout = Application.Desktop.ActiveLayout;

    var oNewView = oActiveLayout.CreateView( "Property Panel", "MyPropView" );

    oNewView.BeginEdit();

    oNewView.Move( 10, 10 );

    oNewView.Resize( 340, 340 );

    oNewView.SetAttributeValue( "targetcontent", oPSet.FullName );

    oNewView.EndEdit();

    // Logic code used by the buttons on the Custom Property

    function MoveView_OnClicked()

    {

    	// We can't get to the view directly from the PPG object,

    	// but we can find it indirectly by searching through

    	// the open views

    	var thisCustomProp = PPG.Inspected.Item(0).FullName

    	var oActiveLayout = Application.Desktop.ActiveLayout

    	for ( var i = 0 ; i < oActiveLayout.Views.Count ; i++ ) {

    		var oView = oActiveLayout.Views(i) ;

    		if ( oView.Type == "Property Panel" ) {

    			if ( oView.GetAttributeValue("targetcontent") == thisCustomProp ) {

    				// found it!

    				oView.Move( 250, 250 ) ;

    				return ;

    			}

    		}

    	}

    }

    function Close_OnClicked()

    {

    	// Self destruction of the custom property

    	DeleteObj( PPG.Inspected.Item(0) ) ;

    	PPG.Close() ;

    }

#### 4. JScript Example

    // Open an Animation Editor and show the FCurves on

    // a custom property

    var oPSet = ActiveSceneRoot.AddProperty("CustomProperty",false,"Demo" ) ;

    var oParam = oPSet.AddParameter3( "Value", siDouble, 0, 0, 100 ) ;

    var oParam2 = oPSet.AddParameter3( "Value", siDouble, 0, 0, 100 ) ;

    oParam.AddFCurve2(

    	new Array( 1, 0,

    		25, 50,

    		50, 25,

    		100, 100

    	)

    ) ;

    oParam2.AddFCurve2(

    	new Array( 1, 100,

    		25, 25,

    		50, 50,

    		100, 100

    	)

    ) ;

    var oLayout = Desktop.ActiveLayout;

    var oView = oLayout.CreateView( "Animation Editor", "MyFCurves" );

    oView.SetAttributeValue( "TargetContent", oPSet.FullName ) ;

### See Also

View Attributes Reference Layout.Views View.Views