Tech Tip Tuesday: Unload Selected References

I missed New Zealand’s Tuesday, but it’s still Tuesday elsewhere. This is just a way to unload references without going through the reference editor. Sometimes it can be annoying to try to find the right reference in a big long list in the editor, this will just unload whatever reference you have selected.

MEL:

for($each in `ls -sl`){
    if(`objExists $each`){
        if(`referenceQuery -isNodeReferenced $each`){
            string $refNode = `referenceQuery -referenceNode $each`;
            file -unloadReference $refNode;
        }
    }
}
Share Button
This entry was posted in Maya, MEL, Python, Tech Tip Tuesday. Bookmark the permalink.

One Response to Tech Tip Tuesday: Unload Selected References

  1. John says:

    This is a great little piece of code! I’m curious about how to remove the selected object completely, not just unload it. When I replace the -unloadReference flag with -removeReference it returns an error // Error: line 6: File not found.: cubeRefRN //
    any help is greatly appreciated!

Leave a Reply

Your email address will not be published. Required fields are marked *