+ Reply to Thread
Results 1 to 6 of 6

Thread: Script for randomising SPLINE segment material ids

  1. #1
    Senior Member terribrown's Avatar
    Join Date
    Aug 2012
    Posts
    112

    Name
    Terri Brown
    Forum Username
    terribrown

    South Africa

    Default Script for randomising SPLINE segment material ids

    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.


    Thanks guys

  2. #2
    Senior Member
    Join Date
    Mar 2013
    Location
    Oslo
    Posts
    454

    Name
    Nicolai Bongard
    Forum Username
    nicolaibongard

    Norway

    Default Re: Script for randomising SPLINE segment material ids

    Ive not tried this, but a suggestion might be to select all the verteces, split them, then apply a material modifier to randomize by element as you would an editable poly, the add an edit spline modifer on top and weld all the verteces again?

  3. #3
    Senior Member sjmoir's Avatar
    Join Date
    Nov 2004
    Posts
    211

    Name
    Simon Moir
    Forum Username
    sjmoir

    United Kingdom

    Default Re: Script for randomising SPLINE segment material ids

    I think splines are tricky in Maxscript... You could use this script (edit: different to the one you tried, works for me in 2016) to randomly select segments and then assign IDs manually. Can you not do it in Railclone with the Random Node?
    Last edited by sjmoir; 1 Week Ago at 04:08 AM.

  4. #4
    Member
    Join Date
    Nov 2004
    Posts
    90

    Name
    Jon Seagull
    Forum Username
    jackbird

    United States

    Default Re: Script for randomising SPLINE segment material ids

    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).

    Code:
    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

  5. #5
    Senior Member terribrown's Avatar
    Join Date
    Aug 2012
    Posts
    112

    Name
    Terri Brown
    Forum Username
    terribrown

    South Africa

    Default Re: Script for randomising SPLINE segment material ids

    Thanks so much guys. I will definitely give that script a go Jon. Thanks too Simon (I downloaded the script), but I think Jon's script will be far more automatic.

  6. #6
    Senior Member sjmoir's Avatar
    Join Date
    Nov 2004
    Posts
    211

    Name
    Simon Moir
    Forum Username
    sjmoir

    United Kingdom

    Default Re: Script for randomising SPLINE segment material ids

    Works great... Thanks Jon.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 0
    Last Post: December 15th, 2016, 01:13 PM
  2. Freehand spline script
    By MazenSamir in forum 3ds Max
    Replies: 2
    Last Post: September 11th, 2015, 04:12 AM
  3. Replies: 4
    Last Post: May 9th, 2012, 07:29 PM
  4. Max script needed - draw spline beween 2 dummies
    By erniesbot in forum 3ds Max
    Replies: 14
    Last Post: August 12th, 2010, 03:22 AM
  5. Material Script
    By nisus in forum General Discussions
    Replies: 5
    Last Post: July 8th, 2002, 11:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts