Notifications
Clear all

[Closed] Random string values?

You know how there is a field in the render panel for “Frames” instead of “Single” or “Active Time Segment”, where the user can enter arbitrary frames, like “1,1,10-15,24-40”… is there anyway of generating a random string value for rendPickupFrames? I’m wanting to set min and max values so as the script goes through the current timeline it grabs varied ranges of frames between those 2 pre-determined values. So for example we have a frame range of 200 frames. We have values of min=1, max=30, so in this generated string the minimum ranges of frames would be 1, while the maximum range would be something like 170-200.

Any ideas?

thanks

8 Replies

Sounds like a pretty straightforward string function, but I’m still trying to understand what you mean. Try this; This function prints out a string range at a random point between 1 and 200 for a random length between 1 to 30 (as I understand your explaination):

fn randomString = 
    (
    	minFr = 1  --mimimum frames
    	maxFr = 30 --maximum frames
    	animRange = 200
    	randomStart = random 1 animrange --random number between 1 and the animRange
    	while (randomStart+maxFr) > animrange do --make sure it's not beyond the animrange
    	(
    		randomStart = random 1 animrange 
    	)
    	
    	randomEnd = random randomStart (randomStart+maxFr) -- add the random range to get an endpoint
    	outputString = (randomStart as String) + "-" + (randomEnd as String)
    	print outputString 
    )
    
    randomString()
It outputs something like this: 
"163-192"

EDIT: By the way, why exactly are you doing this? Just intrigued!

Is it really that easy? LOL I guess if you know what you’re doing then it is. :)(I’m currently earning this coding stuff.)

I needed something like this for a project I’m working on where I want to get a time-lapsed growing effect of geometry. Instead of a smooth 200 frame render, I wanted to break it up into random frames ranges so it gives me that “jerky” movement that is typical of time lapsed plant growth. I’ll give it a go tonight and let ya know how it turned out.

thanks again!

Edit: just tried it and it’s doing what I expected; grabbing random frames between the min and max values. Is it possible to have it generate random ranges through the set frame range in one go?

example: 1-15,35-33,45-65,70-73,85-90,94,96-100 Once the values have been generated in the maxscript listener then I could just copy these values into the render settings. I even may go as far as have the script copy those frame ranges into the rendPickupFrames function so it automatically loads them into the render settings.

Anything’s possible with strings my friend, it just takes a little longer to work out how to do it!

What you’re after there is to set up a sequential range of random numbers, basically getting a new feed of random frames based off the last ones you generated. I’ll have a look at that one later today if you like (kinda ill and sleepy right now).

That would be uber sweet! thanks:)

Hey, just checked out your site! Damn, you’ve been busy! I’m still waiting for Sin City to come to these shores… Not until July!:sad:

I should have something for you by the end of the day.

Okay! I think this does what you need. Give it a whirl:

fn randomString = 
 (
 	outputString =""
 	minFr = 1  --mimimum frames
 	maxFr = 30 --maximum frames
 	animRange = 200
 	randomStart = random minFr maxFr --random number between min and maxfr
 	
 	minR = minFr  --setup copy values
 	maxR = maxFr 
 	while (randomStart+maxFr) < animrange do --make sure it's not beyond the animrange
 	(
 		randomStart = random minFr (minFr+maxFr)
 		   randomEnd = random randomStart (randomStart+maxFr) -- add the random range to get an endpoint
 		minFr = randomEnd --change the start of the next sequence to the end of the last
 		
 		append outputString ((randomStart as String) + "-" + (randomEnd as String)+", ") --do that funky append thing
 	)
 	outputString = substring outputString 1 ((outputString.count)-2) --cleanup the uncessary chars at the end
 	 print outputString 
 )
 	
  randomString()

Oh, and it outputs something like this:
“10-27, 42-48, 75-84, 102-118, 119-134, 152-167, 187-196”

I can’t remember if the random values are the same all the time, or if you need to seed the random generator. You can seed it, so it might be an idea to. Just use this:

seed <number>

Bloody brilliant is what that is! If I could send you beer through the interweb I would. Thanks a lot, I really appreciate it. I’m going to mess around with throwing the seed value in there tonight. I’ll let you know how it turns out.

No problem. Just keep making cool stuff and I’ll be happy. It also gives my brain a workout.