Python relative importing max 2017 broken!

Python relative importing max 2017 broken!

JokerMartini23
Enthusiast Enthusiast
1,055 Views
2 Replies
Message 1 of 3

Python relative importing max 2017 broken!

JokerMartini23
Enthusiast
Enthusiast

Can someone help me out here, I'm completely baffled on why relative imports do NOT work in 3ds Max 2017 but they work in 3ds Max 2016 and 2015.

 

The below scripts work fine prior to 2017.

What did they change and what do i need to change to make them work again? This is an urgent issue, thank you.

 

importFail.jpg

0 Likes
1,056 Views
2 Replies
Replies (2)
Message 2 of 3

denis_grigor
Autodesk Support
Autodesk Support

Hi John,

 

This happens because your code is not in the path searched by Python.

 

For instance:

python_path.png

Having error [1], if you list the searched paths you will see where Python is looking for modules.

If you add the folder where your code resides [2], it will be found and loaded as expected [3].

 

Unfortunately, the __file__ global variable is not set upon script load, which makes hard to "auto-add filepath to system path", but if the location of your script is predetermined, there should be no problem in reading it from a config file.

 

This behavior is different  from previous 3ds Max version, because now Python integration is tighter, while before it was just a side pack (with all flexibility of a side pack).


Denis GRIGOR
Developer Technical Services
Autodesk Developer Network



0 Likes
Message 3 of 3

JokerMartini23
Enthusiast
Enthusiast

so how do i fix this?

0 Likes