ScriptSpot

Forum topic · General Scripting

Scripting double-sided material toggle? (Can I integrate it into the automapping script I have?)

By Stenrik · 2015-08-15

Description

Hi,

I have a script that auto-maps planes based on name:


(
    local img_path = "C:/Users/Username/Documents/filenameblahblah/"
    
    for p in $Plane* do (
        addModifier p (uvwMap())        -- remove these 2 lines if the planes
        convertToMesh p                 -- already have texture coordinates
        
        local num = substring p.name (p.name.count - 2) p.name.count
        local mat = standardMaterial()
            
        mat.diffuseMap = bitmapTexture filename:(img_path + "Diffuse" + num + ".png")
        mat.opacityMap = bitmapTexture filename:(img_path + "Alpha" + num + ".png")
	            
        p.material = mat
    )
)

However, this is only of use to me if both sides are mapped visibly. In other words, having "2-Sided" checked under "Shader Basic Parameters" in the material editor.
I'll need to do this with thousands of planes, so I'd really like to integrate "toggle all materials 2 sided" with this script if possible. A separate script would also do.

(By the way, my Maxscript Listener isn't working at all, but that's a question for another thread. Still getting in the way of me figuring this out.)

Many thanks,
~Sten

Comments (1)

Progress...

Stenrik · 2015-08-15

OK, so in the meantime I got Listener working, and found that "meditMaterials[22].twoSided = on" is what I needed. I put it on the last line and it seems to be working.

...Though with a mystery. When I use the eyedropper within the Material Editor to actually bring in one of my maps, the "2-sided" box is NOT checked. Even though it acts 2-sided.
I also realized that no matter which plane's material I bring into the editor, it always says that it is mapped with "Alpha001"/"Diffuse001" when it should in reality be something like "Alpha018"/"Diffuse018."

I'm having a hard time understanding how mapping planes with a script is different than doing everything through the material editor. I'd like to know more about the differences.