I was a bit confused about what you wanted to do. to get all meshes or just the top level meshes. here is some pymel examples you can sift through pretty easily in a single line for either
import pymel.core as pm # GET ALL MESHES IN A SCENE allMeshes = [x.getParent() for x in pm.ls(type="mesh")] # GET ONLY TOP LEVEL MESHES topMostMeshes = [top for top in [x.getParent() for x in pm.ls(type="mesh") ] if not top.getParent()] hope this helps On Thu, Aug 30, 2012 at 2:33 PM, Justin Israel <justinisr...@gmail.com>wrote: > Do you mean you just want to get the parent of each item from your ls > command? > You can pass the geometry results from the ls -> listRelatives > > cmds.listRelatives(cmds.ls(geometry=True, l=True), parent=True, f=True) > > That should return the parent of each item from the ls command. > > > > On Thu, Aug 30, 2012 at 2:13 PM, GWinters <glenn.j.wint...@gmail.com> > wrote: > > Hi everyone! > > Im starting to write scripts in python within maya and Im running into an > > issue. Im trying to get the list to select the top dependency node of all > > geometry in the scene. I get this list by having the list focus on the > > transforms but that is also pulling in transforms in on the cameras and > > lights. I want it to run execute similarly to selecting geometry in > > outliner and duplicating it. As of right now I have a list of all the > > geometry > > > > allMeshes2 = cmds.ls(geometry=True) > > > > Then in the for loop I have a pickWalk before duplicating it. > > cmds.pickWalk(direction= "up") > > > > Is there anyway to just have the ls select that object from the outliner? > > Thanks! > > > > Glenn > > > > -- > > view archives: http://groups.google.com/group/python_inside_maya > > change your subscription settings: > > http://groups.google.com/group/python_inside_maya/subscribe > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe > -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe