Author Topic: Simplify command line scripts / cmd commands  (Read 1972 times)

0 Members and 1 Guest are viewing this topic.

Offline rowan

  • Hero Member
  • *****
  • Posts: 1679
    • View Profile
Simplify command line scripts / cmd commands
« on: July 05, 2011, 12:00:37 PM »
If you've ever done any command line rendering on Windows before you'll notice that on most computers you have to specify the full path to Render.exe, as opposed to being able to simply call 'Render' from the cmd. This makes scripts a little long winded, harder to read and a bit fiddly. Other commands, system commands like msconfig or compmgmt are only one word commands because the environmental variables are set to check the system 32 directory (amongst others) for these commands - this is a windows system default. You can modify these environmental variables in windows to check the installation directory of Maya for commands from the cmd, so that you don't have to specify the full path ever again (on that system). Straight off the bat I will say this tutorial will not work in the labs because you will require administrator rights, I will email Pat about having this set up for the next image. For you home PC however;

Go to Control Panel
System
Advanced tab
Environment Variables
Under system variables locate the 'Path' variable, select it
Click edit
At the end of the entry add a value, ";C:/Program Files/Autodesk/Maya/bin/" without the "", and obviously specifying the directory in which Render.exe resides
The ; divides values in here
Hit ok twice

This simply changes the search path the cmd uses for finding commands and flags. Obviously the more values you add here potentially the more time it will take to search and find your command, but we're talking milliseconds. This will mean next time you type Render into cmd, or call this command in a .bat script, you will not need to specify the full path, Windows will check the directory you specified first.

E.g a typical script line;
"C:/Program Files/Autodesk/Maya/bin/Render.exe" -r file sickRender.mb
becomes
Render -r file sickRender.mb

As always, remember you must specify the Maya file's full directory, unless the .bat script is run from that directory or you cd (change directory) to that location prior to the Render command.

<3 Rowan
Animation? That's pretty much just done by Bridget nowadays... Bridget is ok I guess!!!! <3 <3 <3

Offline Patrick M

  • School IT Coordinator
  • Administrator
  • Sr. Member
  • *****
  • Posts: 276
    • View Profile
Re: Simplify command line scripts / cmd commands
« Reply #1 on: July 05, 2011, 12:14:09 PM »
BE VERY CAREFUL changing the Environment Variables on your system as any errors will and can stop your system from booting.

Also to clean up and script 'correctly' use and set variables at the top of a script to point to the folder you wish to 'render' from and add that variable to your commands.

When I get more time I can show you what I mean if you want.

Offline rowan

  • Hero Member
  • *****
  • Posts: 1679
    • View Profile
Re: Simplify command line scripts / cmd commands
« Reply #2 on: July 05, 2011, 06:35:17 PM »
This article covers the same kind of modification for terminal in Mac OS X, it works well.

http://www.macgasm.net/2008/04/10/adding-a-new-location-to-your-path-variable-within-terminal

As Pat said, take care to follow the instructions closely. I will add to my earlier post you can use the command 'PATH="C:/Program Files/Autodesk/maya/bin/Render.exe"' at the top of your batch scripts and after that you'd need only use the Render command without the full path in each line, I just depends how many batch renders you do a day.

<3 Rowan
Animation? That's pretty much just done by Bridget nowadays... Bridget is ok I guess!!!! <3 <3 <3