Jump to content

Script for randomising SPLINE segment material ids


Terri Brown
 Share

Recommended Posts

Hi guys,

 

I've got a Railclone system set up and I want to control objects placed on the spline by mat ids. Simple enough to do in RC itself, but the manual randomisation of the spline itself is what's getting to me. I have a complex spline with many many segments so it's taking time. Surely there must be a script out there to randomly assign mat ids to the segments of a spline. I looked on ScriptSpot but no luck. Downloaded spline-toolbox_v1.1 to just select random segments, but alas it works not.

 

I have RandomMatIds for POLYs but Splines...nudda.

 

Any suggestions? Or am I missing a button somewhere within max itself that does that?

13 years of using max and I don't know if there's that functionality. :eek:

 

 

Thanks guys

Link to comment
Share on other sites

This will randomize the material IDs on whatever shapes you currently have selected. Change the number in the first line of the script to set the number of material IDs.

 

This will work only on Editable Spline objects (not Lines or any other shapes).

 

highestMatID = 3 --change to set nmumber of random Material IDs to use
myShapes = for obj in selection where classof obj == SplineShape collect obj

for sh in myShapes do
(
for sp in 1 to (numsplines sh) do
(
	for sg in 1 to (numsegments sh sp) do
	(
		setMaterialID sh sp sg (random 1 highestMatID)
	)--end segment
)--end spline
)--end shape

Link to comment
Share on other sites

  • 11 months later...
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...