improving script performance
this is more a general question, but if needed I can post the scripts that I'm talking about next:
I do have a script, that will look at each object in the scene that has a material, copy that material,give it the same name as the object and put that material into a library, which is saved as a file to disk. So for 470 textured objects in the scene I will get a material library containing 470 materials all named as the original objects.
The next script will load that material library and look at the scene: If the material name is the same as the name of an object in the scene, this material will be applied to that object. Ive written both scripts so that I can finalize my shaders and textures in one scene and then easily put those materials into already existing and animated scenes (with the same objects), that yet dont have any materials.
I currently have about 700 objects in the scene, so this script will have to check for corresponding names 470 x 700 = 329.000 times. This is kinda slow, but not thaaat slow. Ive build a progress bar to get a visual feedback of the progress, and it takes less than a minute on my computer to update the materials.
My problem is, after the progress is finished, Max freezes for about 5-10 minutes, not allowing me to do anything. Ive tried the "with redraw off" context, because I thought that could be an issue, but it didn't help. I guess I could improve the checking-progress (e.g. if object gets a material from library, exclude it from remaining search processes). But what does Max slow down so very much after all those materials were put back into the scene? I have the same issue on another script, that detaches all polygons of a model to separate objects. It also has a progress bar, and will freeze for 2-3 minutes after its done. Any ideas why?