PDA

View Full Version : blend material mix control


godblessbotox
08-22-2007, 10:18 PM
hello again scripting world.

im attempting to control a blend material with a small script.

but it cannot be a global change it can only operate on objects with a certin name, which i think i understand. its the mixing that is not working. i have spent most of the morning looking into the max script reference to try to get this done and made a little test at the end to see if the script is indeed compeleting but i never have an altered mix ammount. please help :)


for n in shapes do
(
if matchPattern n.name pattern:"neon" do
(
if hasProperty n "blend" do
(
n.mixAmount = 100
)

)
messageBox "finish"
format "_t= %\n" _t
)

magicm
08-22-2007, 10:30 PM
for n in shapes do
(
-- use wildcards to match any object containing the word "neon"
if matchPattern n.name pattern:"*neon*" then
(
-- check if the object as a blend material applied to it
if classOf n.material == blend then
(
-- set the mix amount of the blend material
n.material.mixAmount = 100
)
)
)

This code doesn't check whether the material has been applied to other objects other than the ones having "neon" in its name, so you'll either have to make sure these objects have unique materials, or implement an extra check in the script.

Hope this helps,
Martijn

godblessbotox
08-22-2007, 10:38 PM
yep, that works. fantastic!

what are the * signs for in the name? is that a required part of matchpattern?

PiXeL_MoNKeY
08-22-2007, 10:43 PM
Those are wildcards without them it will only match the string "neon". With "*neon" it would match "neon" or "red_neon", but not "neon_red". With "neon*" it would match "neon" or "neon_red", but not "red_neon". With "*neon*" it will match any string containing the string "neon".

-Eric

magicm
08-22-2007, 10:44 PM
what are the * signs for in the name? is that a required part of matchpattern?
It's just like how the old dir command in dos works. * stands for "any number of characters" and ? stands for "any single character".

So "*neon*" translates to a string which starts with any number of characters, contains the word "neon", and ends with any number of characters. So, using just "neon" as the pattern in the matchPattern function would only return nodes named "neon", and not those named "neon01", "neon02", etc.

Hope this clears it up,
Martijn

CGTalk Moderation
08-22-2007, 10:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.