Skip to main content

Another funky maya quirk!

I'm trying to write a function that selects all top level objects that have a child object. In maya that's tricky. First we need to filter out top level objects

{obj for obj in ls(transforms=True) if obj.firstParent2()==None}

This works okay. But figuring out wether it has children is a tough call in maya, because: Group objects are transforms without shape nodesShape nodes are the first child of transform nodesHence when you check a node, you cannot simply ask how many childs it has. If you filter for nodes with one or more children, you're basically get all meshes, cameras, lights and so on. If you filter for two or more, you don't get groups with only one child. Anyhow you need a lot of filtering for what should be a really small issue.