ScriptSpot

Forum topic · General Scripting

Attach xref scenes from txt file?

By squeakybadger · 2017-04-25

Description

Hi all,

I'm trying to load a few xrefs from a text file (that will dynamically change content in the future)

This is my code, it seems to read the text file but throws up and error and doesn't attach anything:


xrefPath = "c:\\users\\jaime\\desktop\\x\\"
ext = ".max"

listArray = #() 
file = openFile "c:\\users\\jaime\\desktop\\x\\xrefs.txt" mode:"r"
while not eof file do
(
lineInfo = readLine file
append listArray lineInfo
)
close file

for i in listArray do
(
xrefs.addNewXrefFile (xrefPath + i + ext) i 
)

This is the error in the listener:


"c:\users\jaime\desktop\x\"
".max"
#()
<File:c:\users\jaime\desktop\x\xrefs.txt>
#("temp.max", "vbnv.max", "scriptest.max")
OK
-- Error occurred in i loop; filename: ; position: 314; line: 15
--  Frame:
--   i: "temp.max"
-- Runtime error: Unknown addNewXRefFile argument: "temp.max"

Any ideas on what's wrong?

Thanks.

Comments (1)

.

miauu · 2017-04-28

This:


"temp.max"

must be a full path to the file. Something like this:


"D:\\Projects\\temp.max"

So, in the text file you should have written the full paths to the files, not only the name of the files that you want to attach to the scene.