There is not a way to do this with automation.
I looked through everything on the setup parameters and layerstack in the help files and there's no way I can see to do it.
I suspect the reason is that in the Stackup Editor, there is an order to how you add layers - dielectrics + conductor layers, and all the properties they have, and that it would be very complex to handle the task parametrically in an automation tool. And very easy to create an unworkable stackup without knowing it.
The automation you seek already exists in the Stackup Editor. I understand you want to do something else, but you may want to consider the effort of creating the automation software compared to the number of times the automation will run, and how much time it will really save you in the future. Unless the number of times used is very high, or the task particularly difficult and tedious, manual methods may be preferable.
I automated this for creating a new design from an external source. I used the stackup ".stk" file format and automated the reading that into .prj file.
There are caveats to deleting layers so I created a 2 layer template so that I only need to add layers.
You can automate it through the command line with the design closed and here is an example command line that removes layers:
C:\MentorGraphics\XPI_2.4_64\EEVX.2.4\SDD_HOME\common\win64\bin\importstk.exe -input <path>my.stk -prj <path>template.prj -map_layers "1,2,3,,,,,,,,,,,,,4,5"
To get the .stk file format open Stackup Editor and do a File>Export
The backdoor solution. Clever.
I do similar with many other configurations throughout the Mentor tools.