In this case, CTRL+D on a pass would appear to work, but the pass wouldn’t show up in the explorer.
The problem turned out to be in the Duplicate options (the Hierarchy pref was set to None: hat tip to Chinny for spotting that). To duplicate passes, Hierarchy has to be set to Share Parent.
We confirmed this by looking at what was logged in the script history.
The problem is the 4th argument to Duplicate. That’s the Hierarchy argument, and 0 means siNoParent.
So the Duplicate command was creating a pass with no parent, so the new pass was just sort of “floating” around in the scene, until it was discarded during a save operation.
// Duplicate a pass but don't give it a parent var x = Duplicate("Passes.Default_Pass", null, 2, 0, 1, 0, 0, 1, 0, 1, null, null, null, null, null, null, null, null, null, null, 0); // It was created, but not placed in the pass list: LogMessage( x.Count ); LogMessage( x(0).FullName ); InspectObj( x(0) );