Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] I need help! => Topic started by: ichinozori on 2024-06-02, 10:14:03

Title: [Help] How to make Auto Config Reflection 0 and Scale 0 for all Materials
Post by: ichinozori on 2024-06-02, 10:14:03
Hello everyone, I first want to thank several people who have helped me overcome the problems I experienced in the post I published previously.

Now I want something that can minimize processing time, namely automatically arranging all materials in the "Reflection" and "Scale" sections in the material editor menu.
I have previously tried asking ChatGPT but every script provided always does not work as I expected, below I have attached the detailed section marked in red for the settings I want to make which can change automatically as I expected from "1.0" to "0.0"(https://i.ibb.co.com/RPXPgFJ/howto.png)

and this is script that ChatGPT wrote to me
Quote
allMaterials = getClassInstances PhysicalMaterial

if allMaterials.count > 0 then
(
    for mat in allMaterials do
    (
        if mat.hasProperty #reflectivityMap then
            mat.reflectivityMap.amount = 0.0
       
        if mat.hasProperty #subsurfaceScattering then
            mat.subsurfaceScatteringScale = 0.0
    )
    format "All Physical Materials have been updated.\n"
)
else
(
    format "No Physical Materials found in the scene.\n"
)
Title: Re: [Help] How to make Auto Config Reflection 0 and Scale 0 for all Materials
Post by: James Vella on 2024-06-02, 10:55:02
If you want to do it scene wide use this:
Code: [Select]
for i in sceneMaterials do
(
    if ClassOf i == PhysicalMaterial then
    (
        i.reflectivity = 0.0
        i.sss_scale = 0.0
    )
)

Just for selected objects:
Code: [Select]
for obj in selection do
(
    if ClassOf obj.material == PhysicalMaterial then
    (
        obj.material.reflectivity = 0.0
        obj.material.sss_scale = 0.0
    )
)

or when dealing with materials inside a multisub (on selected objects) use this:
Code: [Select]
for obj in selection do
(
    for i in getClassInstances PhysicalMaterial target:obj do
    (
        i.reflectivity = 0.0
        i.sss_scale = 0.0
    )
)
Title: Re: [Help] How to make Auto Config Reflection 0 and Scale 0 for all Materials
Post by: clemens_at on 2024-06-02, 10:59:07
try this:
Code: [Select]
for mat in (allPhysMats = getClassInstances PhysicalMaterial) do
(
mat.reflectivity = 0.0
mat.sss_scale = 0.0
)

James beat me to it :P
I think he wanted to set the values to 0?
Title: Re: [Help] How to make Auto Config Reflection 0 and Scale 0 for all Materials
Post by: James Vella on 2024-06-02, 11:00:24
I think he wanted to set the values to 0?

Ah yes you are correct. Ive updated the snippets to reflect this.