in pymel, each pynode has a method called .nodeType() that you can query.
.type() is no longer used to determine the node type because of clashes
with

if you get selected objects with pymel it will automatically pynode all of
your objects:
pm.selected() returns a list of pynode

types = [node.nodeType() for node in pm.selected()]


this might simplify your code a bit I hope.



On Mon, May 6, 2013 at 8:50 AM, Day Dreamer <day.dreamer.m...@gmail.com>wrote:

> Edit :-
>
> i mport pymel.core as pm
>
> def get_all_nodes(all_nodes, node_type):
>         return [ node for node in all_nodes if
> pm.nodeType(node)==node_type]
>
> As, pymel is highly object oriented we can modify our function to
>
> def get_all_nodes(all_nodes, pymel_node_type):
>         return[ node for node in all_nodes if isinstance(pm.PyNode(node),
> pymel_node_type)]
>
> Here, pymel_node_type is a pymel class and we checking our node is a
> instance of that particular class, if positive append the node to the list
> of desired nodes and finally return the formerd list.
>
> On Monday, May 6, 2013, Day Dreamer wrote:
>
>>  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 python_inside_maya+unsubscr...@googlegroups.com.
>>> To post to this group, send email to python_inside_maya@googlegroups.com
>>> .
>>> 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 python_inside_maya+unsubscr...@googlegroups.com.
> To post to this group, send email to python_inside_maya@googlegroups.com.
> 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 python_inside_maya+unsubscr...@googlegroups.com.
To post to this group, send email to python_inside_maya@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to