nested reference have been a real nitemare for me..
I've been working on and off on an importer for all references. and I haven't found a way to list ALL references when they are nested. only the top nodes..
so. if you want to import. and also load.. you could try this:
all_ref_paths = cmds.file(q=True, reference=True) or [] # Get a list of all top-level references in the scene.
for ref_path in all_ref_paths:
print(ref_path)
isLoaded = cmds.referenceQuery(ref_path, isLoaded=True)
print(isLoaded)
if cmds.referenceQuery(ref_path, isLoaded=True) == True: # Only import it if it's
print (ref_path)
cmds.file(ref_path, importReference=True) #import the reference
new_ref_paths = cmds.file(q=True, reference=True) # If the reference had any nested references they will now become top-level references, so recollect them.
if new_ref_paths:
for new_ref_path in new_ref_paths:
if new_ref_path not in all_ref_paths: # Only add on ones that we don't already have.
all_ref_paths.append(new_ref_path)
else:
cmds.file(ref_path, loadReference=True) # Load the reference
but I'm assuming you want to keep the refs in tact.
Normally I never ever work with nested references... as they've almost always caused naming issues.
(just running into a system where the artists are using nested references right now , and trying to fix it all)
hth
-=s