Notifications
Clear all

[Closed] How to write max script loading .prt file

Hello all:
This is the first time to write script. I would like to write a max script what could
create krakatoa PrtLoader and load the cache files.For example, i have cache
files at D: est\cache\particles_####.prt,when i run the script that could create
PrtLoader and load the cache files.

       I wrote down this:
     
       startObjectCreation KrakatoaPRTLoader;
       F=KrakatoaPrtLoader;
       F iconSize:20 pos:[0,0,0]
       F isSelected:on
       max modify mode
       F fileList:"D:	est\cache\particles_.prt" <<---that is problem

       I can't figure out how to write down for loading cache files.
       Could anyone help me??
       Thank you all for watching and help :cry:
7 Replies

what’s the error message?
do you use double slash in your path string?


F fileList:"D:	est\cache\particles_.prt"

try with:


F fileList:"D:\	est\\cache\\particles_.prt"

Thank you so much for help, stigatle.

I tried the code you suggested, but it doesn’t work.

The error shows:Type error: array parameter assignment requires Array, got:
“D: est\cache\particles_.prt”

 lo1
F fileList:(getFiles "D:\	est\\cache\\particles_*.prt")

Ya~it works~!
Thank you so much, lo.
Thank you all for help~!
I have another question,when i load the cache files,but the was no particle appear.
I found there had a lot of cache files and i click one of them,there had error message:
– Error occurred in i loop; filename: C:\Program Files (x86)\Thinkbox\Krakatoa\Scripts\KrakatoaPRTLoader.ms; position: 21536; line: 454
How should i do to fix that?
Thank you all again for help.

Hello all:

       I found the problem about the my last reply because i didn't write down the 
       ".fileListFlags",but i wrote down this:
         KrakatoaPRTLoader fileListFlags:([ 3 ]   
        "D:\	est\\cache\\particles_*.prt")

        there was error:-- Syntax error: at <index>, expected <factor>
                              --  In line: KrakatoaPRTLoader fileListFlags:([ 3 ]   "   

      I don't know how to write correct.
      Could anyone help me again?
      Thank you for watching and help.

To help with the awkward way to deal with backslashes in strings, they introduced a new way to define paths a couple of versions back.

When defining paths, you can put a @ before the string and it will be much less pain than having to put double back slashes all through your code. I even use them when using filterstring on paths

thePath = @"c:	emp	heFile.bmp"
   filteredPath = filterstring thePath @"\"

I couldn’t see that anyone explained why you needed double slashes so I’ll give it a go.
The backslash in a string is an escape character. It can be used for things like telling it to make a new line with
or add tab spacing with .
evaluate this line to get an idea.

format "hey
	buddy
"

So when you have a single backslash in a path or string, it’s looking for an instruction next and not recognizing the backslash as part of the string. So the old way to deal with paths is to add a double backslash. It’s awkward and annoying. Especially if you’re grabbing paths from dialogs and you have to then convert them to either forwardslashes or double backslashes.

Hope this helps you understand it all a bit more.

Cg.

Thank you so much,3rd Dimentia!
I tried several way to figure out the problem,but it still didn’t work.
Your answer gives to me another way of thinking,i’ll keep trying.
Thank you all for help again!