[Closed] 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)
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)
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.
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…
I’ve wrote up so functions that check for that. It seems like it will work great for this. Thanks for you help Bobo.