In this case, a customer sent me a scene where Undo didn’t work. As soon as you opened the scene, nothing you did could be undone, and Undo wouldn’t start working again until you loaded some other scene.
I thought it might be something in the scene, so I deleted practically everything under the Scene_Root, but Undo still didn’t work. Then I noticed that the .scn file was still pretty big (18MB) so I poked around a bit more in the scene and found thousands and thousands of materials (14K of materials, to be exact).
There were over 13 thousand AutoCAD_Color_Index materials. Just opening the Material Manager took minutes, and deleting 13 thousand materials wasn’t as easy as you might think.
I first tried with the DeleteAllUnusedMaterials command, but that took so long that I figured that Softimage was hung and I killed it.
In the end, I deleted some manually (a hundred at a time) and then the rest with the Material Manager > Delete Unused Materials. But I could also have done it like this:
import time start = time.clock() import win32com.client oObj = win32com.client.Dispatch( "XSI.Collection" ) oObj.Items = 'Sources.Materials.DefaultLib.AutoCAD_Color_Index_*' print oObj.count # 13782 Application.SetValue("preferences.General.undo", 0, "") for mat in oObj: Application.DeleteObj(mat) Application.SetValue("preferences.General.undo", 50, "") end = time.clock() Application.LogMessage( round( end - start, 3) ) # INFO : 264.117
It is funny but I ended up with a same scene myself yesterday, had 6914 materials and undo was greyed out. I used your script, the only thing I added was to before deleting I wanted to make sure that material was not used. So I added a line for that before the deletion:
Thanks for the scripts !