You can create Netview pages that not only set data in Softimage, but also get data from Softimage and display dynamic info. For example, you can write a suite of scripts for custom tools, and build the user interface with dynamic HTML, forms, and buttons in a Web page. There's no end to the possibilities, but this section should help you get started.
Before you can run scripts from Netview, you must set the appropriate security level to Low for the domains on which the scripts reside. Low security allows all scripts and ActiveX content to run; to interact with Softimage, scripts must instantiate the XSI.Application ActiveX object.
To set Internet security levels on Windows
On Windows, you can set the security level for a specific domain in either of two ways:
The exact procedure depends on the versions of Windows and Internet Explorer that you are using, so consult Internet Explorer's online help for details.
To set Internet security levels on Linux
On Linux, you can set the security level for a specific domain using the Mainwin Control Panel:
Source the Softimage environment script by typing:
source ~/.xsi_2013Launch the MainWin Control Panel by typing:
mwcontrolDouble-click on the Internet Options icon. The Internet Properties dialog box opens.
On the Security tab, select Trusted sites and then click the Sites button. The Trusted sites dialog box opens.
Running Embedded Scripts Automatically
Scripts that are embedded in the body of an HTML page are parsed and run automatically when the page is loaded into Netview. Global code (that is, code that is not within any procedure) is executed, together with functions or subroutines that are called from the global code.
<body> <!-- HTML elements go here --> ... <script language="vbscript"> 'Global code 'This gets executed automatically ... sub mySub() 'This procedure is executed only when it is called ... end sub </script> <!-- More HTML elements go here --> ... </body>
Running Embedded Script Code from Buttons and Hotspots
You can run script code when your users click a button or hotspot on the HTML page. To do this, write a procedure and then call the procedure from the onclick event of the button or hotspot.
For example, to create an HTML button that runs mySub using VBScript:
<script language="vbscript"> ... sub mySub() 'Code goes here end sub ... </script> ... <input id=bClickMe type=button value="Click Me" name=button1 language=vbscript onclick="mySub()">
Your Netview script must link to Softimage before it can get and set data. This is because a script in Netview is actually running inside Internet Explorer, and therefore needs to get a pointer to Softimage before it can communicate. To get the pointer, your script must instantiate the XSI.Application object.
On Error Resume Next Set myXSI = CreateObject("XSI.Application") Set myApp = myXSI.Application if err.number <> 0 then document.write "Open this page in Softimage's Netview." end if
Once you have a pointer to XSI.Application, you can prepend it to the name of any object, method, or property in the Softimage object model. For example, to get the current selection in Softimage using VBScript:
Set mySel = myApp.Selection
Running Softimage Script Commands
Getting a pointer to the XSI.Application object, as described in the previous section Communicating with Softimage, allows you to use Softimage objects, methods, and properties in your Netview scripts. But what if you need to use a Softimage script command for which there is no equivalent in the object model? Luckily, there are a few ways to accomplish this.
Running script commands via COM automation
Once you have a pointer to XSI.Application, you can use it to run any Softimage script command via COM automation. For example:
'Get a pointer to XSI.Application Set myXSI = CreateObject("XSI.Application") Set myApp = myXSI.Application 'Get the selection Set mySel = myApp.Selection 'Run a command, e.g. InspectObj myApp.InspectObj(mySel(0))
Running script commands with ExecuteScriptCommand
The ExecuteScriptCommand method of the XSIApplication object lets you run Softimage scripting commands, including custom commands. Although this method is primarily intended to run commands from COM C++, you can also use it in Netview. You must package the arguments in an array beforehand. For more information see ExecuteScriptCommand [SDK Guide].
You can display information from Softimage dynamically in a Netview page.
Create a <div> element in the body of the HTML to hold the data that you will write, and give it a unique ID. For example:
<div id="myDiv"> </div>If desired, you can put default text or other HTML elements between the opening and closing div tags.
Write a routine that builds a string of text in HTML format and assigns it to the innerHTML property of the <div>.
Sub writeSel() Set mySel= myApp.Selection if mySel.Count <> 0 then myStr = "" for each thing in mySel myStr = myStr & "<p>My name is <b>" & thing.Name & "</b>.</p>" next else myStr= "<p>Select an object first.</p>" end if myDiv.innerHTML= myStr End Sub
Call the routine in some way. For example, to make a button that calls a VBScript subroutine:
<input id=bWhoAmI type=button value="Who am I?" name=button1 language=vbscript onclick="writeSel()" >