Example #1
0
    def pre_app_init(self):
        """
        Do any additional initialization before the apps are loaded. 
        """
        self.log_debug("%s: Initializing..." % self)

        # check max version
        max_major_version = mxs.maxVersion()[0]
        # 13000 means 2011, 14000 means 2012, etc.
        if max_major_version not in (13000, 14000, 15000, 16000):
            raise tank.TankError(
                "Unsupported version of 3ds Max! The engine only works with "
                "versions 2011, 2012, 2013* & 2014. (* Please see the engine "
                "documentation for more details regarding 2013)")
        elif max_major_version == 15000:
            # specifically for 2013 which is not officially supported but may work, output a warning:
            self.log_warning(
                "This version of 3ds Max is not officially supported by Toolkit and you may "
                "experience instability.  Please contact [email protected] "
                "if you do have any issues.")

        # set up a qt style sheet
        # note! - try to be smart about this and only run
        # the style setup once per session - it looks like
        # 3dsmax slows down if this is executed every engine restart.
        qt_app_obj = tank.platform.qt.QtCore.QCoreApplication.instance()
        curr_stylesheet = qt_app_obj.styleSheet()

        if "toolkit 3dsmax style extension" not in curr_stylesheet:

            self._initialize_dark_look_and_feel()

            # note! For some reason it looks like the widget background color isn't being set correctly
            # on 3dsmax top level items. In order to mitigate this, apply a style to set the background
            # color on the main app window area. The main app window area is typically a QWidget which
            # is a child of a QDialog (created by tk-core) with the name TankDialog. Based on this,
            # we can construct a style directive QDialog#TankDialog > QWidget which applies to the
            # immediate QWidget children only.
            curr_stylesheet += "\n\n /* toolkit 3dsmax style extension */ \n\n"
            curr_stylesheet += "\n\n QDialog#TankDialog > QWidget { background-color: #343434; }\n\n"
            qt_app_obj.setStyleSheet(curr_stylesheet)

        self._safe_dialogs = []

        engine = self

        class DialogEvents(tank.platform.qt.QtCore.QObject):
            def eventFilter(self, obj, event):
                # Remove from tracked dialogs
                if event.type() == tank.platform.qt.QtCore.QEvent.Close:
                    if obj in engine._safe_dialogs:
                        engine._safe_dialogs.remove(obj)

                return False

        self.dialogEvents = DialogEvents()
Example #2
0
    def pre_app_init(self):
        """
        Do any additional initialization before the apps are loaded. 
        """
        self.log_debug("%s: Initializing..." % self)         
        
        # check max version
        max_major_version = mxs.maxVersion()[0]
        # 13000 means 2011, 14000 means 2012, etc. 
        if max_major_version not in (13000, 14000, 15000, 16000):
            raise tank.TankError("Unsupported version of 3ds Max! The engine only works with "
                                 "versions 2011, 2012, 2013* & 2014. (* Please see the engine "
                                 "documentation for more details regarding 2013)")
        elif max_major_version == 15000:
            # specifically for 2013 which is not officially supported but may work, output a warning:
            self.log_warning("This version of 3ds Max is not officially supported by Toolkit and you may "
                             "experience instability.  Please contact [email protected] "
                             "if you do have any issues.")        
        
        # set up a qt style sheet
        # note! - try to be smart about this and only run
        # the style setup once per session - it looks like
        # 3dsmax slows down if this is executed every engine restart. 
        qt_app_obj = tank.platform.qt.QtCore.QCoreApplication.instance()
        curr_stylesheet = qt_app_obj.styleSheet()
        
        if "toolkit 3dsmax style extension" not in curr_stylesheet:

            self._initialize_dark_look_and_feel()
            
            # note! For some reason it looks like the widget background color isn't being set correctly
            # on 3dsmax top level items. In order to mitigate this, apply a style to set the background
            # color on the main app window area. The main app window area is typically a QWidget which 
            # is a child of a QDialog (created by tk-core) with the name TankDialog. Based on this, 
            # we can construct a style directive QDialog#TankDialog > QWidget which applies to the 
            # immediate QWidget children only.
            curr_stylesheet += "\n\n /* toolkit 3dsmax style extension */ \n\n"
            curr_stylesheet += "\n\n QDialog#TankDialog > QWidget { background-color: #343434; }\n\n"        
            qt_app_obj.setStyleSheet(curr_stylesheet)        
                
        self._safe_dialogs = []

        engine = self
        class DialogEvents(tank.platform.qt.QtCore.QObject):
            def eventFilter(self, obj, event):
                # Remove from tracked dialogs
                if event.type() == tank.platform.qt.QtCore.QEvent.Close:
                    if obj in engine._safe_dialogs: 
                        engine._safe_dialogs.remove(obj)

                return False;

        self.dialogEvents = DialogEvents()
	def id(self):
		"""
			\remarks	implements AbstractScene.softwareId to return a unique version/bits string information that will represent the exact
									version of the software being run.
			\return		<str>
		"""
		mversion 	= mxs.maxVersion()[0]/1000
		sixtyfour	= ''
		if ( mversion > 10 ):
			mversion = 2009 + (mversion-11)		# shifted to years at version 11
		if ( mxs.is64BitApplication() ):
			sixtyfour = '_64'
		return 'MAX%i%s' % (mversion,sixtyfour)
Example #4
0
    def id(self):
        """
			\remarks	implements AbstractScene.softwareId to return a unique version/bits string information that will represent the exact
									version of the software being run.
			\return		<str>
		"""
        mversion = mxs.maxVersion()[0] / 1000
        sixtyfour = ''
        if (mversion > 10):
            mversion = 2009 + (mversion - 11)  # shifted to years at version 11
        if (mxs.is64BitApplication()):
            sixtyfour = '_64'
        return 'MAX%i%s' % (mversion, sixtyfour)
Example #5
0
 def post_app_init(self):
     """
     Called when all apps have initialized
     """
     # set TANK_MENU_BG_LOCATION needed by the maxscript.  The gamma correction applied to the
     # background images seems to have changed for 2012 & 2013 and then reverted back for 2014
     # which is why there are two versions!
     max_major_version = mxs.maxVersion()[0]
     menu_bg_name = "menu_bg_light.png" if max_major_version in [14000, 15000] else "menu_bg.png"
     os.environ["TANK_MENU_BG_LOCATION"] = os.path.join(self.disk_location, "resources", menu_bg_name)
     
     # now execute the max script to create a menu bar
     menu_script = os.path.join(self.disk_location, "resources", "menu_bar.ms")
     mxs.fileIn(menu_script)
     
     # set up menu handler
     tk_3dsmax = self.import_module("tk_3dsmax")
     self._menu_generator = tk_3dsmax.MenuGenerator(self)
Example #6
0
    def post_app_init(self):
        """
        Called when all apps have initialized
        """

        # set TANK_MENU_BG_LOCATION needed by the maxscript.  The gamma correction applied to the
        # background images seems to have changed for 2012 & 2013 and then reverted back for 2014
        # which is why there are two versions!
        max_major_version = mxs.maxVersion()[0]
        menu_bg_name = "menu_bg_light.png" if max_major_version in [
            14000, 15000
        ] else "menu_bg.png"
        os.environ["TANK_MENU_BG_LOCATION"] = os.path.join(
            self.disk_location, "resources", menu_bg_name)

        # now execute the max script to create a menu bar
        menu_script = os.path.join(self.disk_location, "resources",
                                   "menu_bar.ms")
        mxs.fileIn(menu_script)

        # set up menu handler
        tk_3dsmax = self.import_module("tk_3dsmax")
        self._menu_generator = tk_3dsmax.MenuGenerator(self)

        # set up a qt style sheet
        # note! - try to be smart about this and only run
        # the style setup once per session - it looks like
        # 3dsmax slows down if this is executed every engine restart.
        qt_app_obj = tank.platform.qt.QtCore.QCoreApplication.instance()
        curr_stylesheet = qt_app_obj.styleSheet()

        if "toolkit 3dsmax style extension" not in curr_stylesheet:

            self._initialize_dark_look_and_feel()

            # note! For some reason it looks like the widget background color isn't being set correctly
            # on 3dsmax top level items. In order to mitigate this, apply a style to set the background
            # color on the main app window area. The main app window area is typically a QWidget which
            # is a child of a QDialog (created by tk-core) with the name TankDialog. Based on this,
            # we can construct a style directive QDialog#TankDialog > QWidget which applies to the
            # immediate QWidget children only.
            curr_stylesheet += "\n\n /* toolkit 3dsmax style extension */ \n\n"
            curr_stylesheet += "\n\n QDialog#TankDialog > QWidget { background-color: #343434; }\n\n"
            qt_app_obj.setStyleSheet(curr_stylesheet)
Example #7
0
    def init_engine(self):
        """
        constructor
        """
        self.log_debug("%s: Initializing..." % self)

        # check max version
        max_major_version = mxs.maxVersion()[0]
        # 13000 means 2011, 14000 means 2012, etc.
        if max_major_version not in (13000, 14000, 15000, 16000):
            raise tank.TankError(
                "Unsupported version of 3ds Max! The engine only works with "
                "versions 2011, 2012, 2013* & 2014. (* Please see the engine "
                "documentation for more details regarding 2013)")
        elif max_major_version == 15000:
            # specifically for 2013 which is not officially supported but may work, output a warning:
            self.log_warning(
                "This version of 3ds Max is not officially supported by Toolkit and you may "
                "experience instability.  Please contact [email protected] "
                "if you do have any issues.")
	def nameAndVersion( self ):
		version = mxs.maxVersion()
		jobTypeDic = {
				'5100' : "Max5",
				'6000':	 "Max6",
				'7000':	 "Max7",
				'8000':  "Max8",
				'9000':  "Max9",
				'10000': "Max10",
				'11000': "Max2009",
				'12000': "Max2010",
				'14000': "Max2012",
				'16000': "Max2014",
				'18000': "Max2016",
				'default': "Max2014"}
		if jobTypeDic.has_key(str(version[0])):
			jobType = jobTypeDic[str(version[0])]
		else:
			jobType = jobTypeDic['default']

		return jobType
Example #9
0
    def post_app_init(self):
        """
        Called when all apps have initialized
        """
        # set TANK_MENU_BG_LOCATION needed by the maxscript.  The gamma correction applied to the
        # background images seems to have changed for 2012 & 2013 and then reverted back for 2014
        # which is why there are two versions!
        max_major_version = mxs.maxVersion()[0]
        menu_bg_name = "menu_bg_light.png" if max_major_version in [
            14000, 15000
        ] else "menu_bg.png"
        os.environ["TANK_MENU_BG_LOCATION"] = os.path.join(
            self.disk_location, "resources", menu_bg_name)

        # now execute the max script to create a menu bar
        menu_script = os.path.join(self.disk_location, "resources",
                                   "menu_bar.ms")
        mxs.fileIn(menu_script)

        # set up menu handler
        tk_3dsmax = self.import_module("tk_3dsmax")
        self._menu_generator = tk_3dsmax.MenuGenerator(self)
Example #10
0
    def nameAndVersion(self):
        version = mxs.maxVersion()
        jobTypeDic = {
            '5100': "Max5",
            '6000': "Max6",
            '7000': "Max7",
            '8000': "Max8",
            '9000': "Max9",
            '10000': "Max10",
            '11000': "Max2009",
            '12000': "Max2010",
            '14000': "Max2012",
            '16000': "Max2014",
            '18000': "Max2016",
            'default': "Max2014"
        }
        if jobTypeDic.has_key(str(version[0])):
            jobType = jobTypeDic[str(version[0])]
        else:
            jobType = jobTypeDic['default']

        return jobType
Example #11
0
#

# initialize the Py3dsMax system
import os
import Py3dsMax
from Py3dsMax import mxs

# At some point in initialization  the install path is removed from the system path resulting in missing dlls when loading qt
# if it is installed in the max folder.
os.environ['path'] = ';'.join(
    (mxs.pathConfig.resolvePathSymbols('$max'), os.environ.get('path', '')))

Py3dsMax.__dict__['installPath'] = mxs.pathConfig.resolvePathSymbols(
    '$scripts\\python')

version = mxs.maxVersion()
if version:
    version = version[0]

# initialize the sys module
import sys
if version < 17000:
    # Max 2014 or older
    sys.argv = ['']
    sys.path.insert(0, Py3dsMax.installPath + r'\site-packages')
else:
    # Max 2015 or newer

    # Attempt to find the standard python install location and add it to sys.path
    registry = 'HKEY_LOCAL_MACHINE'
    key = r'SOFTWARE\Python\PythonCore\2.7\InstallPath'
	def version(self, major=True):
		version = mxs.maxVersion()
		if major:
			return int(version[0] / 1000)
		else:
			return '.'.join([unicode(token) for token in version])
Example #13
0
 def version(self, major=True):
     version = mxs.maxVersion()
     if major:
         return int(version[0] / 1000)
     else:
         return '.'.join([unicode(token) for token in version])