Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Executing Python scripts from the command line

7 REPLIES 7
Reply
Message 1 of 8
hannahchu.cs98g
850 Views, 7 Replies

Executing Python scripts from the command line

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!

Tags (2)
7 REPLIES 7
Message 2 of 8

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!
Message 3 of 8
akira.kudo
in reply to: milesmajefski

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


Message 4 of 8
a3dcreator
in reply to: akira.kudo

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!

Message 5 of 8
drew.avis
in reply to: a3dcreator

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
Message 6 of 8
milesmajefski
in reply to: drew.avis

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.
Message 7 of 8
drew.avis
in reply to: milesmajefski

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
Message 8 of 8
1032951826
in reply to: drew.avis

That is to say,i can only execute *.py in Max?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report