PDA

View Full Version : Super-Easy Guide to Scripting


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>

StephenBlair
02-03-2008, 12:25 PM
I'll post the answers, eventually.

For now, here's a tip: script editor, selected text, F1

Malcolm Zaloon
02-19-2008, 12:44 PM
Ok, simple things are simple. Sure...

I´m a xsi scripting guy too, but i´m intermediate scripter.
i´m currently figuring how to create UI for my scripts, in JavaScript. Can you explain how to create, sliders, combo boxes, drop downs, lists, markers, buttons, fcurve views, etc?

Thanks in advance.

PS: Please, i´m want make UI for scripting without using "Custom Parameters"

kim aldis
02-19-2008, 02:38 PM
check out the SDK Wizards in the plugin manager. open up a workgroup and right click over the plugins folder, see the context menu that pops up. You're probably looking to create a property but you can create operators too. The wizard creates all the code you need to get started, dumps it in the plugin folder and opens it in a text editor for you.
There are some examples in the docs and the XSI install but you should find the code generated for you tells a good story.

http://www.kim-aldis.co.uk/externalthumbs/PluginMngr.gif

Squid
02-19-2008, 03:04 PM
To add my ha'penny's worth, a thorough dig through the \\Softimage\XSI_6.5\Application\DSScripts directory is a must for anyone remotely interested in scripting.

lot's of little nuggets to be found there.

StephenBlair
02-20-2008, 10:41 AM
The SDK wizards are themselves examples of how to build a UI through scripting.

The wizard UI code is here: C:\Softimage\XSI_6.5\Addons\sdkui\Application\Plug ins.

The SDK example workgroup contains many UI examples.

Sunces
02-20-2008, 11:07 AM
Thanks guys this info is great for ppl like myself who are trying to dive into scripting in xsi.

StephenBlair
02-28-2008, 04:01 PM
Some info on UI building on my blog (http://community.softimage.com/blog.php?b=15). As time permits I will expand on this :-)

StephenBlair
03-10-2008, 10:59 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