ScriptSpot

Forum topic · General Scripting

do not load maps into viewport

By br0t · 2011-01-04

Description

Hey there,
I have a script that loads a bunch of materials from a materiallibrary and assigns them to different objects in the scene. It works well, but when there are huge maps inside the materials, I get some performance problems: Max will freeze after assigning the materials for several minutes. I am pretty sure that this happens, because it loads all maps to show them in the viewport. It does not happen with simple materials.
Is there any way to prevent that from happening? I tried to assign all materials in an

 with redraw off( )

context and I also tried to change all materials to

 material.showInViewport = false

but both did not help.
Any ideas?

Cheers

Comments (3)

br0t · 2011-01-05

hehe fighting with callbacks, that sounds funny :D Thanks for your effort Anubis! I tried it, but it does not seem to help reduce the "freezing" time. This is really weird, but maybe I'll just have to cope with it. The script is still quite a time saver, even if I have to wait a few minutes.
Regards

another idea

Anubis · 2011-01-08

Ok, another idea - update scene materials (MtlBrowser feature).
It's works well here and maybe worth to try it.

--quick target scene setup:
for obj in selection do obj.mat = standard name:(obj.name + "_mat")

and when load your .mat file and update:

Attachments

strange issue

Anubis · 2011-01-04

By default all new materials added to scene goes with showInViewport off, so this may come from some plugin. I have similar ugly problem (almost from 2 years) but with renderable shapes - my Max try (on every view port update) to turn on all of them and I fight with this with callbacks. Did you try something like...

fn turnMatOffInView = (
	(callbacks.notificationParam()).showInViewport = off
)
callbacks.removeScripts id:#matOff
callbacks.addScript #mtlRefAdded "turnMatOffInView()" id:#matOff