In need of some help with Name selection and random material script

Hey Guys, Im trying to write a script for work but I'm quite new to scripting. Wonder if anyone could help.

I'll try to keep this simple...

What we have is sets of 4 people, i.e. Sandy, Ben, Sue and Jerry. The next set would be Sandy01, Ben01, Sue01, Jerry01 and so forth. THEN For each person we have 4 material variations, so lets say Sandy could have ONE material from the materials named Sandy, Sandy01, Sandy02, Sandy04 and the same for the other people. We need a script to add a random material from the ones that are associated with the characters name. I hope that makes sense, I tried to keep it simple and clear.

I'm having trouble selecting all the objects using characters name (although i think im close) I then am stuck a little on how to select a random material from the ones in the material editor with the characters name.

I've attached the code so far (with comments on my thought process), if anyone is able to help it will be much appreciated.

AttachmentSize
NameDependantRandomMaterial.ms1.11 KB

Comments

Comment viewing options

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

Hey thankyou for reply and

Hey thankyou for reply and yeah that was it, thankyou :)

Graph's picture

( local sallyMats = #(mat1,

(
  local sallyMats = #(mat1, mat2, mat3)
  --or
  --local sallyMats = for mat in sceneMaterials where findString mat.name "sally" != 0 collect mat
 
  local sallys = #(sally1, sally2, sally3)
  --or
  --local sallys = $sally*
  --or 
  --local sallys = for o in geometry where findstring o.name "sally" != 0 collect o
 
  for sally in sallys do sally.material = sallyMats[random 1 sallyMats.count]
 
)

that about what ur looking for?
cant verify that everything works as im rendering but should

Raphael Steves

Comment viewing options

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