Hello.
I’m doing an experiment where I have mostly generic python code and then some software specific commands in wrappers for each targeted 3d application that uses python scripting. I’m in a situation where I have to support many different applications and this first test is me just dipping my feet into trying a one-script approach for common workflow tasks. I already found some large annoyances like it seems every software has their own flavor of Python and need specially compiled versions of PIL, etc.
Anyways, the current way I have it set up is a series of nested try except blocks. If I’m in 3ds Max, the first try will fail on import maya.cmds and go to the except where I try import Py3dsMax which would succeed, etc. However, this is very ugly IMO. Any ideas of a better way to do this?
try:
import MayaWrapper as SoftwareWrapper
except:
try:
import MaxWrapper as SoftwareWrapper
except:
try:
import Cinema4DWrapper as SoftwareWrapper
except:
try:
import BlenderWrapper as SoftwareWrapper
except:
try:
import LightwaveWrapper as SoftwareWrapper
except:
try:
import HoudiniWrapper as SoftwareWrapper
except:
import FallbackWrapper as SoftwareWrapper