Monday, December 7, 2020
Monday, October 5, 2020
Tale of the Goblin Wizard
This just popped up in my youtube feed. I worked on it quite a while ago adjusting Cloth Rigs for the wizards and Goblin Wizard as well as doing CFX on a bunch of the shots.
Tuesday, January 21, 2020
Kroeger "Anthem" for Hornet Inc
Had a pretty fun time setting up a whole lot of these characters. Jared Eng created a pretty nice base rig, and I did a whole lot of skinning and enveloping, as well as add clothing and prop rigs on top.
Kroger "Anthem" Dir: Cesar Pelizer from Hornet on Vimeo.
Kroger "Anthem" Dir: Cesar Pelizer from Hornet on Vimeo.
Tuesday, December 10, 2019
setting chrome as default browser for Maya
Apparently the easiest/only way to force Maya to use Chrome ( or firefox) is to update your registry and force it to use it..
this little bit of python code should do the trick.
import _winreg
htm = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,"SOFTWARE\\Classes\\.htm", 0, _winreg.KEY_ALL_ACCESS)
_winreg.SetValueEx(htm, '', 0, 1, "ChromeHTML")
_winreg.CloseKey(htm)
this little bit of python code should do the trick.
import _winreg
htm = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,"SOFTWARE\\Classes\\.htm", 0, _winreg.KEY_ALL_ACCESS)
_winreg.SetValueEx(htm, '', 0, 1, "ChromeHTML")
_winreg.CloseKey(htm)
Tuesday, July 23, 2019
Spring 2019 Reel
Just collected up a few more items to put into my new Spring 2019 Reel.
It's just a collection of some of my recent and most fun work to date.
and at the moment I am looking for full time work in the NYC area, or remote.
Unfortunately I can't put any of the "the Society" work in just yet ( spoilers, etc)
smann_2019_reel from Stephenkmann@gmail.com on Vimeo.
It's just a collection of some of my recent and most fun work to date.
and at the moment I am looking for full time work in the NYC area, or remote.
Unfortunately I can't put any of the "the Society" work in just yet ( spoilers, etc)
smann_2019_reel from Stephenkmann@gmail.com on Vimeo.
Thursday, March 14, 2019
PolyUniteSkinned
It's rare you need it, but when you do.. you need it.
This little hidden gem of a command will merge all your selected geometries into one. and maintain the skin weights.
And , with construction history off, it makes a very nice clean result of single orig node, single shape node, and one skin cluster.
polyUniteSkinned -constructionHistory 0 -mergeUVSets 1 ;
This little hidden gem of a command will merge all your selected geometries into one. and maintain the skin weights.
And , with construction history off, it makes a very nice clean result of single orig node, single shape node, and one skin cluster.
polyUniteSkinned -constructionHistory 0 -mergeUVSets 1 ;
Synopsis: polyUniteSkinned [flags] [String...]
Flags:
-e -edit
-q -query
-ch -constructionHistory on|off
-cp -centerPivot
-muv -mergeUVSets Int
-op -objectPivot
Command Type: Command
Friday, November 9, 2018
Work recap , November 2018
Aardman Nathan Love
CG Supervisor / Lead Character TD
"Candy Crush Friends Saga"
Responsible for rigging all characters and CG supervising projectw
PSYOP : Tech Animator / character TD
Clash of Clans: Eight Clans Enter One Clan Leaves
Responsible for cloth sim and tech anm polish on all characters in most shots
PSYOP : Tech Animator / character TD
Cricket Wireless
"Four For the Holidays"
Responsible for cloth sim and tech anm polish on all characters in 25% of the shots, some minor rigging on clothing
CG Supervisor / Lead Character TD
"Candy Crush Friends Saga"
Responsible for rigging all characters and CG supervising projectw
PSYOP : Tech Animator / character TD
Clash of Clans: Eight Clans Enter One Clan Leaves
Responsible for cloth sim and tech anm polish on all characters in most shots
PSYOP : Tech Animator / character TD
Cricket Wireless
"Four For the Holidays"
Responsible for cloth sim and tech anm polish on all characters in 25% of the shots, some minor rigging on clothing
Thursday, September 20, 2018
Camera Framing Bug and NAN value in Maya 2018.3
NaN
Some operations of floating-point arithmetic are invalid, such as taking the square root of a negative number. The act of reaching an invalid result is called a floating-point exception. An exceptional result is represented by a special code called a NaN, for "Not a Number". All NaNs in IEEE 754-1985 have this format:
I haven't seen this one in quite a while, but just got bit by it.. hard. The issue crops up when Maya has a division by zero issue, or something similar that results in an infinitesimally small or NAN number. It used to happen a lot with uvs .. especially with uvs coming from zBrush, as zBrush, like the honey badger, didn't care. But it would mess up Maya read on open, and often would end up in an open file, with seemingly nothing in it but the transform nodes.
You would think, what do I care. Fubar uvs are not my problem, and I can make new ones anyway.. but Maya, says, wait I don't know what NAN is and basically stops trying, and just errors out the rest of your scene.
This new issue seems to be hard to track down, but easy to accidentally do, and that's when hit f to frame the camera on a selection. For some reason it will put NAN into all the translate channels of the camera, and also in the center of interest (which is the biggest issue) , and using [ and ] to try and go back to previous views. doesn't work.. huh,
To fix this you want to do a couple things.
First is to reset the TRS of the camera, so select it, and run Modify -> reset transforms.
next in the view, go to view -> default View
But really, I'm more interested in how it happens, and how to fix it !
the nice thing is.. it looks like this issue is fixed in 2018.4
but until you get updated.. here is some mel code you can run in your scene to reset you camera.. i added a small part to reset pan/zoom as well
I put this on my hotbox so I can quickly access it:
________________________________________________________________
global proc resetCamera()
{
string $panel=`getPanel -wf`; if ($panel == "StereoPanel"){$panel = "StereoPanelEditor";}
string $camera = `modelEditor -q -cam $panel`;
string $chans[] = {"tx","ty","tz","rx","ry","rz"};
for ($chan in $chans)
{
catchQuiet(`setAttr ($camera + "." + $chan) 0`);
}
string $chans[] = {"sx","sy","sz"};
for ($chan in $chans)
{
catchQuiet(`setAttr ($camera + "." + $chan) 1`);
}
viewSet -animate 0 -home $camera;
string $camShape[] = `listRelatives -c -s $camera`;
setAttr ($camShape[0] + ".horizontalPan" ) 0 ;
setAttr ($camShape[0] + ".verticalPan" ) 0 ;
setAttr ($camShape[0] + ".zoom") 1;
}
Some operations of floating-point arithmetic are invalid, such as taking the square root of a negative number. The act of reaching an invalid result is called a floating-point exception. An exceptional result is represented by a special code called a NaN, for "Not a Number". All NaNs in IEEE 754-1985 have this format:
I haven't seen this one in quite a while, but just got bit by it.. hard. The issue crops up when Maya has a division by zero issue, or something similar that results in an infinitesimally small or NAN number. It used to happen a lot with uvs .. especially with uvs coming from zBrush, as zBrush, like the honey badger, didn't care. But it would mess up Maya read on open, and often would end up in an open file, with seemingly nothing in it but the transform nodes.
You would think, what do I care. Fubar uvs are not my problem, and I can make new ones anyway.. but Maya, says, wait I don't know what NAN is and basically stops trying, and just errors out the rest of your scene.
This new issue seems to be hard to track down, but easy to accidentally do, and that's when hit f to frame the camera on a selection. For some reason it will put NAN into all the translate channels of the camera, and also in the center of interest (which is the biggest issue) , and using [ and ] to try and go back to previous views. doesn't work.. huh,
To fix this you want to do a couple things.
First is to reset the TRS of the camera, so select it, and run Modify -> reset transforms.
next in the view, go to view -> default View
But really, I'm more interested in how it happens, and how to fix it !
the nice thing is.. it looks like this issue is fixed in 2018.4
but until you get updated.. here is some mel code you can run in your scene to reset you camera.. i added a small part to reset pan/zoom as well
I put this on my hotbox so I can quickly access it:
________________________________________________________________
global proc resetCamera()
{
string $panel=`getPanel -wf`; if ($panel == "StereoPanel"){$panel = "StereoPanelEditor";}
string $camera = `modelEditor -q -cam $panel`;
string $chans[] = {"tx","ty","tz","rx","ry","rz"};
for ($chan in $chans)
{
catchQuiet(`setAttr ($camera + "." + $chan) 0`);
}
string $chans[] = {"sx","sy","sz"};
for ($chan in $chans)
{
catchQuiet(`setAttr ($camera + "." + $chan) 1`);
}
viewSet -animate 0 -home $camera;
string $camShape[] = `listRelatives -c -s $camera`;
setAttr ($camShape[0] + ".horizontalPan" ) 0 ;
setAttr ($camShape[0] + ".verticalPan" ) 0 ;
setAttr ($camShape[0] + ".zoom") 1;
}
Tuesday, September 18, 2018
xray selected
Just passing thru an old script
// xraySelected.mel
// isolated by steve Mann
global proc xraySelectedObj()
{
// get selected shape nodes
string $sel[] = `ls -sl -dag -s`;
for( $each in $sel )
{
if (`getAttr ($each + ".intermediateObject")` == 0)
{
int $xState[] = `displaySurface -q -xRay $each`;
displaySurface -xRay ( !$xState[0] ) $each;
}
}
}
// xraySelected.mel
// isolated by steve Mann
global proc xraySelectedObj()
{
// get selected shape nodes
string $sel[] = `ls -sl -dag -s`;
for( $each in $sel )
{
if (`getAttr ($each + ".intermediateObject")` == 0)
{
int $xState[] = `displaySurface -q -xRay $each`;
displaySurface -xRay ( !$xState[0] ) $each;
}
}
}
Thursday, September 13, 2018
Handle your instances
Thinking about controlling python classes and instances in Maya . As basically , every 'bit' you create, adds to the amount of memory Maya is taking up.
So in doing a little research , stumbled upon del() globals(), and locals()
del( ' name of instance') will remove the object from memory... NICE!
globals() lists all the instances in memory of your Maya session, notice that it's not just classes and procedures, but also any random variables you( or a script that was run) created. ie: if you've import maya.cmds as mc it will show up , but also if you've run a sel = cmds.ls(sl=True), that will also show up..
locals() scope of local variables... ( as above )
So in looking for your errant variables, it becomes even more important, NOT to have them, but also to name them something that not only doesn't overlap with existing variables.. ( as mel won't let you, python you can redeclare f***All ) , but also to name them with a unique signifier.. I've started using sm for mine.. which makes things fun ,, like, my sm_rigging_tools gets imported as smrt. ahh.. how cute. , but my matrix math is sort of ugly smmm .
in any case I thought I'd try and be more proactive, so I can do things like search for only my instances.. We'll see how it all works out.
glist = globals()
for g in glist:
if g.startswith("sm"):
print g
In mel you can list all gloabl variables using env, but , since variables written into the script editor, unless scoped, are global, you want to be very careful.
And also, just like a mel variable cannot be redefined.. it also appears that it cannot be removed either.
{
string $gList[] = `env`;
$glist = `sort $gList`;
for ($g in $gList)
print ($g + "\n");
}
but realistically, it probably doesn't hurt to scope python in the script editor as well
-=s
So in doing a little research , stumbled upon del() globals(), and locals()
del( ' name of instance') will remove the object from memory... NICE!
globals() lists all the instances in memory of your Maya session, notice that it's not just classes and procedures, but also any random variables you( or a script that was run) created. ie: if you've import maya.cmds as mc it will show up , but also if you've run a sel = cmds.ls(sl=True), that will also show up..
locals() scope of local variables... ( as above )
So in looking for your errant variables, it becomes even more important, NOT to have them, but also to name them something that not only doesn't overlap with existing variables.. ( as mel won't let you, python you can redeclare f***All ) , but also to name them with a unique signifier.. I've started using sm for mine.. which makes things fun ,, like, my sm_rigging_tools gets imported as smrt. ahh.. how cute. , but my matrix math is sort of ugly smmm .
in any case I thought I'd try and be more proactive, so I can do things like search for only my instances.. We'll see how it all works out.
glist = globals()
for g in glist:
if g.startswith("sm"):
print g
In mel you can list all gloabl variables using env, but , since variables written into the script editor, unless scoped, are global, you want to be very careful.
And also, just like a mel variable cannot be redefined.. it also appears that it cannot be removed either.
string $gList[] = `env`;
$glist = `sort $gList`;
for ($g in $gList)
print ($g + "\n");
}
but realistically, it probably doesn't hurt to scope python in the script editor as well
-=s
Wednesday, August 29, 2018
select curves in hierarchy
//select the curves in hierarchy
{
select -hi `ls -sl -dag -type "nurbsCurve"`;
string $sel[] = `ls -sl`;
select -clear;
for ($e in $sel)
select -add `listRelatives -p $e`;
}
Monday, May 7, 2018
Wednesday, February 14, 2018
Aardman Nathan Love : Chobani
Had a great time being involved with this Chobani Project.
Directed by Anca Risca , and art Directed by Kim Dulany , Eric Cunha really nailed the hand drawn look of the integrated CG into the beautifully hand animated animation.
Chobani "The Giving Tree" from Aardman Nathan Love on Vimeo.
Directed by Anca Risca , and art Directed by Kim Dulany , Eric Cunha really nailed the hand drawn look of the integrated CG into the beautifully hand animated animation.
New Projects from Aardman Nathan Love
Back in September I picked up a job as CG supervisor at Aardman Nathan Love. Super awesome bunch of artists to work with..
It was a busy end to 2017 with two projects stacked on top of each other with a Sprite Cranberry christmas special type spot featuring Lebron James and Dram .
Sprite "Thirstiest Time of the Year" from Aardman Nathan Love on Vimeo.
and a whole mess of station IDs for Nickelodeon..
Nickelodeon "Winter Refresh" ID's - Supercut from Aardman Nathan Love on Vimeo.
It was a busy end to 2017 with two projects stacked on top of each other with a Sprite Cranberry christmas special type spot featuring Lebron James and Dram .
Sprite "Thirstiest Time of the Year" from Aardman Nathan Love on Vimeo.
and a whole mess of station IDs for Nickelodeon..
Nickelodeon "Winter Refresh" ID's - Supercut from Aardman Nathan Love on Vimeo.
Friday, November 18, 2016
V-ray Light inconsistency on "visibility"
I don't know why Vray lights are set to "visible" , or in some cases not set to "invisible" by default. I can't think of any time I actually want my lights visible and to affect the alpha of the image.
However. no big deal, I thought I'd write a little script to auto turn them off.. Only to discover that some lights use "visibility" and some use "invisible" for their channels.
LightDome, sphere and Rect Lights use "Invisible" while IES use "Visibility"
In the end, I don't care what the channel name is.. but it sure would be nice if it was consistent.


However. no big deal, I thought I'd write a little script to auto turn them off.. Only to discover that some lights use "visibility" and some use "invisible" for their channels.
LightDome, sphere and Rect Lights use "Invisible" while IES use "Visibility"
In the end, I don't care what the channel name is.. but it sure would be nice if it was consistent.


Monday, October 17, 2016
hiding Arnold channels on shapes
Man, those keyable and visible channels on mesh and curve shapes are super annoying. I have no idea what they do, and have never really understood why they are all there .. but Arnold adds them, and for some reason. Ignores requests to hide them, which is interesting, cause to hide them, is super easy ..
so. I wrote a simple script to hide arnold channels,, It's not automatic, so every new mesh or curve needs to have it run, and sometimes when doing mesh separate and mesh combine operations, a new mesh object is created, so the channels are created fresh on the new object.
I just put the script on my shelf and randomly hit it, like a gerbil hitting the space bar for food in a pysch 101 class experiment.
You don't need anything selected, it just grabs all nurbs curves , and all mesh shapes, and hides the channels,... ( and of course can be reverse engineered if you ever want to show the channels again )
here's the script:
// stephenkmann@gmail.com
// just a quick way to hide all the arnold channels that are added to shapes
global proc hideArnoldChan()
{
string $meshes[] = `ls -type "mesh"`;
for ($mesh in $meshes )
{
setAttr -keyable false -channelBox false ($mesh + ".ai_shadow_density");
setAttr -keyable false -channelBox false ($mesh + ".ai_exposure");
setAttr -keyable false -channelBox false ($mesh + ".ai_diffuse");
setAttr -keyable false -channelBox false ($mesh + ".ai_specular");
setAttr -keyable false -channelBox false ($mesh + ".ai_sss");
setAttr -keyable false -channelBox false ($mesh + ".ai_indirect");
setAttr -keyable false -channelBox false ($mesh + ".ai_volume");
setAttr -keyable false -channelBox false ($mesh + ".ai_use_color_temperature");
setAttr -keyable false -channelBox false ($mesh + ".ai_color_temperature");
setAttr -keyable false -channelBox false ($mesh + ".scr");
setAttr -keyable false -channelBox false ($mesh + ".scg");
setAttr -keyable false -channelBox false ($mesh + ".scb");
setAttr -keyable false -channelBox false ($mesh + ".intensity");
setAttr -keyable false -channelBox false ($mesh + ".emitDiffuse");
setAttr -keyable false -channelBox false ($mesh + ".emitSpecular");
}
string $nurbsCrvs[] = `ls -type "nurbsCurve"`;
for ($crv in $nurbsCrvs)
{
setAttr -keyable false -channelBox false ( $crv + ".rcurve");
setAttr -keyable false -channelBox false ( $crv + ".cwdth");
setAttr -keyable false -channelBox false ( $crv + ".srate");
setAttr -keyable false -channelBox false ( $crv + ".ai_curve_shaderr");
setAttr -keyable false -channelBox false ( $crv + ".ai_curve_shaderg");
setAttr -keyable false -channelBox false ( $crv + ".ai_curve_shaderb");
}
}
Wednesday, September 28, 2016
Random scripts I needed this week
This is more for me than to actually share as I know I'll forget these ...
in a heavy scene file I was running into issues dealing with the geo and blendShapes and just wanted to kick out some things without having to deal with the ui. ( I had also transferred UV maps which kills basically everything until you get rid of history )
so for exporting the blendShape maps the command is part of the ART brush commands and will open up the file dialog for size and where you want to save the exported image file
// export maps
artExportMapDialog "artAttrCtx";
I also wanted to smooth flood the hell out of my painted maps, but I didn't want to sit there hitting the "flood" button forever.. so I just wrote an uber simple loop script.. What's weird to me is that the flag that coincides with "flood" .. is -clear.
{
int $i = 0;
while ($i <= 25)
{
artAttrCtx -e -clear `currentCtx`;
$i++;
}
}
also this is all in Maya 2016. so I am not even sure what works and doesn't in 2017 yet with blendshapes, and blendShape wt maps.
Monday, April 25, 2016
Maya mode OptionMenu
I do a lot of editing to the source code of Maya's UI to customize and add or remove items.
One of my personal pet peeves is the "mode" button in the upper left corner of Maya's status bar. It's huge, I use the hotbox predominantly so it's useless to me, and it doesn't have a "collapse bar" so you can hide it like all the other buttons and ui items on the status bar.
The purpose of the mode button is to change what menu set is available, like "modeling" , "rendering" etc.
There isn't that much space on a screen, and this button already is connected to a bunch of hotkeys { which I also don't use}, So I find it very redundant.. Unless I am making a custom menuSet.. which I guess now I'll have to explain later... but you can make your own menus that show up in the hotbox or menu .. but I'll do that later..
in any case the nice thing is this optionMenu is easy to get at , as Maya has already made it a global variable by default
print $gMenuModeButton;
will give you the actual name of the optionMenu, which will change each time you open Maya
in this instance I get the following
//MayaWindow|toolBar1|MainStatusLineLayout|formLayout5|flowLayout1|optionMenuForm|menuMode
note the numbers in the names, this is due to Maya not caring what those layout's names are . but the Menu Mode Button , Maya wants to know because it is accessed all over the place to help show menus and ui .. So the easiest way for the developers to do that, was to make a it a global variable.. There are a lot of these and they almost all start with 'g'
so even though they named it "button" it's actually an optionMenu. ( which I think I only know from digging into the statusline.mel code)
So now that you know what it is you can do all sorts of things to it, like hide it
optionMenu -e -vis 1 $gMenuModeButton
or make it smaller.
optionMenu -e -width 1 $gMenuModeButton
It's super important to use the -e or -edit flag when running the optionMenu command, or you will end up adding a new optionMenu somewhere in maya.. which of course can be dangerous, and not what you want.
You could add a shelf button or menu somewhere to show/hide the menu, but I just put the above command into my userSetup.mel and let Maya collapse it on start up.
If I really wanted to dig in I would add a collapse bar in front of the optionMenu, but since I almost never ever use it.. I haven't bothered to do so.
if you want to do other edits to the menu just check out the help docs.
help -doc optionMenu;
Lately I've been playing with the "custom" menu sets and so I've only been shrinking the mode button down, so I can still access it when I want to without having to run code to reveal it again.. and I can live with 5 -10 pixel width vs 100
( you can't read the menu names, but I know custom is at the bottom so I just click the bottom one)
hth
-=s
One of my personal pet peeves is the "mode" button in the upper left corner of Maya's status bar. It's huge, I use the hotbox predominantly so it's useless to me, and it doesn't have a "collapse bar" so you can hide it like all the other buttons and ui items on the status bar.
The purpose of the mode button is to change what menu set is available, like "modeling" , "rendering" etc.
There isn't that much space on a screen, and this button already is connected to a bunch of hotkeys { which I also don't use}, So I find it very redundant.. Unless I am making a custom menuSet.. which I guess now I'll have to explain later... but you can make your own menus that show up in the hotbox or menu .. but I'll do that later..
in any case the nice thing is this optionMenu is easy to get at , as Maya has already made it a global variable by default
print $gMenuModeButton;
will give you the actual name of the optionMenu, which will change each time you open Maya
in this instance I get the following
//MayaWindow|toolBar1|MainStatusLineLayout|formLayout5|flowLayout1|optionMenuForm|menuMode
note the numbers in the names, this is due to Maya not caring what those layout's names are . but the Menu Mode Button , Maya wants to know because it is accessed all over the place to help show menus and ui .. So the easiest way for the developers to do that, was to make a it a global variable.. There are a lot of these and they almost all start with 'g'
so even though they named it "button" it's actually an optionMenu. ( which I think I only know from digging into the statusline.mel code)
So now that you know what it is you can do all sorts of things to it, like hide it
optionMenu -e -vis 1 $gMenuModeButton
optionMenu -e -width 1 $gMenuModeButton
It's super important to use the -e or -edit flag when running the optionMenu command, or you will end up adding a new optionMenu somewhere in maya.. which of course can be dangerous, and not what you want.
You could add a shelf button or menu somewhere to show/hide the menu, but I just put the above command into my userSetup.mel and let Maya collapse it on start up.
If I really wanted to dig in I would add a collapse bar in front of the optionMenu, but since I almost never ever use it.. I haven't bothered to do so.
if you want to do other edits to the menu just check out the help docs.
help -doc optionMenu;
Lately I've been playing with the "custom" menu sets and so I've only been shrinking the mode button down, so I can still access it when I want to without having to run code to reveal it again.. and I can live with 5 -10 pixel width vs 100
( you can't read the menu names, but I know custom is at the bottom so I just click the bottom one)
hth
-=s
Thursday, April 21, 2016
One of my last jobs at CHRLX
Rigging the Jublia toe-nail fungus tennis girl.......
Jublia "Smash It" Commercial from Rob Cavallo on Vimeo.
Jublia "Smash It" Commercial from Rob Cavallo on Vimeo.
Friday, March 11, 2016
Simple Maya Script Snippets
I sort of started doing the rigging dojo challenge of putting out a super simple script snippet a day, that not only does "something" but also displays something interesting in the world of scripting for Maya . None of this is mind bending and I'm sure not new to a lot of people, but maybe it will help someone with an intro
day one:
so this is a super simple script to just get the number of objects you have selected.. I have gotten so use to writing this script that I tend to just pop it into the script editor without thinking
the nice thing here is I'm not creating any variables so they wont be global or overwrite anything in my current Maya session.
mel:
size `ls -sl`;
python:
len(cmds.ls(sl=True))
also since the "select" command does not have a type flag. I use this same sort of method for quickly selecting all of a given node type
mel:
select `ls -type "mesh"`;
python:
cmds.select(cmds.ls(type='mesh'))
day two:
ok, so this one is not so different from the previous, so I'll just call it "super simple script" that can be helpful ( i just ran out of time today)
This one just takes your current object's type and makes a set of every object of that type in your scene . Since I'm dropping this on the shelf or running in the script editor, I scope it inside curly braces to keep the variables from going global. I highly recommend scoping whenever you are prototyping in the script editor with mel.. or you will bang your head against an illegal re-declaration , or an array of the wrong items from time to time.
{
string $s[] =`ls -sl ` ;
string $c[] =`listRelatives -c -s $s[0]`;
string $type = `nodeType $c[0]` ;
sets -n ($type + "s") `ls -type $type`;
}
for the Python version I was able to get rid of all the variables as you can nest functions better ( with Mel you only can do it once)
(the following should read as just 2 lines, the first being the import of the maya commands module )
import maya.cmds as cmds
cmds.sets(cmds.ls(type=cmds.nodeType(cmds.listRelatives(cmds.ls(sl=True)[0],c=True,s=True))),n='SET')
day three:
this is an experiment in fixing up an old script and streamlining it a little bit. the top this time is in Python, and I added the nope variable & print statement just to demonstrate that nope is actually list of booleans and I have to A) pull out the first item using [0] and then use str() to force it into a string for printing
sel=cmds.ls(sl=True,dag=True,shapes=True,noIntermediate=True)
for e in sel:
nope =not(cmds.displaySurface(e,query=True,xRay=True))[0]
print ("the ! issue is : " + str(nope) )
cmds.displaySurface(xRay=not(cmds.displaySurface(e,query=True,xRay=True))[0])
pretty much the same thing, but I don't have the same power in MEL to pull the first item out of the int array, and so I have to first make an int array variable and then use that in the action part of the script,, note that in MEL you can use ! for ( opposite or not) while in Python it's "not" to do the same thing
{
string $sel[] = `ls -sl -dag -s -noIntermediate`;
for ($each in $sel)
{
int $x[] =`displaySurface -q -xRay $each`;
displaySurface -xRay ( !$x[0] ) $each;
}
}
day one:
so this is a super simple script to just get the number of objects you have selected.. I have gotten so use to writing this script that I tend to just pop it into the script editor without thinking
the nice thing here is I'm not creating any variables so they wont be global or overwrite anything in my current Maya session.
mel:
size `ls -sl`;
python:
len(cmds.ls(sl=True))
also since the "select" command does not have a type flag. I use this same sort of method for quickly selecting all of a given node type
mel:
select `ls -type "mesh"`;
python:
cmds.select(cmds.ls(type='mesh'))
day two:
ok, so this one is not so different from the previous, so I'll just call it "super simple script" that can be helpful ( i just ran out of time today)
This one just takes your current object's type and makes a set of every object of that type in your scene . Since I'm dropping this on the shelf or running in the script editor, I scope it inside curly braces to keep the variables from going global. I highly recommend scoping whenever you are prototyping in the script editor with mel.. or you will bang your head against an illegal re-declaration , or an array of the wrong items from time to time.
{
string $s[] =`ls -sl ` ;
string $c[] =`listRelatives -c -s $s[0]`;
string $type = `nodeType $c[0]` ;
sets -n ($type + "s") `ls -type $type`;
}
for the Python version I was able to get rid of all the variables as you can nest functions better ( with Mel you only can do it once)
(the following should read as just 2 lines, the first being the import of the maya commands module )
import maya.cmds as cmds
cmds.sets(cmds.ls(type=cmds.nodeType(cmds.listRelatives(cmds.ls(sl=True)[0],c=True,s=True))),n='SET')
day three:
this is an experiment in fixing up an old script and streamlining it a little bit. the top this time is in Python, and I added the nope variable & print statement just to demonstrate that nope is actually list of booleans and I have to A) pull out the first item using [0] and then use str() to force it into a string for printing
sel=cmds.ls(sl=True,dag=True,shapes=True,noIntermediate=True)
for e in sel:
nope =not(cmds.displaySurface(e,query=True,xRay=True))[0]
print ("the ! issue is : " + str(nope) )
cmds.displaySurface(xRay=not(cmds.displaySurface(e,query=True,xRay=True))[0])
pretty much the same thing, but I don't have the same power in MEL to pull the first item out of the int array, and so I have to first make an int array variable and then use that in the action part of the script,, note that in MEL you can use ! for ( opposite or not) while in Python it's "not" to do the same thing
{
string $sel[] = `ls -sl -dag -s -noIntermediate`;
for ($each in $sel)
{
int $x[] =`displaySurface -q -xRay $each`;
displaySurface -xRay ( !$x[0] ) $each;
}
}
Subscribe to:
Posts (Atom)




