Ls is undoable, NOT queryable, and NOT editable. The ls command returns the names (and optionally the type names) of objects in the scene. The most common use of ls is to filter or match objects based on their name (using wildcards) or based on their type. Python for maya - creating joints. Offline / Send Message. Import maya.cmds as cmds for geo in cmds.ls(sl=True): pos = cmds.xform(geo, q=True, t=True, ws=True) cmds.select(clear=True) cmds.joint(p=pos) Also advice Ive had before was to use the average of verts for the object, but basically I want to create a joint at the pivot.
![Listrelatives maya Listrelatives maya](http://zurbrigg.com/images/training/beginning_python_for_maya_teaser.png)
ExampleMany ls queries are intended to find a single object, but ls always returns a list (or, in older Mayas, a single None). This creates complicated error checking for a simple question.The easiest way to get a single value from an ls under any circumstances is result = (cmds.ls('your query here') or None)0The or guarantees that at a minimum you'll get a list containing a single None so you can always index into it.Note that this style won't tell you if you've got more than one result - it just makes it safe to assume a single result.
Copyright © 2019 lesterbanks all rights reserved. Not any part of the site, techniques or tutorials of lesterbanks.com may be reproduced, transmitted, distributed or stored in any form by any means without written permission by lesterbanks. Copyright to all Products, Plugins, and Tutorials not written or created by lester banks belong to their respective owners. Everything else on this site is copyrighted by lesterbanks. You may not copy whole tutorials nor should you translate it to another language without written permission from lesterbanks.