StephenBlair
02-03-2008, 11:55 AM
I moved the lessons over to my XSI Support blog (http://community.softimage.com/blog.php?u=125), now that the Tutorials forum is a forest of links.
Lesson 1 (http://community.softimage.com/blog.php?b=21)
Lesson 2 (http://community.softimage.com/blog.php?b=22), and answers to the Lesson 1 Hands-On Challenge
Introduction
Scripting in XSI is easy. Really easy. You don’t need a Ph.D. in Computer Science. You don’t need to know C or C++ or any programming language. You don’t need to know anything about object models. You don’t even have to know how to program your VCR.
But don’t take my word for it. Let me show you how easy it is. Take a look at these four lines of XSI object model code:
set Layout = Application.Desktop.ActiveLayout
set WikiView = Layout.CreateView( "NetView", "Softimage Wiki" )
WikiView.SetAttributeValue "url", "http://softimage.wiki.avid.com"
WikiView.Resize 960, 640Can you figure out what this code does in XSI?
Scripting uses language that for the most part is already familiar to you (if you are familiar with XSI). For instance, ActiveLayout is the current layout, and CreateView opens a new view, in this case a NetView (just like the View > General > NetView menu command).
In these four lines of code, we open a NetView window, point it to the URL of the external wiki, and then resize the NetView window.
Lesson 1: Hello World
The traditional starting point for programming tutorials is the “Hello, world” program. So here’s a "Hello, world" script:
LogMessage "Hello World" ' VBScript
LogMessage ( "Hello World" ); // JScript
Application.LogMessage ( "Hello World" ) # Python
Pretty simple, eh? To run this script, all you have to do is type this one line into the Script Editor and click Run. The message "Hello, world" is logged in the History window of the Script Editor, and on the XSI status bar.
http://softimage.wiki.avid.com/images/c/c8/HelloWorld-1.png
LogMessage can be very useful when you’re trying to figure out what’s going on in a script. By logging information, you can track changes in values and get a better idea of how a script works. However, logging messages slows down scripts.
The Script Editor is your main work area for scripting:
The window title bar displays the name of the file you are editing, and the current scripting language.
The Script Editor has a History pane (which displays the output of LogMessage and logs a history of everything a user does in XSI) and an Editing pane (where you edit scripts).
XSI supports four scripting languages: VBScript, JScript, Python, and PerlScript. To change the current scripting language, right-click in the Editing pane and then click one of the Set to <scripting language=""> commands.</scripting><scripting language=""> PerlScript is supported, but few people use it. And our Wizards (which generate scripting code for commands, menus, properties, filters, and operators) do not generate PerlScript code. </scripting>
<scripting language=""></scripting><scripting language="">
Hands-on Challenge #1
</scripting>
<scripting language=""> Use LogMessage to display a message in a Message Box. </scripting>
<scripting language=""> Figure out how to display Verbose messages.</scripting><scripting language="">
</scripting>
Lesson 1 (http://community.softimage.com/blog.php?b=21)
Lesson 2 (http://community.softimage.com/blog.php?b=22), and answers to the Lesson 1 Hands-On Challenge
Introduction
Scripting in XSI is easy. Really easy. You don’t need a Ph.D. in Computer Science. You don’t need to know C or C++ or any programming language. You don’t need to know anything about object models. You don’t even have to know how to program your VCR.
But don’t take my word for it. Let me show you how easy it is. Take a look at these four lines of XSI object model code:
set Layout = Application.Desktop.ActiveLayout
set WikiView = Layout.CreateView( "NetView", "Softimage Wiki" )
WikiView.SetAttributeValue "url", "http://softimage.wiki.avid.com"
WikiView.Resize 960, 640Can you figure out what this code does in XSI?
Scripting uses language that for the most part is already familiar to you (if you are familiar with XSI). For instance, ActiveLayout is the current layout, and CreateView opens a new view, in this case a NetView (just like the View > General > NetView menu command).
In these four lines of code, we open a NetView window, point it to the URL of the external wiki, and then resize the NetView window.
Lesson 1: Hello World
The traditional starting point for programming tutorials is the “Hello, world” program. So here’s a "Hello, world" script:
LogMessage "Hello World" ' VBScript
LogMessage ( "Hello World" ); // JScript
Application.LogMessage ( "Hello World" ) # Python
Pretty simple, eh? To run this script, all you have to do is type this one line into the Script Editor and click Run. The message "Hello, world" is logged in the History window of the Script Editor, and on the XSI status bar.
http://softimage.wiki.avid.com/images/c/c8/HelloWorld-1.png
LogMessage can be very useful when you’re trying to figure out what’s going on in a script. By logging information, you can track changes in values and get a better idea of how a script works. However, logging messages slows down scripts.
The Script Editor is your main work area for scripting:
The window title bar displays the name of the file you are editing, and the current scripting language.
The Script Editor has a History pane (which displays the output of LogMessage and logs a history of everything a user does in XSI) and an Editing pane (where you edit scripts).
XSI supports four scripting languages: VBScript, JScript, Python, and PerlScript. To change the current scripting language, right-click in the Editing pane and then click one of the Set to <scripting language=""> commands.</scripting><scripting language=""> PerlScript is supported, but few people use it. And our Wizards (which generate scripting code for commands, menus, properties, filters, and operators) do not generate PerlScript code. </scripting>
<scripting language=""></scripting><scripting language="">
Hands-on Challenge #1
</scripting>
<scripting language=""> Use LogMessage to display a message in a Message Box. </scripting>
<scripting language=""> Figure out how to display Verbose messages.</scripting><scripting language="">
</scripting>