CSV import and visibility control

Hello
I imported coordinates from a CSV file and at every point I created a box. I want to control visibility by hiding one box at every frame. THe code I have so far is attached below. If this can not be done then I would love someone to direct me on how to import a point and create a box there at every keyframe until all points imported.
Thanks in advance

theFilename = getOpenFileName types:"Comma Separated Values (*.CSV)|*.CSV|All Files (*.*)|*.*"
if theFilename != undefined do ( --if a valid filename picked
    local theFile = openFile theFilename --open the file
    while not eof theFile do ( --loop until the end of file
	Box pos:(Point3 (readValue theFile) (readValue theFile) (readValue theFile))
    )
)
Select $box*
animationrange = interval 1 selection.count
!REG3XP1!>startTime = 0
endTime = selection.count
nthFrame = 1
 
for i in selection do
(
	for t in startTime to endTime by nthFrame do (
    animate on at time t (
		if i=t then
	i.visibility = False
    )
  )              
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

...

The import part looks fine, but the anim part...
First some notes - in the loop "for i in selection..." the "i" variable hold Node, while in second "for t ...", "t" hold TimeValue, so comparision like "i=t" has no sense :)
And the whole question is a bit unclear... You want to animate the visibility. If it in a time row like - box1 is invisible at time 0 and visible in time 1 and to the end of the animation, t.e. only 2 anim keys; next - 2nd obj (box2) is invisible as well and become visible at time 2, and so on, then...

arrBoxes = $box* as array -- created boxes
-- set the animation range
strTime = 0; endTime = arrBoxes.count
animationRange = interval 1 endTime
 
-- create vis.controller + add it to the 1st box
cntr = arrBoxes[1][1].controller = bezier_float()
 
-- add + setup 2 keys
addNewKey cntr 0; cntr.keys[1].value = 0 -- off
addNewKey cntr 1; cntr.keys[2].value = 1 -- on
 
-- in the loop by time index,
-- assign a Copy (not instance) of the vis.cntrl
-- to each box and just move it keys:
for i = 2 to endTime do
(
	c = arrBoxes[i][1].controller = copy cntr
	moveKeys c i
)

cheers!

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.