Apply random material to element
Hi,
I found on this forum the following script that works very well when applying a random amount of materials to selected objects
Now if I have a single mesh with many sub objects in it (cubes for example) that each can be selected with the mesh / element selection, how shall I modify the script to make it apply the random materials to the elements of the mesh?
I presume the "obj" should be swtiched to become refering to the element instead?
Script:
for obj in selection do obj.material = meditMaterials[random 1 4]
thanks
Comments
It works thanks so much :)
It works thanks so much :)
I might be missing something
I might be missing something obvious but why not just use the MaterialByElement modifier?
Some of my scripts and MCGs :: 3ds Max SDK Intro for Scripters
Yep. For E-Mesh objects are
Yep. For E-Mesh objects are better to use the MaterialByElement modifier
bga
:) I know.
Then try this fn. NOTE: Works only with E-Poly object without assigned modifiers.
Mesh objects are calculates slower because num of triangle faces.
bga
Thanks Barygazy, very
Thanks Barygazy, very usefull...
One problem is that the max's random function don't "really" return random value.
Is there a way to make more random values ?
Thanks.
Try with this:
Tools and Scripts for Autodesk 3dsMax
hello miauu, I don't
hello miauu,
I don't understand what "seed (timestamp())" is used to ?
Open the maxscreipt help file
Open the maxscreipt help file and search for:
Mathematical Operations
Then read at the bottom of the page:
For reasons beyond the scope of this tutorial, the random command will generate the same "random" numbers each time a script is run. This happens if you restart the software and run the script, but not if you run the script over and over. If you want the values created by the random function to change each time you start the software, you can use the seed command:
seed where is any float or integer. Each time you change the seed value, MAXScript generates a new set of "random" numbers.
About timestamp()
The function returns the number of milliseconds since 00:00 hours that day. This is useful for timing operations (presuming you are not timing across midnight.)
So, using
seed timestamp()
you will have unique seed values every time when you wants to generates random values.Tools and Scripts for Autodesk 3dsMax
oooookkkkkeeeyy Thanks for
oooookkkkkeeeyy
Thanks for explanation miauu. The seed wasn't obvious, and I didn't found it in maxscript help...
But in result I don't find that random fn give a "real" randomization,...
cheers
For "seed" look in "Array
For "seed" look in "Array Value" topic in mxsHelp
bga