Becoming a Script Master

November 24th, 2005 by Andrew Skowronski - Viewed 19957 times -




The Path to Becoming a Scripting Master

Many XSI users recognize the potential to speed up their daily work by taping into XSI’s scripting and customization capabilities. Scripting skills can help optimize your own work, and open up the path to becoming a TD or programmer. Some XSI users have fine-tuned their scripting skills to such a high level that they could be considered a “scripting master”. These developers write tools that impress not just members of a single organization but the entire XSI community, and they have the potential to be high paid consultants or write commercial add-ons for XSI.

For users who do not come from a programming background some of the technical challenges to becoming a scripting master can be daunting.

This article gives some tips to give an idea how someone with no programming knowledge can work towards becoming a scripting master.

The Novice Scripter

Any XSI user who has no prior experience with programmer and who does not take specific training in XSI scripting will spend some time as a “novice” script writer.

The novice can tap into XSI’s scripting capabilities by creating “Macro” style scripts. Actions are performed through the XSI user interface, and the resulting log of commands is copied and pasted from script history window to the script editor. The resulting script will reproduce the same actions. It is possible to store the script inside a toolbar so that a single click on a toolbar button will produce the same effect as 10 or 100 clicks inside various menus and property pages.

Here are some tips for users who are just reaching this level of scripting experience:

These basic scripts are just a sequential list of XSI commands. For example SetValue, GetPrim and Translate. Each command takes arguments, which tell XSI what to do when performing the command. The behavior of each command is influenced by its arguments, but also by the state of XSI – in particular what objects are selected, what scene is loaded and so on.

For example:

1
GetPrim( "Null" )

Will create a primitive, with the type specified as an argument to the command, and with the parent determined by the current selection.

To take the full advantage of this technique it is important to make an effort to understand what each command is doing and look at the arguments and understand what impact the XSI Selection has on the command. For example you may want your script to modify the currently selected object, so you have to make sure your script doesn’t have calls to SelectObj that would change the selection to a different object. Each command is documented so you can use the F1 key in the script history to get information about each command. Start by examining the documentation of simple commands like SelectObj before moving to the more complicated commands like ApplyOp. Note: it is not necessary to understand every single argument, some arguments are designed for advanced usage and do not need to be specified for normal scenarios.

The script writer may also start running scripts written by other users, including those found in the XSI Command or Object Model reference. The novice may even attempt to adapt these examples to work in a different way than originally intended, but will often become frustrated because of the lack of understanding needed to do this successfully. These techniques can be very useful and by gaining some experience with this technique an XSI user will be a “novice” scripter. However this style of script has some limitations. For example, XSI does not log all actions. And such scripts can change the scene but they can never read any information from it. To move further it is necessary to start learning some further scripting techniques.

The Casual Scripter

The majority of users who use scripting at all will eventually evolve past the novice stage into the large space of casual scripting. This is the place of someone who does not consider themselves a real programmer, but who is intelligent and persevering enough to hack together interesting scripts, often without full understanding of all the concepts.

The novice scripter builds scripts that contain only a sequence of calls to XSI commands. The casual scriptwriter moves beyond this by starting to use scripting language constructs like loops, functions and variables. They gain some understanding of the script language they are dealing with, by looking at example code, by getting help from colleagues and through a lot of trial and error. They rarely study the language in a formal or systematic fashion.

They also start using the XSI Object Model as a more powerful way to read scene information. Their scripts are more flexible to be useful in different scenes because they use less hard coded object names and are less dependent on the current selection. A casual scripter may also learn to build simple user interfaces, through custom property sets, message boxes or netview. They use the XSI wizards or examples to get the initial code rather than starting from scratch.

A casual scripter may also write batch scripts to solve pipeline issues such as import and export of data.

A casual scripter is much more productive than the novice script writer, and can produce tools that are used by many users in the organization. However such a script writer does not consider himself or herself as a “real programmer”. And such a script writer often feels helpless or frustrated when they get into an area without existing SDK examples or when they can’t find a bug in their script code.

The Competent Scripter

Over time a casual scripter can evolve into being a competent scripter, someone who gets a good job done and may have scripting as part of their official responsibilities. I don’t think there are any special tips to give for the transition from Casual to Competent, it may largely be a matter of experience and attitude. But moving beyond competent to mastery is a very interesting challenge.

The Master

A casual scripter will eventually evolve into being a “Competent Scripter”.

There is no single attribute or knowledge that would make an XSI script writer a “Master”. No single developer knows all the details of the SDK or all the tricks of scripting. However a script writer who is has become very competent at several areas of the XSI SDK can be considered more than a casual scripter, perhaps even as a master of scripting. To gain such competency requires concentration, focus and learning. It is impossible to focus and concentrate on the entire SDK all at once so the potential master must pick certain areas to concentrate on, only a few at a time, so that they can get deep enough to really master the concept. Otherwise the user could fall into the state of “jack of all trades, master of none”.

It can be very difficult to concentrate on learning in the constant pressure of a deadline driven production. Yet if all the script writing is done in a wild scramble without time to improve the learning process will stagnate.

Part of the mastery of the SDK can come through sheer time and experience. The more script writing that is performed the faster the process becomes, with fewer errors and fast debugging of any errors that creep in. And, at the same time, the budding master can build a “library” of scripting building blocks so that bits of earlier projects can be used to solve today’s projects.

But beyond the general concepts of concentration and experience, here are some specific areas to consider focusing on. It is unreasonable to be able to do all of these at once, but over the course of a few years it is feasible to make good progress on many of these points.

  • Spend time to master the scripting language itself. Few people dedicate the few hours that are necessary to read a book specifically about vbscript, jscript or python. Having a good explanation of global and local variables, data types, functions, string manipulation, error handling and all the looping constructs will make it much easier to understand and write source code. And the ability to create classes and other object-oriented approaches can be very useful when dealing with very large projects. It is not necessary to memorize every obscure class or syntax, as long as you are confident you could look those up quickly if you need them.
  • Read the necessary parts of the XSI SDK docs. An example is Custom Properties. Many casual script writers play around with the Custom Property Wizard but few really understand the full range of controls and layout possibilities that are available, because they are not exposed in the Wizard User Interface. These are almost entirely documented.
  • Master Self-installed custom commands. The real building block for a library of scripts is the self-installed custom command. A casual scripter probably has some initial experience with this concept, but a master will use it to its full potential by understanding Argument Handlers, how to return script-based objects and how to design a useful and clear API.
  • Understand the file system organization of workgroups and add-ons so that you can take full advantage of these concepts to organize your tools and smoothly distribute them to other users.
  • Master some plug-in types. Apart from having an overview understanding of the purpose of each type of plug-in, it is only necessary to master the ones that are relevant used most frequently. For example a script writer responsible for exposing tools in the user interface should know all about menus, custom properties, netview and filters. Other script writers would need to master custom operators so that they can build sophisticated rigs.
  • Master the Object Model and Command API. The Object Model is too large to completely memorize, but certain core objects (SIObject, Parameter, ProjectItem, SceneItem, Property, X3DObject etc) should be very familiar to a master script writer. Beyond that the master needs to know the objects related to their area of expertise, but also have good skills to look things up quickly in the SDK reference.
  • Learn other languages. The master should be able to read any vbscript, jscript or python code, even if only one language is used for his or her coding. This is because many examples are written in different languages, so the ability to read, to understand and possible re-use can be very useful. Beyond this, any knowledge of C++ is highly useful, because it opens up the potential to write more advanced types of plug-in or high performance code.
  • Master XSI. It is important to have a good idea of the built-in functionality and user interface for the particular areas of XSI that is the focus of the scripting. For example when writing custom operators it is important to understand how to apply built-in operators, how to manipulate the operator stack (the construction history), how to see the connections between objects and how to test the operator in action.
  • Keep track of the new features added in each version of XSI. Because the XSI SDK is always improving there can be new and easier ways to get your job done with each release.
  • Iterate and refactor. Although it can be fairly easy to patch together a quick script that gets the job done, a master script writer will do passes through the script code to improve it. This includes adding error (with clear error messages for user error situations), removing duplicated code and adding subroutines, commenting the code, using clear names for the variables and functions. Such work may be low priority for a “run-once-and-throw-away” script, but for anything that needs to be available to many users and enhanced over time this is critical. Ideally your code should be something you aren’t embarrassed to post on the mailing list, and something that you are any other script master could understand even after a few years when you suddenly have to enhance it for a new production.
  • Don’t get stuck on details. No script is ever perfect. Although iteration and refactoring is a very good way to improve the code, a script master will also know when it is good enough and stop tinkering with this. A good example of getting stuck on details are coders who get carried away with writing high performance code, which if often misguided if the code is not actually a production bottleneck.
  • Look under the hood. Some of the most advanced script masters have examined the scripts and SPDL files that ship with XSI, and which include the implementations of important commands. Some have even suggested improvements back to Softimage, or experimented with making their own changes directly in those files. This is a challenging area, but it can be a treasure trove of advanced knowledge for a script master.

This may seem like a daunting list of suggestions, each of which can imply days or weeks of study. But the pay-off to mastering scripting can be great. For example, in the field of professional programming it has been found that some programmers are literally ten times more productive than other programmers!

Imagine what that sort of productivity could do to improve your daily work. Although no one has the arrogance to call themselves a “master”, if you read the XSI mailing list and other community forums you will realize that these masters really exist.

Conclusion

Each user is different, with a different background and a different approach to learning. This article deals very much with broad generalizations, and many “students” of the XSI SDK will travel a different path. Perhaps there are other major categories of scriptwriters that could be described in future articles, for example “the hacker”, “the PHD”, “the management-type”, “the god”.

No matter where you stand with your current scripting skills I hope this article motivates you to keep pushing ahead on improving your core competencies so that you become more of a XSI SDK script master.

6 Responses to “Becoming a Script Master”

  1. Is always interesting to read and talk about what an “artistic” mind can produce as a programmer. I think is really hard to put in a scheme such a random path, so well done, perfect synthesis!
    I’m quite curious about the “Hackers” kind : )

  2. For a while now, many non-scripters / non-technical people out there may have been wondering how to dive in and how to develop their technical skills. You”ve laid out a pretty clear roadmap for them with this article.

    Good work!
    Cheers

  3. Helge Mathee says:

    nice article.

    I can see alot of people dive into scripting and get stuck.
    I think the trick is to experience once how much scripting can improve your daily workflow, and then you”ll get sucked in. ;-)

  4. Bonifacius says:

    Great article. I am just sad I dont know how to reply properly, though, since I want to show my appreciation like many other.

  5. Best Cameras says:

    Good Blog keep it up…

  6. thomas says:

    oldies, but goldies !