Notifications
Clear all

[Closed] dotNet in Maxscript directory issue

Hi,

I’m new to MaxScript but have been putting together a script from what I have been learning online.

I found this line which has allowed me to look for a .csv file and return the data inside.
adata = (dotnetClass "System.IO.File").ReadAllLines "Job_Log.csv"

The problem is this line looks for the .csv file in the location of the .ms script (Max root dir\scripts).

I want it to look and read it in the location of the .max file, as the .csv file’s information relates to that.

How can I change this line to look in the correct place please.

I’ve tried iterations of dotNet code found in the help pages, and also tried maxfilepath etc with no Luck.

I’m a beginner so its mostly guess work, hope someone with better knowledge is kind enough to help.

Thanks

6 Replies

Can’t see why maxFilePath wouldn’t work.
What kind of errors are you getting?

It’s strange, there was obviously a problem with the file I was testing it on.
Iv’e changed that and also re-insalled Max

So now this code looks in the correct folder (.max file folder location) and reads the .csv file.

However…

When I “run” the script it still looks in the “scripts” folder in the 3ds Max root folders and errors because it’s not there etc.

But if I have the same script from that location opened in script editor and I “evaluate all”, the script runs fine and works perfectly!

I just don’t understand it?

There should be no difference whether a script is being run via Evaluate All or Scripting > Run Script.
Just checked maxFilePath for the heck of it and as expected it works identically in both use cases.

Yeah, I don’t get it either (not that I know MaxScript very well).

How would you write that line then to include maxFilePath? because I tried it all the ways I could think of (again being new to this they probably didn’t make any sense).
Thanks for helping

pathconfig.appendPath maxFilePath  "yourfile.csv"

Thanks Serejah,

I tried it and got this error (– Argument count error: pathConfig_appendPath wanted 2, got 1)

I put your code in like this;

adata = (pathconfig.appendPath maxFilePath).ReadAllLines "Job_Log.csv"

Because I need it to read the .csv file and assign the contents to “adata” to be used in the script

putting it like this:

adata = pathconfig.appendPath maxFilePath “Job_Log.csv”

Didn’t return an error but did not work…