cmds.select question

27 views
Skip to first unread message

kiteh

unread,
Dec 19, 2018, 6:41:23 PM12/19/18
to Python Programming for Autodesk Maya
In my scene, there are the following joints:
  • testing:joint1_ent
  • testing:joint2
  • testing:joint3_ent
  • testing:joint4
  • testing:joint5
So I am trying to grab the 2 joints that ends with `_ent` and I used the following code:

If I wrote my `cmds.select` as:
cmds.select('*_ent')
cmds
.select('*_ent*')
It does not works and returns me `# ValueError: No object matches name: *_ent #` or `# ValueError: No object matches name: *_ent* # 

However, if I wrote it as `cmds.select('*:*_ent')`, only will these 2 joints be selected.

Additionally, I also tried to select by using the namespace..
# Does not works
cmds
.select('testing*') # ValueError: No object matches name: testing* #
#Works if I added in the colon
cmds
.select('testing:*')

If someone could kindly advise me, is this by design? I asked, because say, using the abive same 5 joints (but without the namespace), if I do a `cmds.select('joint*')`, it will returns me all the 5 joints. And hence my confusion here...



Eric Cunha

unread,
Dec 19, 2018, 7:10:10 PM12/19/18
to python_in...@googlegroups.com
This is by design, the select command operates on the root namespace unless another one is specified. You can read more here: http://download.autodesk.com/us/maya/2011help/CommandsPython/select.html

I usually get around this by just using ls, since there is a 'recursive' flag that searches all namespaces. 
So you could use this instead:
joints = cmds.ls('*_ent', r=1)
cmds.select(joints)

Hope that helps!


--
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e97fef96-c074-498e-a02d-13f7979c3be5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kiteh

unread,
Dec 20, 2018, 8:46:03 PM12/20/18
to Python Programming for Autodesk Maya
Got it, thanks.

I had thought that Maya iterates it by string and hence if I queried via the use of some strings of the namespace and it will works...
Reply all
Reply to author
Forward
0 new messages