Is there any kind of script or built in function to Maya that selects all objects with rotations or translates less than or greater than zero. And scale less than or greater than one? Any help would be appreciated
Asked
Active
Viewed 1,911 times
1 Answers
0
EDIT : My phone did uppercase to the 'if' so it wasn't working. The error in the script editor gave this :
# Error: invalid syntax
# File "<maya console>", line 9
# If any(Tr) or any(Rot):
# ^
# SyntaxError: invalid syntax #
It gives you the line with problems so it is really straight forward to debug. I suggest you should learn python/mel basics, there is a lot of good place to do this and there is also website where you can find code if you dont want to learn : pluralsight, justinFx, highend3d, maya google group On stackoverflow, it is more to correct bugs, mistakes than providing full code.
import maya.cmds as cmds
Objs = cmds.ls(type='transform')
Out=[]
for o in Objs:
Tr = cmds.getAttr(o+'.t')[0]
Rot = cmds.getAttr(o+'.r')[0]
if any(Tr) or any(Rot):
Out.append(o)
Sca = cmds.getAttr(o+'.s')[0]
if Sca != (1,1,1):
Out.append(o)
print(Out)

DrWeeny
- 2,487
- 1
- 14
- 17
-
Hmmn, I have very limited programming knowledge, I assume this is python? When I paste this in the python window it just gives a syntax error, any ideas? Thank you very much for your help – thisisnice05 Mar 26 '19 at 23:55
-
Ill check this when I get to my office two hours but yeah it is python – DrWeeny Mar 27 '19 at 00:06
-
Thank you so much, I have marked it as the answer. It does not select the objects though, it lists them in the script editor. I did learn a little bit of mel a few years ago but I never ended up having to use it – thisisnice05 Mar 27 '19 at 02:02
-
never mind, I realized I just need to replace print with cmds.select – thisisnice05 Mar 27 '19 at 02:12
-
One last comment because I have already said too much, it did not tell me the line with problems in the script editor, which is why I only mentioned the syntax error – thisisnice05 Mar 27 '19 at 02:32
-
in your script editor, there is a tab called History, click on it, and make sure you have ticked Batch Render Messages, Line numbers in errors and show stack trace. – DrWeeny Mar 27 '19 at 03:03
-
Keep in mind that this doesn't take into account extremely small float numbers that would otherwise be perfectly fine. I'm talking about numbers like `4.355996409864918e-16` that would trigger it being non-zero. Although technically true, it's so trivial and would pop up on many objects that are deemed 'ok'. – Green Cell Mar 28 '19 at 01:59