[Closed] waiting so long ,can reduce the run time
cy1=cylinder radius:0.1 height:0.6 pos:[0,0.65,49.5]
cy2=copy cy1 pos:[0,-0.65,49.5]
for i=1 to 1070 do
(
copy cy1 pos:[i,0.65,49.5]
copy cy1 pos:[-i,0.65,49.5]
copy cy2 pos:[i,-0.65,49.5]
copy cy2 pos:[-i,-0.65,49.5]
)
when I run the code in max 8, I have to waiting for a little long time, is there has some simple method to do it ?
One big speed improvement would be two wrap your code with
disableSceneRedraw()
enableSceneRedraw()
That way your viewport doesn't have to update itself after every cylinder creation.
one easy way to speed things up a good bit is by naming the new objects yourself:
copy cy1 pos:[i,0.65,49.5] name:("cy1_copya_" + i as string)
copy cy1 pos:[-i,0.65,49.5] name:("cy1_copyb_" + i as string)
copy cy2 pos:[i,-0.65,49.5] name:("cy2_copya_" + i as string)
copy cy2 pos:[-i,-0.65,49.5] name:("cy2_copyb_" + i as string)
That should speed things up about five-fold (on my machine).
I also tried maxOps.cloneNodes, but because it’s so many repeat operations with so few objects, it actually ended up taking much longer. Might work better if you copied objects in chunks. E.g. copy 1 to 2, 2 to 4, 4 to 8, etc.
( for testing purposes, try including ‘if (keyboard.EscPressed) then ( throw “Esc pressed” )’ in the loop so you can easily exit a lengthy loop by hitting the Esc key )
thanks thatoneguy and ZeBoxx2
ZeBoxx2, your method is perfect it reduced the time from 55000 to 15266 milliseconds on my pc, but is there any methods to make it faster?
uh , I didn’t test your chunks way.