import maya.cmds as cmds
Def objs_of_type(all_nodes, node_type):
Return [node for node in all_nodes if cmds.nodeType(node==node_type)]
I used list comprehension.
On Monday, May 6, 2013, Simen Chris wrote:
> Hey guys, I'm working on creating generic functions that are flexible and
> can be called from my other scripts. However, I feel like I use a lot more
> code that necessary, I have 12 if-conditions just in this little script
> that I've attached.
>
> The attached script is a function that reads all the objects I define as
> inputs, then checks if they match the specified objectType, and then
> returns the objects that match the objectType specified.
>
> I was hoping someone could take a quick look and see if things could be
> done in a better way :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:;>.
> To post to this group, send email to
> [email protected]<javascript:;>
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.