Announcement

Collapse
No announcement yet.

Maxscript Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maxscript Help

    I'm trying to get a Max scene to attach xrefs that are listed in a text file (so that file can change externally and the maxscript can be run to update everything)

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

    Code:
    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:

    Code:
    "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.

  • #2
    Hi, remove the last 'i' in the xrefs.addnewxreffile line. It's double and reads as a second argument which the function doesn't accept.
    Rens Heeren
    Generalist
    WEBSITE - IMDB - LINKEDIN - OSL SHADERS

    Comment


    • #3
      Hi Rens,

      That's cleaned up the error, but nothing gets attached in the xref scene dialog.

      Any ideas?

      Thanks.

      Comment


      • #4
        Is the listArray empty or has wrong filenames? You could try a print i in the for loop and see what it outputs. Other than that maybe the XRef window needs to be closed and reopened. You could also try a doesFileExist on the newly constructed filename.
        Rens Heeren
        Generalist
        WEBSITE - IMDB - LINKEDIN - OSL SHADERS

        Comment


        • #5
          I think you've made it more complicated than it needs to be....

          You don't need the ext variable at all... as in your text file you have them listed as "temp.max"

          Code:
          xrefPath = "c:\\users\\jaime\\desktop\\x\\"
           
          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)
          )
          Maxscript made easy....
          davewortley.wordpress.com
          Follow me here:
          facebook.com/MaxMadeEasy

          If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

          Comment

          Working...
          X