Frame Range to sequence

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Display Modes
  04 April 2012
Frame Range to sequence

Is there an easy way to turn a given input sequence to an array of numbers.
Same way max's render frame range is handled in the edittext.

--user input
--"30,36,22 - 20,-3 - 2"

--result wanted
-- #(-3,-2-1,0,1,2,20,21,22,30,36)
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
  04 April 2012
Seems like having those negative values really makes things confusing.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
  04 April 2012
Originally Posted by JokerMartini: Seems like having those negative values really makes things confusing.


May I ask what you are trying to do?

EDIT:

Here is a possible solution for YOUR specific syntax (where the delimiter is " - " and not "-"):

fn getFramesArrayFromString theString = 
(
	theString = filterString (substituteString theString " - " "..") ","
	theFrames = for i in theString where not matchPattern i pattern:"*..*" collect i as integer
	for i in theString where matchPattern i pattern:"*..*" do 
	(
		local thePair = (for j in filterString i "." collect j as integer)
		local theStep = if thePair[1] > thePair[2] then -1 else 1
		for k = thePair[1] to thePair[2] by theStep do appendIfUnique theFrames k
	)
	sort theFrames 
)

getFramesArrayFromString "30,36,22 - 20,-3 - 2"
--> #(-3, -2, -1, 0, 1, 2, 20, 21, 22, 30, 36)
__________________
Bobo

Last edited by Bobo : 04 April 2012 at 02:27 AM.
 
  04 April 2012
I'm making an attribute holder with a multilistview that contains (these time intervalsl created by the user) inwhich controls the birth frames of a particle system.

The list view has an input field for the user to insert frame ranges or individual frames.

Check out that attached file. It's just the attribute side of it right now.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com

Last edited by JokerMartini : 04 April 2012 at 04:12 PM.
 
  04 April 2012
Originally Posted by JokerMartini: The list view has an input field for the user to insert frame ranges or individual frames.


In that case, the code I posted won't do in its current form - you will need to expand it to perform a significant amount of sanity checks, ensuring the user is not entering garbage...
__________________
Bobo
 
  04 April 2012
I've wrote up so functions that check for that. It seems like it will work great for this. Thanks for you help Bobo.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
  04 April 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:08 AM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.