Author Topic: [Help] How to make Auto Config Reflection 0 and Scale 0 for all Materials  (Read 905 times)

2024-06-02, 10:14:03

ichinozori

  • Users
  • *
  • Posts: 3
    • View Profile
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"

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"
)

2024-06-02, 10:55:02
Reply #1

James Vella

  • Active Users
  • **
  • Posts: 669
    • View Profile
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
    )
)
« Last Edit: 2024-06-02, 11:00:43 by James Vella »

2024-06-02, 10:59:07
Reply #2

clemens_at

  • Active Users
  • **
  • Posts: 150
    • View Profile
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?

2024-06-02, 11:00:24
Reply #3

James Vella

  • Active Users
  • **
  • Posts: 669
    • View Profile
I think he wanted to set the values to 0?

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