|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
|
I’m trying to write a rather more than simple for loop here.....
My frame range for example is (-50 1220)
Im wanting a function that does this ( for every 100 frames print “the batch number and the frame number”
the batch number corresponds to groups of 100 frames. The first 100 frames would be 1. The second group of 100 frames would be batch number 2.
examples: (batch# + “_” + frame#)
1_50
1_51
1_52
1_....
2_151
2_152
2_153
2_....
Max 4 - 2012
Nvidia Quadro FX 3500
Duel Intel(R) Xeon(R) CPU X5355 2.66GHz, 8Gb Ram, DX9.0c.
Windows 7 64bit Operating System
|
|
|
|
Kinda have something going here but not completely there yet.
loops = (ceil (150/100.0)) as integer
for i =1 to loops do (
for o = 1 to 100 do (
print (i as string+ "_" + o as string)
)
)
Max 4 - 2012
Nvidia Quadro FX 3500
Duel Intel(R) Xeon(R) CPU X5355 2.66GHz, 8Gb Ram, DX9.0c.
Windows 7 64bit Operating System
|
|
|
|
local firstFrame = 50
local lastFrame = 1220
local blockSize = 100
local loops = (ceil ((lastFrame-firstFrame+1)/blockSize)) as integer
local currentFrame;
for i = 1 to loops do (
for o = 0 to (blockSize-1) do (
currentFrame = (o + (i-1)*blockSize + firstFrame)
if (currentFrame <= lastFrame) then (
print (i as string + "_" + currentFrame as string)
)
)
)
Hope it will help.
-amarhys
Max 2011, Win7-Pro 64.
NVidia GeForce GTX 460
Core i7 950 3.06Ghz, 24Gb Ram.
|
|
|
|
Hey John,
You ask same question at ScriptSpot and I reply there,
but just in case will post my solution here too.
(
local sFrame = -50, eFrame = 1220
local seqSize = 100, itrNum = 0
local seqNum = 1, prefix = "1_"
local frmCount = eFrame - sFrame + 1
local strArray = #()
strArray[frmCount] = null
for i = sFrame to eFrame do (
itrNum += 1
strArray[itrNum] = prefix + i as string
if mod itrNum seqSize == 0 do (
seqNum += 1
prefix = seqNum as string + "_"
)
)
print strArray )
Hardly ever you need just to print strings,
so I store them to array for future use.
If hide/exclude print command,
the runtime is about 16 ms.
Cheers!
Max 9 through 2009, XP-Pro x64 SP2
ASUS EAH3450 Series (Driver 8.470).
Core 2 Duo E8400 3GHz, 4Gb Ram, DX9.0c.
|
|
|
|
count = 0
batch = "1" for i = -50 to 1220 do
(
count+=1
print (batch + "_" + i as string)
if count == 100 do
(
count = 0
batch = (batch as integer + 1) as string
)
)
why so complicated?
VFB+ : An enhanced 3dsmax frame buffer (free)
|
|
|
lo_ 06 October 2011 04:52 AM
why so complicated?
if you mean that mod() compared to zero’ing counter complicate the code?… then might be… not checked ;)
Max 9 through 2009, XP-Pro x64 SP2
ASUS EAH3450 Series (Driver 8.470).
Core 2 Duo E8400 3GHz, 4Gb Ram, DX9.0c.
|
|
|
|
|
sorry, I wasn’t talking about your code specifically, just saw a couple of pretty chunky blocks of code :)
But to be competitive, mine is 5ms without the ‘print’ :P
Author: lo_
|
| Replied: 06 October 2011 05:05 AM
|
|
|
|
|
|
Ok ;)
Maybe my Max is not so sensitive for benchmark because if the runtime is below 15 ms it returns 0 ms. So, if I hide print part (in your code), I get 0, but if at least supply “str = (batch + “_” + i as string)” inside the loop, I end with the same runtime (16 ms), but yep, I catch your idea, using mod() is an extra calculation, and w/o it logicaly s’d be a bit more faster.
Author: Anubis
|
| Replied: 06 October 2011 06:13 AM
|
|
|
|
|
Ok, I made 2 function, 1st based on your idea and 2nd on mine.
fn buildStrins range size delimiter:"_" = (
local sFrm = int(range.start), eFrm = int(range.end)
local queNum = 1, prefix = "1" + delimiter
local nCount = 0, sCount = 0, result = #()
result[eFrm - sFrm + 1] = null
for i = sFrm to eFrm do (
nCount += 1; sCount += 1
result[sCount] = prefix + i as string
if nCount == size do (
nCount = 0; queNum += 1
prefix = queNum as string + delimiter
)
)
result -- returns array
) test1 = buildStrins animationRange 20
test2 = buildStrins (interval -50 1220) 100
fn buildStrins2 range size delimiter:"_" = (
local sFrm = int(range.start), eFrm = int(range.end)
local queNum = 1, prefix = "1" + delimiter
local itrNum = 0, result = #()
result[eFrm - sFrm + 1] = null
for i = sFrm to eFrm do (
itrNum += 1
result[itrNum] = prefix + i as string
if mod itrNum size == 0 do (
queNum += 1
prefix = queNum as string + delimiter
)
)
result -- returns array
) test1 = buildStrins2 animationRange 20
test2 = buildStrins2 (interval -50 1220) 100
But as I get values 0 or 15 ms for both, I test them with more large range:
(
GC()
T1 = timeStamp()
a = buildStrins (interval -5000 5000) 100
format "F1: %\n" (timeStamp() - T1)
GC()
T2 = timeStamp()
a = buildStrins2 (interval -5000 5000) 100
format "F2: %\n" (timeStamp() - T2)
)
And the result is interesting…
In sequential run 4/5 of the tests they show equal speed,
but in 1/5 of the cases second function showns as 15% better.
Strange?… :)
Max 9 through 2009, XP-Pro x64 SP2
ASUS EAH3450 Series (Driver 8.470).
Core 2 Duo E8400 3GHz, 4Gb Ram, DX9.0c.
|
|
|
|
well, it’s such a negligible time anyways that I don’t see how it could possibly matter in any implementation unless we’re talking about numbers in the millions, which is not likely.
VFB+ : An enhanced 3dsmax frame buffer (free)
|
|
|
|
|
Yep, you’re right. I just was a bit curious after saw your code. At first look I like it, and the next test surprise me :)
Author: Anubis
|
| Replied: 06 October 2011 10:56 AM
|
|
|
|
|
Yeah this is essentially so I can loop through various controls of a morph target which has a limit of 100 but the animation could be over 100 frames so there posed the problem. I’m taking into consideration the code examples you’ve posted and things are working great. I’ll post what I have here when I’m complete to get your thoughts on things. I appreciate all the help and quick responses guys.
Thank you very much.
Max 4 - 2012
Nvidia Quadro FX 3500
Duel Intel(R) Xeon(R) CPU X5355 2.66GHz, 8Gb Ram, DX9.0c.
Windows 7 64bit Operating System
|
|
|
|