You can set all three translates or rotates each with a single line of code.
Instead of this:
// Set Translates
setAttr myObject.translateX 10 ;
setAttr myObject.translateY 10 ;
setAttr myObject.translateZ 10 ;
// Set Rotates
setAttr myObject.rotateX 180 ;
setAttr myObject.rotateY 180 ;
setAttr myObject.rotateZ 180 ;
You can combine it all into just two lines, using .t and .r
// Set Translates
setAttr myObject.t 10 10 10 ;
// Set Rotates
setAttr myObject.r 180 180 180 ;
If you're really looking for some fun, try doing it all in one line using the .worldMatrix attribute. :)
hi, i have a question, if i have a my object in a variable, how do i need to write the setAttr?
ReplyDeleteI wrote by this way:
//$c have the name of the object.
setAttr $c.translateX 0;
setAttr ($c + ".translateX") 0 ;
ReplyDeleteWhat if I want to translate my object by a variable?
ReplyDeleteI wrote it like this
//$cubepx is how far I want to translate my object
setAttr myObject.translateX $cubepx
But it says Error: line 45: setAttr: Error reading data element number 1: 0