def openProjectFolder(self):
     if windows.optionMenu("projectOptionMenu", q = True, v = True)!="None":
         project_number = int(windows.optionMenu("projectOptionMenu", q = True, v = True).split(":")[0]) - 1
         _dir = self.projects[project_number].directory
         print(_dir)
         if (os.path.isdir(_dir)):
             call(["open", "-R", _dir])
         else:
             windows.confirmDialog(title = "Project Not Found", message = "The selected project folder cannot be found.", button=["Dismiss"])
 def saveFile(self, type=0):
     #So this function needs to look into the proper component folder (if it exists), find the Working folder (if it exists, if not make it)
     #Then save an iteration of this file.
     project = self.getSelectedProject()
     if project!="None":
         if windows.optionMenu("partOptionMenu", q=True, v=True)!="None":
             part_index = int(windows.optionMenu("partOptionMenu", q=True, v=True).split(":")[0]) - 1
             part_directory, part_name, part_numname = project.modelingComponents[part_index]
             if os.path.isdir(part_directory):
                 #part_name = project.modelingComponents[part_index][1]
                 
                 working_dir = os.path.join(part_directory, "Working")
                 publish_dir = os.path.join(part_directory, "Publish")
                 
                 if os.path.isdir(working_dir)==False:
                     os.makedirs(working_dir)
                 if os.path.isdir(publish_dir)==False:
                     os.makedirs(publish_dir)
                     
                 if type==0:
                     files = glob.glob(working_dir+"/*")
                     if len(files)>0:
                         highest_num=0
                         for file in files:
                             if os.path.isfile(file):
                                 filenum = int(file.split("/")[-1].split("_")[-1].split(".")[0])
                                 if filenum>highest_num:
                                     highest_num = filenum
                         else:
                             highest_num+=1
                             num = ("0"*max(0,3-len(str(highest_num)))+str(highest_num))
                             #if len(str(highest_num))==1:
                             #    num="00"+str(highest_num)
                             #if len(str(highest_num))==2:
                             #    num="0"+str(highest_num)
                             #if len(str(highest_num))==3:
                             #    num=str(highest_num)
                             print("Num: " + num)
                     else:
                         num = "001"
                     
                     if num=="001":
                         if windows.confirmDialog(title = "Save Part File?", message = "Save the first version of this part? You will not be prompted when saving new versions after this.", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                             file_name = os.path.join(working_dir , part_name + "_working_" + num + ".mb")
                             system.saveAs(file_name)
                     else:
                         file_name = os.path.join(working_dir , part_name + "_working_" + num + ".mb")
                         system.saveAs(file_name)
                         
                 elif type==1:
                     if windows.confirmDialog(title = "Publish File", message = "Publish this scene file?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                         file_name = os.path.join(publish_dir, part_name + "_publish.mb")
                         current_filename = system.sceneName()
                         system.saveAs(file_name)
                         system.saveAs(current_filename)
             else:
                 windows.confirmDialog(title = "Part Not Found", message = "The selected part folder cannot be found.", button=["Dismiss"])
Пример #3
0
 def openPartFolder(self):
     if windows.optionMenu("projectOptionMenu", q = True, v = True)!="None":
         project = self.getSelectedProject()
         if windows.optionMenu("partOptionMenu", q=True, v=True)!="None":
             part_num = int(windows.optionMenu("partOptionMenu", q = True, v = True).split(":")[0]) - 1
             part_dir = project.modelingComponents[part_num][0]
             if (os.path.isdir(part_dir)):
                 call(["open", "-R", part_dir])
             else:
                 windows.confirmDialog(title = "Part Not Found", message = "The selected part folder cannot be found.", button=["Dismiss"])
Пример #4
0
 def openProjectFolder(self):
     if windows.optionMenu("projectOptionMenu", q = True, v = True)!="None":
         project_number = int(windows.optionMenu("projectOptionMenu", q = True, v = True).split(":")[0]) - 1
         _dir = self.projects[project_number].directory
         print(_dir)
         #if "Client_Projects" in _dir:
         #    waitfor("""osascript -e 'mount volume "afp://xserve1._afpovertcp._tcp.local/Client_Projects"'""", 30)
         if (os.path.isdir(_dir)):
             call(["open", "-R", _dir])
         else:
             windows.confirmDialog(title = "Project Not Found", message = "The selected project folder cannot be found.", button=["Dismiss"])
Пример #5
0
 def loadSettings(self):
     #print("\n\nInitializing project save and publish script.\nChecking for settings file...")
     if os.path.isfile(os.path.join(os.path.expanduser("~"),"Documents/maya/settings/filepublishsettings")):
         file = open(os.path.join(os.path.expanduser("~"),"Documents/maya/settings/filepublishsettings"), "r")
         self.username = file.readline().replace("\n", "")
         windows.textFieldGrp("usernameEntry", e = True, tx = self.username)
         project_name =  file.readline().replace("\n","")
         part_name = file.readline().replace("\n","")
         #filter = file.readline().replace("\n","")
         file.close()
         
         if filter in makes:
             windows.optionMenu("filterMakeMenu", e = True, v = filter)
         self.populateProjectsList([])
     
         for project in self.projects:
             if project.name == project_name:
                 #print("    Project successfully loaded, looking for part now...")
                 windows.optionMenu("projectOptionMenu", e = True, v = project.numname)
                 self.populatePartsList()
                 for part in project.modelingComponents:
                     #print("    Checking " + part_name + " against " + part[1])
                     if part_name == part[1]:
                         windows.optionMenu("partOptionMenu", e = True, v = part[2])
                         if windows.confirmDialog(title = "Load previous scene?",message= "Do you want to automatically load the last scene you were working on?", button=["Yes","No"], defaultButton = "Yes", cancelButton = "No", dismissString="No")=="Yes":
                             self.loadFile()
                         return
                 else:
                     return
         else:
             self.populatePartsList()#self.getFilters())
     else:
         self.populateProjectsList(self.getFilters())
Пример #6
0
    def loadFile(self, type=0):
        project = self.getSelectedProject()
        if project!="None":
            if windows.optionMenu("partOptionMenu", q=True, v=True)!="None":
                part_index = int(windows.optionMenu("partOptionMenu", q=True, v=True).split(":")[0]) - 1
                part_directory = project.modelingComponents[part_index][0]
                #part_name = project.modelingComponents[part_index][1]
                
                working_dir = os.path.join(part_directory, "Working")
                #publish_dir = os.path.join(part_directory, "Publish")
                latest_file=None

                if os.path.isdir(working_dir)==False:
                    print("No working files for this model found.")
                else:
                    if type==0:
                        files = glob.glob(working_dir+"/*")
                        if len(files)>0:
                            highest_num=0
                            for file in files:
                                if os.path.isfile(file):
                                    filenum = int(os.path.split(file)[1].split(".")[0][-3:])
                                    if filenum>highest_num:
                                        highest_num = filenum
                                        latest_file = file
                            else:
                                if latest_file==None:
                                    print("No working files found that match the save format")
                        else:
                            print("No working files found in the working directory")
                            
                #print("Saving file: " + file_name)
                if latest_file!=None:
                    #changes_list = system.dgmodified()
                    if system.dgmodified()==None:
                        system.openFile(latest_file, f = True)
                    else:
                        if windows.confirmDialog(title = "Unsaved Changes in Scene", message = "There are unsaved changes in the scene.  Would you like to proceed anyways?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                            system.openFile(latest_file, f = True)
Пример #7
0
 def write_mesh(self, path, name, **kwargs):
     output_path = path / name
     self.status.setText('Exporting: ~/%s.' % name)
     if not self.copy_and_replace_all and output_path.exists():
         click_result = confirmDialog(title='Write File',
          message=os.linesep.join(( \
          'There is already a file with the same name at this location.',
          'What would you like to do?')),
          button=('Copy and Replace all', 'Cancel'),
          defaultButton='Copy and Replace all',
          cancelButton='Cancel', dismissString='Cancel')
         if click_result == 'Cancel':
             self.aborted = True
             return False
         else:
             self.copy_and_replace_all = True
     if self.copy_and_replace_all or not output_path.exists():
         # TODO: PyMEL's exportSelected(output_path, **kwargs),
         # but it keeps spitting out mtl files, regardless of settings.
         #from pymel.core.system import exportSelected
         #exportSelected(output_path, force=True, type='OBJexport')
         mc.file(output_path, **kwargs)
     return True
Пример #8
0
	def write_mesh(self, path, name, **kwargs):
		output_path = path / name
		self.status.setText('Exporting: ~/%s.' % name)
		if not self.copy_and_replace_all and output_path.exists():
			click_result = confirmDialog(title='Write File',
				message=os.linesep.join(( \
				'There is already a file with the same name at this location.',
				'What would you like to do?')),
				button=('Copy and Replace all', 'Cancel'),
				defaultButton='Copy and Replace all',
				cancelButton='Cancel', dismissString='Cancel')
			if click_result == 'Cancel':
				self.aborted = True
				return False
			else:
				self.copy_and_replace_all = True
		if self.copy_and_replace_all or not output_path.exists():
			# TODO: PyMEL's exportSelected(output_path, **kwargs),
			# but it keeps spitting out mtl files, regardless of settings.
			#from pymel.core.system import exportSelected
			#exportSelected(output_path, force=True, type='OBJexport')
			mc.file(output_path, **kwargs)
		return True
Пример #9
0
    def on_exportButton_clicked(self):

        if not ls(selection=True):
            return error('Nothing is currently selected.')

        # Load the objExport plug-in if it hasn't been already.
        kwargs = {}
        if self.formatExt.text() == '.obj':
            mll = 'objExport.mll'
            if not pluginInfo(mll, query=True, loaded=True):
                try:
                    loadPlugin(mll)
                    info('Loaded plug-in: ' + mll)
                except:
                    return error('Failed loading plug-in: ' + mll)
            #kwargs = dict(force=True, constructionHistory=False,
            #	channels=False, constraints=False, expressions=True,
            #	shader=False, preserveReferences=False, type='OBJexport')
            options = dict(groups=self.groups,
                           ptgroups=self.pointGroups,
                           materials=self.materials,
                           smoothing=self.smoothing,
                           normals=self.normals)
            options = ';'.join('%s=%d' % (k, cb.isChecked()) \
             for k, cb in options.items())
            kwargs = dict(exportSelected=True,
                          type='OBJexport',
                          force=True,
                          options=options)
        elif self.exportCombo.currentIndex() == 2:  # mesh
            return error('Unsupported extension: %s.' % self.formatExt.text())

        # Validate the output path.
        output_path = Path(self.path.text())
        if not output_path.exists():
            output_path = Path(self.set_path(workspace.getPath()))
            if not output_path.exists():
                return

        # Validate the frame range.
        start, end, by = self.start.value(), self.end.value(), self.by.value()
        remainder = (end - start) % by
        if remainder:
            click_result = confirmDialog(title='Confirm',
             message=os.linesep.join(( \
             'The end frame will not be exported because',
             'the "by frame" overshoots it by %.2f.' % remainder)),
             button=('OK', 'Cancel'), cancelButton='Cancel',
             defaultButton='OK', dismissString='Cancel')
            if click_result == 'Cancel':
                return

        # Validate the format.
        format = str(self.format.text())
        try:
            format % (start + by)
        except TypeError:
            return error('Invalid format: "%s". ' % format + \
             'Click the \'...\' tool button for help.' % format)

        # Disable UI elements while running.
        [o.show() for o in self.run_showers]
        [o.setEnabled(False) for o in self.run_disablers]

        # Set the range.
        if self.renumFrames.isChecked():
            renum_start = self.renumStart.value()
            self.renum_by = self.renumBy.value()
        else:
            renum_start = start
            self.renum_by = by
        self.frame, self.renum_frame = start, renum_start

        # Set loop vars.
        self.aborted = False
        self.export_count = 0
        self.copy_and_replace_all = False

        # Call the appropriate export function.
        (self.export_skeleton, self.export_camera, self.export_mesh,
         self.export_skin_weights)[self.exportCombo.currentIndex()](**kwargs)

        self.main_progress.endProgress()

        # Enable UI elements back.
        [o.hide() for o in self.run_showers]
        [o.setEnabled(True) for o in self.run_disablers]

        # Report results.
        if self.aborted:
            msg = 'Aborted with %s exported'
        else:
            msg = 'Successfully exported %s'
        plural = self.export_count != 1 and 's' or ''
        frames = '%d frame' % self.export_count + plural
        result(msg % frames + ' to: %s.' % output_path)
Пример #10
0
 def saveFile(self, type=0):
     #So this function needs to look into the proper component folder (if it exists), find the Working folder (if it exists, if not make it)
     #Then save an iteration of this file.
     project = self.getSelectedProject()
     if project!="None":
         if windows.optionMenu("partOptionMenu", q=True, v=True)!="None":
             part_index = int(windows.optionMenu("partOptionMenu", q=True, v=True).split(":")[0]) - 1
             part_directory, part_name, part_numname = project.modelingComponents[part_index]
             if os.path.isdir(part_directory):
                 #part_name = project.modelingComponents[part_index][1]
                 
                 working_dir = os.path.join(part_directory, "Working")
                 qa_dir = os.path.join(part_directory, "QA")
                 publish_dir = os.path.join(part_directory, "Publish")
                 
                 if os.path.isdir(working_dir)==False:
                     os.makedirs(working_dir)
                 if os.path.isdir(qa_dir)==False:
                     os.makedirs(qa_dir)
                 if os.path.isdir(publish_dir)==False:
                     os.makedirs(publish_dir)
                 
                 #If save type is 0 (which is a regular work file incremental save)
                 #Save format: part_modeler_v001.mb
                 if type==0:
                     if self.username!="":
                         files = glob.glob(working_dir+"/*")
                         if len(files)>0:
                             highest_num=0
                             for file in files:
                                 if os.path.isfile(file):
                                     filenum = int(os.path.split(file)[1].split(".")[0][-3:])
                                     if filenum>highest_num:
                                         highest_num = filenum
                             else:
                                 highest_num+=1
                                 num = ("0"*max(0,3-len(str(highest_num)))+str(highest_num))
                                 print("Num: " + num)
                         else:
                             num = "001"
                         
                         if num=="001":
                             if windows.confirmDialog(title = "Save Part File?", message = "Save the first version of this part? You will not be prompted when saving new versions after this.", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                                 file_name = os.path.join(working_dir , part_name + "_" + self.username + "_" + "v" + num + ".mb")
                                 system.saveAs(file_name)
                         else:
                             file_name = os.path.join(working_dir , part_name + "_" + self.username + "_" + "v" + num + ".mb")
                             system.saveAs(file_name)
                     else:
                         windows.confirmDialog(title="No username entered.", message="Please enter a valid username to save with.",button="Dismiss")
                 
                 #If the save file is type 1, its a publish attempt 
                 elif type==1:
                     if windows.confirmDialog(title = "Publish File", message = "Publish this scene file?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                         file_name = os.path.join(publish_dir, part_name + "_publish.mb")
                         if os.path.isfile(file_name):
                             ctime = os.path.getctime(file_name)
                             moveFolder = os.path.join(publish_dir,"_old",time.strftime("%b%d_%Y %H-%M-%S",time.localtime(ctime)))
                             if not os.path.isdir(moveFolder):
                                 os.makedirs(moveFolder)
                             shutil.move(file_name, moveFolder)
                         #Save the current file, then move on to cleaning up this file in preparation for publishing
                         current_filename = system.sceneName()
                         system.saveAs(current_filename)
                         #Clean up all references
                         reference_files = []
                         references = general.ls(type = "reference")
                         if len(references)>0:
                             for reference in references:
                                 if "sharedReferenceNode"!=reference:
                                     reference_files.append(system.referenceQuery(reference, filename=True))
                             else:
                                 for file in reference_files:
                                     system.FileReference(pathOrRefNode = file).remove()
                         general.select(clear = True)
                         general.select(general.ls(geometry = True))
                         layerName = os.path.split(system.sceneName())[1].split("_")[0].replace(" ", "_")
                         general.createDisplayLayer(name = layerName)
                         system.saveAs(file_name)
                         system.openFile(current_filename, f = True)
                 #If its type 2, its a QA submit
                 elif type==2:
                     if windows.confirmDialog(title = "Submit for QA", message = "Submit this scene file for QA?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes':
                         _time = time.strftime("%b%d_%Y_%H-%M-%S", time.localtime(time.time()))
                         file_name = os.path.join(qa_dir, part_name + "_%s_%s.mb"%(self.username,_time))
                         _files = glob.glob(qa_dir+"/*.mb")
                         if len(_files)>0:
                             found=False
                             for i in _files:
                                 if file_name == i:
                                     found=True
                                     if windows.confirmDialog(title = "Overwrite?", message = "A QA file with this name already exists.  Overwrite it?", button = ['Yes', 'No'], defaultButton='Yes', cancelButton='No', dismissString='No')=='Yes': 
                                         current_filename = system.sceneName()
                                         system.saveAs(file_name)
                                         system.saveAs(current_filename)
                                         
                                 else:
                                     _folder = os.path.join(qa_dir,os.path.split(i)[1].split(".")[0])
                                     os.makedirs(_folder)
                                     shutil.move(i, _folder)
                             else:
                                 if found==False:
                                     current_filename = system.sceneName()
                                     system.saveAs(file_name)
                                     system.saveAs(current_filename)
                         else:
                             current_filename = system.sceneName()
                             system.saveAs(file_name)
                             system.saveAs(current_filename)
             else:
                 windows.confirmDialog(title = "Part Not Found", message = "The selected part folder cannot be found.", button=["Dismiss"])
Пример #11
0
	def on_exportButton_clicked(self):
		
		if not ls(selection=True):
			return error('Nothing is currently selected.')
		
		# Load the objExport plug-in if it hasn't been already.
		kwargs = {}
		if self.formatExt.text() == '.obj':
			mll = 'objExport.mll'
			if not pluginInfo(mll, query=True, loaded=True):
				try:
					loadPlugin(mll)
					info('Loaded plug-in: ' + mll)
				except:
					return error('Failed loading plug-in: ' + mll)
			#kwargs = dict(force=True, constructionHistory=False,
			#	channels=False, constraints=False, expressions=True,
			#	shader=False, preserveReferences=False, type='OBJexport')
			options = dict(groups=self.groups, ptgroups=self.pointGroups,
				materials=self.materials, smoothing=self.smoothing,
				normals=self.normals)
			options = ';'.join('%s=%d' % (k, cb.isChecked()) \
				for k, cb in options.items())
			kwargs = dict(exportSelected=True, type='OBJexport', force=True,
				options=options)
		elif self.exportCombo.currentIndex() == 2:  # mesh
			return error('Unsupported extension: %s.' % self.formatExt.text())
		
		# Validate the output path.
		output_path = Path(self.path.text())
		if not output_path.exists():
			output_path = Path(self.set_path(workspace.getPath()))
			if not output_path.exists():
				return
		
		# Validate the frame range.
		start, end, by = self.start.value(), self.end.value(), self.by.value()
		remainder = (end - start) % by
		if remainder:
			click_result = confirmDialog(title='Confirm',
				message=os.linesep.join(( \
				'The end frame will not be exported because',
				'the "by frame" overshoots it by %.2f.' % remainder)),
				button=('OK', 'Cancel'), cancelButton='Cancel',
				defaultButton='OK', dismissString='Cancel')
			if click_result == 'Cancel':
				return
		
		# Validate the format.
		format = str(self.format.text())
		try:
			format % (start + by)
		except TypeError:
			return error('Invalid format: "%s". ' % format + \
				'Click the \'...\' tool button for help.' % format)
		
		# Disable UI elements while running.
		[o.show() for o in self.run_showers]
		[o.setEnabled(False) for o in self.run_disablers]
		
		# Set the range.
		if self.renumFrames.isChecked():
			renum_start = self.renumStart.value()
			self.renum_by = self.renumBy.value()
		else:
			renum_start = start
			self.renum_by = by
		self.frame, self.renum_frame = start, renum_start
		
		# Set loop vars.
		self.aborted = False
		self.export_count = 0
		self.copy_and_replace_all = False
		
		# Call the appropriate export function.
		(self.export_skeleton, self.export_camera, self.export_mesh,
			self.export_skin_weights)[self.exportCombo.currentIndex()](**kwargs)
		
		self.main_progress.endProgress()
		
		# Enable UI elements back.
		[o.hide() for o in self.run_showers]
		[o.setEnabled(True) for o in self.run_disablers]
		
		# Report results.
		if self.aborted:
			msg = 'Aborted with %s exported'
		else:
			msg = 'Successfully exported %s'
		plural = self.export_count != 1 and 's' or ''
		frames = '%d frame' % self.export_count + plural
		result(msg % frames + ' to: %s.' % output_path)