Check if your extension module was built and linked against a different version of Python. In order to use a CPython module with Python in 3ds Max, you must compile the CPython binaries against Python version 2.7.15. See Python extension libraries for more information.
Update the registry or manually install the module. Often modules support installation via manual steps or a Python module (for example, the Python "easy_install" module (http://pythonhosted.org/distribute/easy_install.html). See also Python extension libraries for more information.
In Python, if you misspell a property when assigning it, a new field is added to the object as a result - for example: MyClass.fOotball = x, or worse yet: MyClass.GetValue = 42. It is legal to add or replace fields on an object at run-time; therefore no error occurs. The safest way to set a property is to use a Set function, for example: render.SetWidth(640).
When you run any Python code that affects the global environment (for example, importing a module), those settings persist during your session of 3ds Max. A common mistake is to rely on a module that was imported by another script, or to call a function that was created by another script.
Use the reload(MyLibraryModule) command to force Python to reload that module.
When sys.exit() is used to exit Python, it raises a SystemExit exception. If an uncaught exception is raised in Python, it is reported to the MAXScript Listener window as an error, even though no error actually occurred. To avoid having an error being reported in the MAXScript Listener window by sys.exit(), you can use the try and except statements as follows: try: import sys print 'goodbye world' sys.exit() # Safe way to leave program at any point and allow objects and resources to be cleaned up. # Prevent 3ds Max from reporting a system exit as an error in the listener. except SystemExit: pass
When creating an instance of QApplication(), do not use app = QApplication([]), use instead:
app = PySide2.QtCore.QCoreApplication.instance() if not app: ...
to avoid a potential crash.
Note Troubleshooting tips for PySide2 also apply to PyQt.
In order to capture keyboard input for your Qt windows, you must disable the 3ds Max keyboard accelerators by calling the following when your UI control gets focus:
You can optionally call the following when your UI control loses focus as well:
There are several areas of 3ds Max that calls enableAccelerators. For more information, see the MAXScript Documentation.
The sys.path does not contain the executing script path. This is by design. To get the path of the currently executing script, use the __file__ constant. Note that this variable is only populated when scripts are run from the Scripting > Run Script menu, and is empty when scripts are run from the MAXScript editor.