按名称查找对象

使用 ls() 命令按名称查找对象:

freds = cmds.ls("fred") 
#finds all objects in the scene named exactly 'fred', ie [u'fred', u'|group1|fred']

使用*作为通配符:

freds = cmds.ls("fred*")
# finds all objects whose name starts with 'fred'
# [u'fred', u'frederick', u'fred2']

has_fred = cmds.ls("*fred*")
# [u'fred', u'alfred', u'fredericka']

ls() 接受多个过滤字符串参数:

cmds.ls("fred", "barney") 
# [u'fred', u'|group1|barney']

它也可以接受一个可迭代的参数:

look_for = ['fred', 'barney']
# cmds.ls(look_for)
# [u'fred', u'|group1|barney']