Executing Python scripts from the command line

Executing Python scripts from the command line

Anonymous
Not applicable
1,656 Views
7 Replies
Message 1 of 8

Executing Python scripts from the command line

Anonymous
Not applicable

Hi,

       I'm trying to execute my python script from command lind.Inside the script I want to opne a max file and get some information.But I don't want to do that with : 3dsmax -U PythonHost demo.py Since it will show the print message inside MAXScript Listenser instead showing in the cmd console.

       Now I execute python script in cmd :

               python demo.py

 

       Inside demo.py I use MaxPlus.FileManager to open max file :

       MaxPlus.FileManager.Open("D:\test.max")

 

However when using MaxPlus.FileManager APIs will always cause "Unknown MaxPlus Exception",

Other MaxPlus APIs work just fine ,ex. MaxPlus.Application

 

Does anyone know what cause the exception?

and How to solve it?

 

Thank you so much!

0 Likes
1,657 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
I bet it is the string you are providing as the filename. Google 'python strings' and check if the string is correctly formed. Good Luck!
0 Likes
Message 3 of 8

akira.kudo
Alumni
Alumni

The code below works fine on my side.

 

<code_begin>

import MaxPlus

 

fm = MaxPlus.FileManager

fm.Open("C:/temp/test.max")

<code_end>

 

I hope this helps.





Akira Kudo

Developer Technical Services

Autodesk Developer Network


0 Likes
Message 4 of 8

a3dcreator
Advocate
Advocate

im having trouble even import MaxPlus library.

im using the python command line.

 

is there something i need to do to point python to this library? in my windows path variable or something??

 

or do i have to use a specific shell or editor?

 

or do i have have to cd into a driectory first before running the import command?

 

im using 3dsmax 2015

 

thanks!

0 Likes
Message 5 of 8

drew_avis
Autodesk
Autodesk

The MaxPlus Python library is designed to execute within an instance of Max.  You can't use it outside the Max environment, such as in a Python command line.



Drew Avis
Content Experience Designer
0 Likes
Message 6 of 8

Anonymous
Not applicable
Good catch on that one!
I am surprised that ANY of the MaxPlus modules (like MaxPlus.Application) work outside of Max, as the first post states.
0 Likes
Message 7 of 8

drew_avis
Autodesk
Autodesk

Yes it's interesting that it can import, I had to try it out to see for myself.  But most calls (including most MaxPlus.Application methods) just crash with an unknown exception.



Drew Avis
Content Experience Designer
0 Likes
Message 8 of 8

Anonymous
Not applicable
That is to say,i can only execute *.py in Max?
0 Likes