3ds Max crushes with this script

Good day to all gurus here.
I have lots of experience with programming, but until recently I never needed Max, so I am new in Max scripting in particular. If this is too simple to work around - please excuse my incompetence, I am just trying out still.
Here is my problem: I want to import a series of altitudes from a file, that is formatted as coma delimited:

0.0,0.0,0.393701,1,0.0,0.278389,0.278389,1
0.19685,0.19685,0.278389,1,-0.278389,0.0,0.278389,2,-0.19685,-0.19685,0.278389,2
0.0,-0.278389,0.278389,2,0.19685,-0.19685,0.278389,2
0.278389,0.0,0.278389,2,0.19685,0.19685,0.278389,3 ,0.0,0.393701,0.0,3,-0.278389,0.278389,0.0,3,1,0.0,0.0,4
0.278388,-0.278389,0.0,5,0.0,-0.393701,0.0,5,0.278388,-0.278389,0.0,5
0.393701,0.0,0.0,5,0.278389,0.278388,0.0,5,0.0,0.2 78389,-0.278389,5,-0.19685,0.19685,-0.278389,5,-0.278389,0.0,-0.278389,5,-0.19685,-0.19685,-0.278389,5
0.0,-0.278389,-0.278389,5,0.19685,-0.19685,-0.278389,5,0.278389,0.0,-0.278389,5
0.19685,0.19685,-0.278389,5,0.0,0.0,-0.393701,5

where each line is a row of altitudes and each altitude is separated with the next by ",".
This is my test file.

I wrote a script as follows:

x0=0
y0=0
dX=0.1
dy=0.1

x=x0 as float
y=y0 as float
n=1
theShape = splineshape name:"imported"

fName = getOpenFileName caption:"Select a .csv file to import" filename:"*.csv" types:"csv|*.csv"
if fName != undefined then
(
addNewSpline theShape
addknot theShape 1 #smooth #line [x,y,0]
thefile = openFile fName mode:"r"
while not eof theFile do
(
theFileLine = readline theFile as stringstream
addNewSpline theShape
while not eof theFileLine do
(
z = readDelimitedString theFileLine "," as float
addKnot theShape n #smooth #line [x,y,z]
y=y+dY
)
x=x+dX
n=n+1
updateShape theShape
)
updateShape theShape
close theFile
close theShape
)

the first four lines are to fix the starting poin of the insertion, and the steps by X and Y.
When I start this script, by "Evaluate All", 3ds Max stops responding and even the debugger is blacking out. When I try to evaluate line by line, it gets stacked on line 21 - "while not eof theFileLine do".
Please help. I really tried out...

Comments

Comment viewing options

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

`

Hi,

"While" might be a problem

I use mostly dotnet to create array from file and than loop it with "for":

linesArr = (dotnetClass "System.IO.File").ReadAllLines filename

and then just loop it with "for... do....":

for l in linesArr do (
  --your code here
)

Best,
Pixamoon

Comment viewing options

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