Activate checkboxes with materials inside, only

Hello guys,

i would really appreciate your help on this topic: i don't need any UI, just if possible 1 click button that should be small fix after material conversion from VrayBlend to fR-Layer material.
I use finalRender R3.5 engine and after materials conversion from VrayBlend to fR-Layer material, this is usual situation and you can see it in attachment. There are 9 layers but only few of them are filled with materials - 2 in this case, and the rest of them are empty. Since VrayBlendMtl does not have these checkboxes, I need small and fast script to check all fR-Layer materials in entire scene (Max 2012 and 2015) and activate only checkboxes for slots that have materials inside (layer 1 and layer 2 in this case), while checkboxes with "none" label on their slots should remain unchecked (layers 3-9). It would be perfect if this could work for fR-Layer materials in MultiSubs, also.
Just for your reference because i believe most of you don't have finalRender R3.5 installed, both checkboxes and material type slots are array type as you can see on attachment.

Maxscript listener for this attachment and layer 1 checkbox (that is turned off) shows:
meditMaterials[1].enableList[1] = off
Maxscript listener for this attachment and layer 3 material list slot (that is emtpy) shows:
meditMaterials[1].materialList[3] = undefined
Property name for fR-Layer material is:
fR_Layer

Thank you very much for your help.

AttachmentSize
fr-layer_rollout.png20.73 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

try this. it will affect all fR_layer materials in scene

for m in getClassInstances fR_Layer do (
    for i=1 to m.materialList.count where m.materialList[i] != undefined do (
        m.enableList[i] = true
    )
)

if you'are not sure how this fr_layer material class is named here's how to check it:

for c in material.classes do format "%\n" c
igamaximus's picture

Works perfectly!

Thank you once again Sergey, it works perfectly on entire scene!
Just please tell me, can you send me variant that would work on selected objects only? This way i would use both variants of the script, this one for entire scene and the other one for selected objects only, depending on the case...
Thank you!

jahman's picture

.

(
selectedNodes = selection as array
mtls = getClassInstances fR_Layer
 
    for mtl in mtls do (
 
	nodes = refs.dependentNodes mtl
 
	for node in nodes where findItem selectedNodes node > 0 do (
 
		for i=1 to m.materialList.count where m.materialList[i] != undefined do (
				m.enableList[i] = true
		)
	)
    )
)

or you can merge needed objects to an empty scene and merge them back later after processing

igamaximus's picture

Thank you Sergey

When i try with that code i get this message in attachemnt. Maybe it is not possible, and i can live with that, i will merge it in new scene as you told me. Thank you!

AttachmentSize
untitled.png 26.25 KB
jahman's picture

My bad. Change all m. to mtl.

My bad. Change all m. to mtl. and it will work

igamaximus's picture

Perfect!

Hey Sergey, I just changed all m. to mtl. and it's totally perfect mate! Thank you SO much for your knowledge and kindness! If i can help back with anything of my abilities, please let me know: www.tiny.cc/igorender

jahman's picture

.

Cool

igamaximus's picture

Thank you so much mate

I will try with your code tomorrow morning and let you know about the result.
Thanks again, i really appreciate your help.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.