Search This Blog

Monday, October 7, 2013

Script to list all Python files and build a menu of them.

Louis Marcoux wrote this and is a handy little MaxScript that lists all python scripts in the default folder and creates a dropdown list menu with an execute button.

Please note there is no error trapping built in.

PythonFilesToMenu.ms

Tuesday, October 1, 2013

Launching Python QApplication multiple times

Just a quick note here, in Qt / PySide code many users are use to just running:

    app = QtGui.QApplication(sys.argv)

In MaxPlus the proper way (I say proper as modules stay loaded when ran in MaxPlus) is to always replace sys.argv with [] and to also first check for a QApplication.instance:

    app = QtGui.QApplication.instance()
    if not app:
        app = QtGui.QApplication([])

MaxPlus and module installers that look to the registry to find Python

Some modules (I.E. PySide) look to the Windows registry for the python location(s).  In order to use these apps you will need the registry keys.

I have setup a .reg file for the default 3ds Max 2014 folder install.  You can simply double click the .reg file to add the needed entries or edit it for the correct paths before using it.

I also wrote a python tool to set this up.

Registry File:

Python Script (to be ran in MaxPlus):
RegistrySetupForInstall.py
3dsmax2014ext.reg

MaxPlus and running PySide

The Python 2.7 release of PySide 1.2.0 was compiled against Python 2.7.5.  While generally point upgrades are compatible PySide compiled against Python 2.7.5 will not work with Python 2.7.3, which is the version of Python in MaxPlus.  We used the same Python build offered in Autodesk Maya and Autodesk Motion Builder instead of offering a different version.

In order to run PySide 1.2.0 with MaxPlus I had to recompile it against Python 2.7.3.  You can grab the build here:

This is a direct recompile, no source code changes.
PySide-1.2.0._Python2.7.3_win-amd64.exe

Wednesday, August 21, 2013

3ds Max 2014 Extension: Python and SSL connection hangs

While working on MaxPlus Python testers found a hang in SSL connections.  It turns out that there is a defect with OpenSSL and Python 2.7.3 that causes a long delay when using SSL operations.  I rebuilt OpenSSL against Python 2.7.3 and then rebuilding the Python 2.7.3 _ssl.pyd with the rebuilt OpenSSL fixes the issue.  There are no source code changes to OpenSSL or Python, just straight re-compiles.

To install unzip the three files into the <3dsmax root>\Python\DLLs folder.  You might want to rename the original _ssl.pyd to _ssl.pyd.bak.

Sample SSL test code:

import ssl
import time

timeStart = time.time()
print "[%s] Prepping ssl" % timeStart

ssl.RAND_status()
timeEnd = time.time()
print "[%s] Done prepping ssl" % timeEnd

timeTotal = timeEnd - timeStart
print 'Total Time: %.2f seconds' % timeTotal