How to Unparent the object under DzRigidFollowNode and delete DzRigidFollowNode?

How to Unparent the object under DzRigidFollowNode and delete DzRigidFollowNode?
Delete all DzRigidFollowNode in the entire scene.
Thanks.
The following is the AI I asked, but it reported an error when running. I gave feedback and wrote it again, but it still reported an error.
// Daz Studio Script// Script to remove all Rigid Follow Nodes (often used for dForce rigid parts) from the scene(function(){ // Get the main scene object var oScene = Scene; var aNodesToRemove = []; // Array to store nodes marked for deletion print( "Starting search for Rigid Follow Nodes (DzRigidFollowNode)..." ); // --- Recursive function to find nodes anywhere in the scene hierarchy --- function findNodesRecursive( node, targetClass, nodesList ) { if (!node) return; // Safety check // Check the current node // inherits() is the reliable way to check the type, including derived classes if ( node.inherits( targetClass ) ) { print( "Found " + targetClass + " node: '" + node.getLabel() + "' (Internal Name: '" + node.getName() + "')" ); // Avoid adding duplicates if somehow visited twice (shouldn't happen with simple recursion) var alreadyListed = false; for( var k = 0; k < nodesList.length; k++ ){ if( nodesList[k] === node ){ alreadyListed = true; break; } } if( !alreadyListed ){ nodesList.push( node ); // Add to our list for removal } } // Recurse through children nodes var numChildren = node.getNumNodeChildren(); for( var i = 0; i < numChildren; i++ ) { var child = node.getNodeChild(i); if( child ) { findNodesRecursive( child, targetClass, nodesList ); // Recursive call } } } // Start the recursive search from the scene's root node // This ensures we find nodes no matter how deeply they are nested. var rootNode = oScene.getRootNode(); findNodesRecursive( rootNode, "DzRigidFollowNode", aNodesToRemove ); // Target class is now "DzRigidFollowNode" // --- Deletion Phase --- if( aNodesToRemove.length > 0 ){ print( "\nFound " + aNodesToRemove.length + " Rigid Follow Node(s) marked for removal." ); // Begin undo block - VERY IMPORTANT for safety and user experience UndoMgr.beginUndoGroup("Remove All Rigid Follow Nodes"); var removalCount = 0; for( var j = 0; j < aNodesToRemove.length; j++ ){ var nodeToRemove = aNodesToRemove[j]; // Double-check the node still exists in the scene before attempting removal // (It's good practice, though unlikely to be an issue here) if( nodeToRemove && oScene.findNodeIndex(nodeToRemove) != -1 ) { print( "Removing: '" + nodeToRemove.getLabel() + "'" ); // Remove the node from the scene if( oScene.removeNode( nodeToRemove ) ) { removalCount++; } else { print(" >> Failed to remove node: " + nodeToRemove.getLabel()); } // 'nodeToRemove' variable now points to a potentially deleted object. Don't use it further. } else { print( "Skipping node (already removed or invalid): " + (nodeToRemove ? nodeToRemove.getLabel() : "Unknown") ); } } // End undo block UndoMgr.endUndoGroup(); print( "\nFinished removing Rigid Follow Nodes. Successfully removed " + removalCount + " node(s)." ); } else { print( "\nNo Rigid Follow Nodes (DzRigidFollowNode) found in the scene." ); }})(); // End of script function wrapper
Starting search for Rigid Follow Nodes (DzRigidFollowNode)...
Script Error: Line 45
TypeError: Result of expression 'oScene.getRootNode' [undefined] is not a function.
Stack Trace: ()@:45
Error executing script on line: 45
Script executed in 0 secs 1 msecs.


20250329-135233.png
289 x 60 - 5K
Comments
Check DzScene - http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/scene_dz - there is no method getRootNode(). AI invents stuff. Also, DzRigidFollowNode is not listed as an object http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/start . Nor does UndoMgr (UndoStack does exist, but one would usually use the glbals for beginUndo etc. http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/global ). There may well be other issues too, those were just the things I noticed. As I have said before, AI is fine if there are plenty of real scripts for it to geenalise from (though in that case you could just use one of the originals, with modification, assuming that was allowed) but it is very good at inventing stuff and leaving you with useless code. Don't trust the computer, the computer is not your friend.
Well, thank you.
How can I find the unparent function? I can't find it.
I searched the Documentation Center but couldn't find it.