Notifications
Clear all

[Closed] Windows Environment Variables

Hi I am wondering if there is a way to use/store environment variables in maxscript

for instance
exportPath = “c:”

instead can I do something like this
exportPath = “%SystemDrive%”

I checked the help doc but only found stuff about maxes root.

I would appreciate any help.
Thanks in advance
Lost…

5 Replies

Hi,

Watch “How To … Access Windows System Data” in MAXScript reference and look at the getEnvironmentPaths() function for example of how to access environment variables.
It’s tricky but useful.

Thanks alot man I am new to this and the hour and half search I performed did not bare fruit I thank you!!

Lost…

If you are using max 9, you could use the maxscript .NET exposure to access system variables (which is really sweeet).

Chris J.

You’re right Chris. I had not thought of the use of the wondeful MAXScript .Net exposure.
It’s a really powerful new feature that any MAXScripter using 3ds max 9 should use!

Jonathan,

If you’re using max 9, you can try :

-- Creare Environment class (cannot create an object of this class)
-- This class does not have a constructor (it's a static class)
Environment = dotNetClass "System.Environment"

-- Get "%SystemDrive%" Environment Variable
SystemDrive = Environment.GetEnvironmentVariable "SystemDrive"

print SystemDrive

It’s as simply as that and looks better than the old code using does command, output to file using “>” etc.