Пример #1
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)
Пример #2
0
	def display_renamed_nodes(self):
		result('Renamed %d nodes.' % self._renamed)
		self._renamed = 0
Пример #3
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)
Пример #4
0
 def display_renamed_nodes(self):
     result('Renamed %d nodes.' % self._renamed)
     self._renamed = 0