How to list all top nodes without the default ones?

I have this code:

import pymel.core as pm

pm.ls(assemblies=True)

This code lists all the top nodes, including the default ones, like persp, top, front, side etc.

Is there any command which skips the default ones, without explicitly writing it manually.

Funny, I was just doing something related to this.

Irritatingly enough, the pm.ls( defaultNodes = True ) does not actually include the cameras. So I just wrote it manually.

Hope someone got a clever solution for this :smiley:

Think I might be onto something here, it seems that any items a user has made will be a member of a layer, default or otherwise. So I got it working by running set intersection on all user made nodes, and top level dags in scene.

import pymel.core as pm

def layerMembers():
    """ List all items which are members of a layer. """
    # Get all layers, and make an empty list to store their members.
    layers = pm.lsThroughFilter('layersFilter') 
    members = list()
    
    for layer in layers:
        members += layer.listMembers()
        
    return members
    
print(set(layerMembers()) & set(pm.ls(assemblies=True)))
1 Like