Notifications
Clear all

[Closed] Doscomnand and shellLaunch dont work with $max

i was trying to make work doscommand and shelllaunch with $max but al external aplication need to go the max path as a proper path.
is any way to get $max as a proper path string.

networkscript =”\\Massive\3dtech\Max 9\maxR9NetworkScripts_32bit”
maxpath =“C:\Program Files\Autodesk\3ds Max 9”

try (dosCommand (“xcopy “”+ networkscript +””” +” “+”””+maxpath+”””+” /s /y /D”)) catch()

this code i wil put on my stdscripts will copy all the latest script from the network to the computer keeping the computer always uodated with the latest scripts.

so instead of putting th emax path by hand and having to got max install equal in all the machines i was thinking to use $max but is any way to convert $max to a proper path as
“C:\Program Files\Autodesk\3ds Max 9”

and was wanted to do quick script to one max directory too because i always doing test and …

shellLaunch “explorer.exe” $max

but $max doesnt work.

Help will be much apreciated.

8 Replies

If you’re running Max 9 simply use .Net :

Environment = dotNetClass "System.Environment"
  maxPath = Environment.GetEnvironmentVariable "max"
  print maxPath

Now think .Net when developing for 3ds Max since version 9. It helps in many areas of MAXScript development.

You could use getdir with any of the following system/user paths:

#font | #Scene | #export | #import | #help | #expression | #preview | #image | #Sound | #plugcfg | #maxstart | #vpost | #drivers | #autoback | #matlib | #scripts | #startupScripts | #defaults | #renderPresets | #ui | #maxroot | #renderoutput | #animations | #archives | #Photometric | #renderassets | #userScripts | #userMacros | #userStartupScripts | #temp | #userIcons | #maxData | #downloads | #proxies

eg:
getdir #scripts

Escuse me Luis, $max isn’t a Windows environment variable but a Max symbolic pathname :D.

This code should work :

maxPath = getFilenamePath "$max"
shellLaunch "explorer.exe" maxPath

ypuech i was going to reply right know.

thanks to matt i did this code.


maxscriptspath = getdir #scripts
path_count= maxscriptspath.count
maxpath= substring  maxscriptspath 1 (path_count-7)
print maxpath
[code/]
 
your code works great two.
 
another question my code is working lovely know, and i put the ms in my plugin folder , this ms is coping any knew file inside a network  folder two my actual max and with this i got my script icons and .. updatted since the last second.
 
but i got a problem the first time the script copy the macros the dont evaluate and , the next time i will open them they are ok.
 
i was thniking ui/macro run after plugins and stdscripts but look that is not enough to be able to load them the first time are copied. i was thinking to evaluate the macro to be sure the got correct the first time they are copied.
 
i pu the .ms cal 0_copyscripts with the intention to be evaluated first. and copy everithing before anithing else happen.
 
did anyone got expirience doing a network update of scripts , icons , plugins....

I think this code is dangerous because #scripts can be changed by the user in the Customize > Configure Paths. But $max will always return the valid Max directory.

 PEN

You can run the scripts once they are installed in max. I do this with my .mzp installers. You will have to collect all the scripts that you have coppied and just run through them all and eval them using fileIn.

Also you don’t have to be using shelllaunch as Max Script can copy and paste files using copyFile.

Another thing that you should consider that is easier is to use a batch script. Replace every ones Max icons and short cuts with the batch file. Have the batch file copy all the scripts and then launch Max. You could also do this with Python or another language as well and make it more robust then a batch file. I did this sort of system using Perl some time ago and it worked very well. It used INI files to determine if a user should have certain scripts. So if I had scripts that were to be tested only the seniors on the production would get them.

There was some similar discussion here:
http://forums.cgsociety.org/showthread.php?f=98&t=396203

hi yupech im going for your version , just was posting my code i was doing befroe you posted.

Matt thanks for the link.

pen shel launch si only for my perosnal use. opening max .my actual script in doing a batch coping of files with msdos doscommand.

pen said

have the batch file copy all the scripts and then launch Max. You could also do this with Python or another language as well and make it more robust then a batch file. I did this sort of system using Perl some time ago and it worked very well. It used INI files to determine if a user should have certain scripts. So if I had scripts that were to be tested only the seniors on the production would get them.”

i was doing this with a ms file in the plugins folder but looks copied script dont get properly evaluated is a way to do maxscript to wait to read the ui scripts .
ut i got a problem the first time the script copy the macros the dont evaluate and , the next time i will open them they are ok.

i was thniking ui/macro run after plugins and stdscripts but look that is not enough to be able to load them the first time are copied. i was thinking to evaluate the macro to be sure the got correct the first time they are copied.