http://forums.cgsociety.org/showthread.php?f=98&t=816475
Developed by Blur, these plugins have the potential to replace Maxscript and finally let us use Python properly in 3DS Max.
I'm just starting to dig into it, fingers crossed...
Saturday, October 17, 2009
Thursday, October 1, 2009
MEL: Check If An Object Or Attribute Exists
Ever needed to check if an object exists in your Maya scene? Or perhaps you need to check if a certain object has an attribute or not?
Use the objExists mel command.
First let's use it in a simple way to check for the existence of an object saved in $myObject
This works for attributes too, so to check for the existence of an attribute on a certain object, let's say "R_Arm_Ctrl.IKFK" we can use the following:
Huzzah!
Use the objExists mel command.
First let's use it in a simple way to check for the existence of an object saved in $myObject
// objExists will return true or false (1 or 0), so you can use it multiple ways.
int $objTest = `objExists $myObject` ;
// If that object exists, it will return 1 (true), so then you could say something like:
if($objTest == 1) {
print "It Exists!" ;
}
// Another trick you can do is an IF statement will simply test a boolean (true or false) and fire if it's true, example:
if($objTest) {
print "It Exists!" ;
}
// So using that, we can simply test for the return of objExists in our IF statement, to simplify it even more.
if(`objExists $myObj`) {
print "It Exists!" ;
}
This works for attributes too, so to check for the existence of an attribute on a certain object, let's say "R_Arm_Ctrl.IKFK" we can use the following:
if(`objExists "R_Arm_Ctrl.IKFK"`) print "It Exists!" ;
Huzzah!
Labels:
Attribute,
Check if an object exists,
Maya,
MEL,
objExists,
Print Selected Objects
Wednesday, September 30, 2009
MEL: Print Size Of Your Current Selection, Or Print Your Current Selection
There are a few different ways to print out the size of your selection.
To print the size of your selection:
To print what is currently selected:
Any questions? Please comment below.
To print the size of your selection:
// Simply use the size command combined with the return of the list selected command
size(`ls -selection`) ;
To print what is currently selected:
// Use the LS command to list your selection
ls -selection ;
// Or print it... (same thing)
print `ls -selection` ;
// What about vertices? (faces, etc.)
// ls -selection ; will usually return a next to useless result with multiple verts selected.
// Instead add another flag, -flatten
ls -selection -flatten ;
Any questions? Please comment below.
Saturday, May 9, 2009
MAXScript: Removing Spaces From Names
Here is a quick snippet of code that will remove all the spaces in your object names and replace them with underscores. Simple yet elegant.
Select all the objects first, and run this script.
for s in selection do
(
oldname = filterString s.name " "
temp = oldname[1]
for i = 2 to oldname.count do
(
temp = temp + "_" + oldname[i]
)
s.name = temp
)
Select all the objects first, and run this script.
Friday, May 8, 2009
MEL: Breaking out of infinite loops
I read a great article today about how to break out of an infinite for or while loop in MEL. It happens to all of us at some point. Every so often you forget to add a counter or you miss a variable somewhere and you create a never-ending loop that you'd need to force quit maya in order to stop. This is a cool trick to prevent that.
http://www.naughtynathan.co.uk/?p=59
Great stuff. He also has a version for Python.
http://www.naughtynathan.co.uk/?p=59
Great stuff. He also has a version for Python.
Tuesday, March 31, 2009
MEL: Print Random Quotes
Here is a script you can put into a shelf button to print out a random quote for you. I filled mine with animation quotes, so during those times when I'm stuck and waiting for an idea I can click through it a bunch of times and get some inspiration.
We've got one set up with tons and tons of animation quotes and it works well. Be sure to load it up with stuff so you don't get bored clicking through it. You'll be surprised how often you click it.
Edit: A related article involving printing your current selection as well as printing the size of the selection.
http://www.scriptswell.net/2009/09/mel-print-size-of-your-current.html
// Here we create the array to hold all the quotes, then add them below.
string $animation_quotes[] = {
"Here is a quote, notice the comma after the quotation marks.",
"Another quotes is right here.",
"'I can add things like this as well to put the author' ~Jay",
//Note, this last entry does NOT have a comma after the quote.
//If you get a syntax error, check for that sometimes it's easy to forget
"Be creative, put cool stuff in here!"
};
//Declare this as an integer, because rand returns a float
int $quote_choice;
//Get the size of your quotes array
$animation_quotes_size = `size($animation_quotes)`;
//Get a random quote
$quote_choice = `rand 0 $animation_quotes_size`;
//Print it out
print $animation_quotes[$quote_choice];
We've got one set up with tons and tons of animation quotes and it works well. Be sure to load it up with stuff so you don't get bored clicking through it. You'll be surprised how often you click it.
Edit: A related article involving printing your current selection as well as printing the size of the selection.
http://www.scriptswell.net/2009/09/mel-print-size-of-your-current.html
Monday, March 30, 2009
MEL: Toggle Background Color in Maya
Ever wanted a button to toggle the background color of your viewport(s) in Maya? We needed one the other day to toggle to white for playblasts/reviews and back to grey for working normally.
Middle mouse drag this into your shelf to make a button for it. It's currently set at White and Grey. You'll need to know the RGB values to change the colors.
//
int $toggled_color ;
if($toggled_color == 0)
{
displayRGBColor "background" 1. 1. 1. ;
$toggled_color = 1 ;
}
else
{
displayRGBColor "background" 0.688 0.688 0.688 ;
$toggled_color = 0 ;
}
//
Middle mouse drag this into your shelf to make a button for it. It's currently set at White and Grey. You'll need to know the RGB values to change the colors.
Subscribe to:
Posts (Atom)