View Full Version : Correct Approach to get Transform?
EightBit 08-18-2009, 08:56 PM Using Mel to create a light setup has led to this multifaceted question:
When a lite is created, it returns the name of the shapeNode, so if we want to move it, we need to address its transform. I found this to get the transform - is it the best way?
file -f -new;
string $light = `pointLight -n "Front_dirLite"`;
string $lightTransf[] = `listRelatives -fullPath -p $light`;
setAttr ($lightTransf[0]+".tz") 1; If that is the most efficient way to get a transform from a shape, is there a way to nest commands? Its obviously not necessary, but I'm curious. For example, this produces an error:
string $lightTransf[] = `listRelatives -fullPath -p `pointLight -n "Front_dirLite"``;
Thanks.
|
|
_stev_
08-18-2009, 09:00 PM
You could do it like this:
string $lightTransform[] = listRelatives( "-p", pointLight("-n", "Front_dirLite") );
Stev
EightBit
08-20-2009, 04:19 AM
Thanks a lot. That's cool.
I've been learning Maya and Mel for a couple of years and I've not seen anyone use that syntax before - where commands and params are nested in parentheses.
Is it in the manual or is there an article on it somewhere?
_stev_
08-20-2009, 04:52 AM
I think all the different syntax are covered in the David Gould book, Complete Maya Programming. I'm not 100% sure of that though. The mel command reference just covers the individual commands so there may not be specific examples like this.
Maybe someone else can shed more light on this? I honestly can't remember where I picked it up from, probably seeing other posts here.
Stev
Robert Bateman
08-20-2009, 10:09 AM
I think all the different syntax are covered in the David Gould book, Complete Maya Programming. I'm not 100% sure of that though.
It's not. AFAIK, this stuff is hidden away in the maya manuals, but very very hidden! It was Joojaa at highend3d who's indirectly informed most people of that particular syntax, and I have may repeated his words on a number of occasions.... (I also included the syntax in my old mel notes). AFAIK, it's not in the gould books...
EightBit
08-21-2009, 11:45 PM
The 1st Gould book was the first Maya book I read. I thought it was great. Whenever I've recommended it to ppl on H3D, Jooja jumps in and says how lousy it is... I will still continue to use it, but this is insightful. I just started looking at Python, and this syntax looks more python-like.
It's probably poor coding to nest too many commands, but is there a limit to the number of commands which could be nested using this approach?
Thanks again.
_stev_
08-23-2009, 04:59 AM
but is there a limit to the number of commands which could be nested using this approach?
I doubt it. Though I can't imagine ever needing to go deeper than three. More than that and you'll surely need to check the return before you proceed.
Stev
CGTalk Moderation
08-23-2009, 04:59 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.