View Full Version : maxscript help
jackburton 06-16-2003, 11:00 PM Writing my first maxscript at work so bear with me, this is probably a noob question. I'm writing a script to import a comma-delimited text file that contains X,Y,Z position values and creates a box(for now) at each point. Pretty simple, right? Problem is I'm trying to use the eof function to determine the imported file length, so I don't have to declare it everytime. The script works fine if I just declare how many lines the file has up front.
With eof the script returns this-
Unable to convert: eof() to type: Integer
So my questions are these- will eof find the end of a file if the file is made up of float values(like my file)? Am I even correct in assuming that's the problem? If eof doesn't work with float values, what's a good way to achieve this? Hope that's understandable. Thanks in advance, any help would be appreciated.
|
|
LFShade
06-16-2003, 11:29 PM
For starters, you can post MAXScript questions in the MAXScript forum (http://www.cgtalk.com/forumdisplay.php?forumid=98). This post will likely be moved when the moderators notice it, but for future reference...
How are you using eof()? Can we see, at least, the framework of your script so far? This sounds like a simple case of misunderstanding the use of the function. Typically eof() is used like this:
while not eof some_file do
(
...
)
RH
jackburton
06-16-2003, 11:45 PM
whoops, sorry about the forum thing, didn't see the maxscript
one. :shame:
Thanks for your reply, I may be misunderstanding it completely- this is my first real script.
Here's the part of the script I'm talking about
new_POS=#()
evac = "c://scxwork//substation1.txt"
posFile = openFile evac
for i = 1 to eof do(
new_line = readLine posFile
new_POS = filterString new_line","
POS_stuff = [(new_POS[1] as integer), (new_POS[2] as integer), (new_POS[3] as integer)]
box position:POS_stuff length:0.2 width:0.2 height:0.2
Perhaps while-do would work better? If I try it like this-
for i = 1 to eof(evac) do(
it returns-
- No ""eof"" function for "c://scxwork//substation1.txt"
Could it just be my file? hmmmm
LFShade
06-17-2003, 12:01 AM
Couple things -
1. eof() doesn't expect a path to a file, it expects the file object returned from openFile().
2. eof() returns either true or false. If you call it the way you propose, MAXScript is going to see for i = 1 to false do... - this doesn't make sense, and will break the script. You're better off with the while..do loop I showed you before.
Here's a quick rewrite of the snippet you posted:
evac = "c:\\scxwork\\substation1.txt"
posFile = openFile evac
while not eof posFile do
(
new_line = readLine posFile
new_POS = filterString new_line","
POS_stuff = [(new_POS[1] as integer), (new_POS[2] as integer), (new_POS[3] as integer)]
box position:POS_stuff length:0.2 width:0.2 height:0.2
)
Hope that makes it a bit clearer:)
RH
jackburton
06-17-2003, 12:19 AM
Aaah yes, thanks so much, I think I understand now:thumbsup:
I sure was using it wrong. Now off to build the rollouts!
CGTalk Moderation
01-15-2006, 10:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.