コード例 #1
0
    def findSet(self, name='', quiet=False):
        ''' finds the set with name
			Params:
				name: name of set
				quiet: suppress dialogs
			Returns: FBSet/False
		'''
        if not name:
            if not quiet:
                moBuLogger.errorDialog("No name arg passed.")
            return False

        # get all sets
        allSets = self.scene.Sets
        if not allSets:
            if not quiet:
                moBuLogger.infoDialog("No sets found in scene.")
            return False

        # check sets for name
        for _set in allSets:
            if name == _set.Name:
                return _set

        # not found
        if not quiet:
            moBuLogger.infoDialog("No set found with name '%s'" % name)
        return False
コード例 #2
0
	def findSet(self, name='', quiet=False):
		''' finds the set with name
			Params:
				name: name of set
				quiet: suppress dialogs
			Returns: FBSet/False
		'''
		if not name:
			if not quiet:
				moBuLogger.errorDialog("No name arg passed.")
			return False
			
		# get all sets
		allSets = self.scene.Sets
		if not allSets:
			if not quiet:
				moBuLogger.infoDialog("No sets found in scene.")
			return False

		# check sets for name
		for _set in allSets:
			if name == _set.Name:
				return _set
				
		# not found
		if not quiet:
			moBuLogger.infoDialog("No set found with name '%s'" % name)
		return False
コード例 #3
0
def KToolsCallbackSubMenu(control, event):
	# import module
	try:
		fp, pathname, description = imp.find_module(str(event.Name))
		menuModule = imp.load_module(str(event.Name), fp, pathname, description)
		menuModule.run()
	except ImportError:
		moBuLogger.errorDialog("Unable to load and run module: '%s'" % event.Name)
コード例 #4
0
def KToolsCallbackSubMenu(control, event):
    # import module
    try:
        fp, pathname, description = imp.find_module(str(event.Name))
        menuModule = imp.load_module(str(event.Name), fp, pathname,
                                     description)
        menuModule.run()
    except ImportError:
        moBuLogger.errorDialog("Unable to load and run module: '%s'" %
                               event.Name)
コード例 #5
0
		# add PyMoBu path
		pyMoBuVer = eval(pcsXMLcore.get('pyMoBuVer'))['%s' % version]
		sys.path.append('%s/python/moBu/site-packages/%s' % (gv.toolsLocation, pyMoBuVer))
				
		#--------------------------------------------
		# start debugging
		import common.diagnostic.wingdbstub #@UnusedImport
		
		#--------------------------------------------
		from common.diagnostic.pcsLogger import moBuLogger
		# do main import loop
		try:
			from moBu.core.sysGlobalMenu import MoBuToolsMenu
		except:
			moBuLogger.info(sys.exc_info())
			moBuLogger.errorDialog("Failed to import moBu and start ArtMonkey")
			print "Failed to import moBu. Error: "
			print sys.exc_info()
		
		#--------------------------------------------
		# start ArtMonkey Global menu
		try:
			MoBuToolsMenu().createTool()
		except:
			moBuLogger.error("Failed to create Art Monkey menu")
		
		#--------------------------------------------
		# report run from location
		def tempFunc():
			pass
		fileLocation = os.path.dirname(inspect.getsourcefile(tempFunc))
コード例 #6
0
	def replaceNamespaceOnChar(self, nSpace='', quiet=False):
		''' replace namespace on character or add if none
			Params:
				nSpace: namespace to add/replace with
				quiet: suppress message
			Returns: True/False
		'''
		
		success = True
		
		# get selected reference or find it
		selected = self.getSelected(_type='all', found=True)
		if not selected:
			# try to select
			selected = self.getReference(namespace='', pyMB=False)
			if not selected:
				# run again
				if not quiet:
					moBuLogger.errorDialog("Select a node from the character")
				else:
					moBuLogger.error("Select a node from the character")
				return False
		
		# get the FBSet associated with the character
		if isinstance(selected, FBSet):
			charSet = selected
		else:
			charSet = mbSets.findSetFromObject(pObject=selected, quiet=quiet)
		if not charSet:
			return False
	
		# iterate through all items in set		
		for item in charSet.Items:
			# check if already has namespaces
			currentNS = None
			if mbNamespace.getNamespace(node=item):
				for ns in mbNamespace.getNamespace(node=item):
					# do NOT replace '*_Template' Namespaces
					if not '_Template' in ns:
						currentNS = ns
						
						# check for replace or add
						if not mbNamespace.replaceNamespace(node=item, nsOrig=currentNS, nsReplace=nSpace, hier=False):
							moBuLogger.debug("Failed to replaceNamespace on: '%s'" % item.LongName)
							success = False
					else:	#_Template Namespace
						# check for existence of new nSpace
						if not nSpace in mbNamespace.getNamespace(node=item):
							# add
							if not mbNamespace.addNamespace(node=item, ns=nSpace, hier=False):
								moBuLogger.debug("Failed to addNamespace on: '%s'" % item.LongName)
								success = False
			else:
				if not mbNamespace.addNamespace(node=item, ns=nSpace, hier=False):
					moBuLogger.debug("Failed to addNamespace on: '%s'" % item.LongName)
					success = False
			
		# add nameSpace to set as well
		if not mbNamespace.addNamespace(node=charSet, ns=nSpace, hier=False):
			moBuLogger.debug("Failed to addNamespace on: '%s'" % charSet.LongName)
			# no need to report False, already getting added
		
		return success
コード例 #7
0
        pyMoBuVer = eval(pcsXMLcore.get('pyMoBuVer'))['%s' % version]
        sys.path.append('%s/python/moBu/site-packages/%s' %
                        (gv.toolsLocation, pyMoBuVer))

        #--------------------------------------------
        # start debugging
        import common.diagnostic.wingdbstub  #@UnusedImport

        #--------------------------------------------
        from common.diagnostic.pcsLogger import moBuLogger
        # do main import loop
        try:
            from moBu.core.sysGlobalMenu import MoBuToolsMenu
        except:
            moBuLogger.info(sys.exc_info())
            moBuLogger.errorDialog("Failed to import moBu and start ArtMonkey")
            print "Failed to import moBu. Error: "
            print sys.exc_info()

        #--------------------------------------------
        # start ArtMonkey Global menu
        try:
            MoBuToolsMenu().createTool()
        except:
            moBuLogger.error("Failed to create Art Monkey menu")

        #--------------------------------------------
        # report run from location
        def tempFunc():
            pass
コード例 #8
0
    def replaceNamespaceOnChar(self, nSpace='', quiet=False):
        ''' replace namespace on character or add if none
			Params:
				nSpace: namespace to add/replace with
				quiet: suppress message
			Returns: True/False
		'''

        success = True

        # get selected reference or find it
        selected = self.getSelected(_type='all', found=True)
        if not selected:
            # try to select
            selected = self.getReference(namespace='', pyMB=False)
            if not selected:
                # run again
                if not quiet:
                    moBuLogger.errorDialog("Select a node from the character")
                else:
                    moBuLogger.error("Select a node from the character")
                return False

        # get the FBSet associated with the character
        if isinstance(selected, FBSet):
            charSet = selected
        else:
            charSet = mbSets.findSetFromObject(pObject=selected, quiet=quiet)
        if not charSet:
            return False

        # iterate through all items in set
        for item in charSet.Items:
            # check if already has namespaces
            currentNS = None
            if mbNamespace.getNamespace(node=item):
                for ns in mbNamespace.getNamespace(node=item):
                    # do NOT replace '*_Template' Namespaces
                    if not '_Template' in ns:
                        currentNS = ns

                        # check for replace or add
                        if not mbNamespace.replaceNamespace(node=item,
                                                            nsOrig=currentNS,
                                                            nsReplace=nSpace,
                                                            hier=False):
                            moBuLogger.debug(
                                "Failed to replaceNamespace on: '%s'" %
                                item.LongName)
                            success = False
                    else:  #_Template Namespace
                        # check for existence of new nSpace
                        if not nSpace in mbNamespace.getNamespace(node=item):
                            # add
                            if not mbNamespace.addNamespace(
                                    node=item, ns=nSpace, hier=False):
                                moBuLogger.debug(
                                    "Failed to addNamespace on: '%s'" %
                                    item.LongName)
                                success = False
            else:
                if not mbNamespace.addNamespace(
                        node=item, ns=nSpace, hier=False):
                    moBuLogger.debug("Failed to addNamespace on: '%s'" %
                                     item.LongName)
                    success = False

        # add nameSpace to set as well
        if not mbNamespace.addNamespace(node=charSet, ns=nSpace, hier=False):
            moBuLogger.debug("Failed to addNamespace on: '%s'" %
                             charSet.LongName)
            # no need to report False, already getting added

        return success
コード例 #9
0
    def savePCSoptions(self, pathFile=None, quiet=True, pOptions=None, p4=True):
        """ saves with customFBFbxOptions
		Params:
			pathFile: complete file path to save
			quiet: suppress messages
			pOptions: pre-made options
			p4: markForAdd/checkout or not
		Returns: True/False
		"""

        text = "Saved with PCSoptions"

        # pick file if not passed
        if not pathFile:
            if not quiet:
                pathFile = self.openFileDialog(openSave="save")
            else:
                moBuLogger.error("No pathFile passed and quiet=True")
                return False
        if not pathFile:
            moBuLogger.info("Cancelled")
            return False

            # add extension if they didn't type it
        if not Path(pathFile).ext:
            pathFile = "%s.fbx" % pathFile

        # 		# checkout from perforce
        # 		if p4:
        # 			if self.pcsParseObj.isp4Active:
        # 				self.p4.fileName = pathFile
        # 				if self.p4.isP4Connected:
        # 					try:
        # 						self.p4.p4CheckOut(desc=text)
        ##					except P4.P4Exception:
        # 					except:
        # 						moBuLogger.warning("Failed to checkout: '%s'" % pathFile)
        # 			else:
        # 				if not quiet:
        # 					moBuLogger.warning('P4Active setting FALSE, not checking out.')
        # 		else:
        # 			if not quiet:
        # 				moBuLogger.warning("p4 arg passed as False, not checking out for file: '%s'." % pathFile)

        if not pOptions:
            pOptions = self.customFBFbxOptions(pLoad=False, saveAllTakes=True)

            # 2010 save process
        currentTakeObject = FBSystem().CurrentTake
        if self.mobuVer == 2010:
            lMgr = FBFbxManager()  # @UndefinedVariable
            lMgr.SaveBegin(str(pathFile))
            lMgr.Selected = True
            for strEach in lMgr.Takes:
                if strEach.Name != currentTakeObject.Name:
                    strEach.Import = False
            lMgr.EmbedMedia = False
            lMgr.BaseCameras = False
            lMgr.CameraSwitcherSettings = False
            lMgr.CurrentCameraSettings = False
            lMgr.GlobalLightingSettings = False
            lMgr.TransportSettings = False
            if not lMgr.Save():
                moBuLogger.errorDialog("There is a problem saving the file", "Cannot Save")
            if not lMgr.SaveEnd():
                moBuLogger.errorDialog("There is a problem saving the file", "Cannot Save")

                # 2012 save process
        elif self.mobuVer == 2012 or self.mobuVer == 2013 or self.mobuVer == 2014:
            alreadyExists = False
            if Path(pathFile).exists():
                alreadyExists = True
            if not self.app.FileSave(str(pathFile), pOptions):
                # cancelled?
                moBuLogger.warning("Cancelled")
                return False
            if not alreadyExists:
                # check to see if new file is there
                res = os.path.exists(str(pathFile))
                if res:
                    if not quiet:
                        moBuLogger.info("%s, '%s'" % (text, str(pathFile)))
                    return True
                else:
                    moBuLogger.errorDialog("Failed to save '%s'" % str(pathFile))
                    return False
            else:
                # TODO: check to see if different?
                if not quiet:
                    moBuLogger.info("%s, '%s'" % (text, str(pathFile)))
                return True