Tuesday, July 23, 2013

Maya Tools - Locator size by scale

In Maya it can cause a problem if we scale objects like camera and lights. For eg. camera imagePlane.depth attribute is affected by scale value. I had a situation when render output was a empty black image because camera (transform node) was scaled. But of course it is much easier to scale than look up the locatorScale attribute on cameraShape for instance.

So here is an easy primitive python script to adjust locatorScale based on transform node scale.

 selectedObject = cmds.ls(sl = 1)[0]  
 scaleVal = cmds.getAttr(selectedObject + ".s")[0][0]  
 cmds.setAttr(selectedObject + ".s", 1, 1, 1)  
 cmds.setAttr(cmds.listRelatives(selectedObject, shapes = 1)[0] + ".locatorScale", scaleVal)  

Okay, it can produce tons of errors if you don't use it properly. I'm going to write a function (a real tool) to check errors. I guess it will be at least 40 lines instead of 4...so the post title was kind of a bluff.
Recently I have been thinking a lot about how to simplify error handling.

No comments:

Post a Comment