def importbutton_OnClicked(): settings = zetcore.load_settings('import', PPG.Inspected(0)) import_ = zetimport.Import(xsi, settings) try: import_.import_() except SystemExit: return except Exception as e: if sigen.msg('Encountered an error while importing, copy error to clipboard?', const.siMsgYesNo) == 6: import win32clipboard, traceback log_path = zetcore.get_import_log_path() lines = [] if log_path: with open(log_path, 'r') as file_handle: lines = file_handle.readlines()[-15:] message = ['Last 15 log lines:', '\n'] message.extend(['\t{0}'.format(line.strip('\n')) for line in lines]) message.extend(('\n', 'Traceback:', '\n')) message.extend(['\t{0}'.format(element) for element in traceback.format_exc().split('\n')]) message = '\n'.join(message) win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() try: win32clipboard.SetClipboardText(message, win32clipboard.CF_TEXT) except TypeError: win32clipboard.SetClipboardText(message) win32clipboard.CloseClipboard() else: raise return
def exportbutton_OnClicked(): settings = zetcore.load_settings('export', PPG.Inspected(0)) export = zetexport.Export(xsi, settings) try: export.export() except SystemExit: return except Exception as e: if sigen.msg('Encountered an error while exporting, copy error to clipboard?', const.siMsgYesNo) == 6: import win32clipboard, traceback log_path = zetcore.get_export_log_path() lines = [] if log_path: with open(log_path, 'r') as file_handle: lines = file_handle.readlines()[-15:] message = ['Last 15 log lines:', '\n'] message.extend(['\t{0}'.format(line.strip('\n')) for line in lines]) message.extend(('\n', 'Traceback:', '\n')) message.extend(['\t{0}'.format(element) for element in traceback.format_exc().split('\n')]) message = '\n'.join(message) win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardText(message, win32clipboard.CF_TEXT) win32clipboard.CloseClipboard() else: raise return
def __init__(self, app, config=None): self.xsi = app self.ADDONPATH = self.xsi.InstallationPath(const.siUserAddonPath) self.notifications = None self.model_deformers = None self.stats = zetcore.ExportStats() self.dontexport = [] # pb = progress bar self.pb = softimage.SIProgressBar() if config: self.ppg_params = config else: return self.ppg_params = zetcore.load_settings('export', PPG.Inspected(0)) logpath = os.path.join(softimage.Softimage.get_plugin_origin('XSIZETools'), 'export_log.log') logging.basicConfig(format='%(levelname)s (%(lineno)d, %(funcName)s): %(message)s', filename=logpath, filemode='w', level=logging.DEBUG)
def store_flags_OnClicked(): settings = zetcore.load_settings('import', PPG.Inspected(0)) zetcore.save_settings('import', settings) sigen.msg('Stored.') return
def MSHImport_Execute(): add_to_path() import softimage reload(softimage) import zetcore reload(zetcore) for x in xsi.ActiveSceneRoot.Properties: if x.Name == 'MSHImport': xsi.DeleteObj('MSHImport') settings = zetcore.load_settings('import') pS = xsi.ActiveSceneRoot.AddProperty('CustomProperty', False, 'MSHImport') pS.AddParameter3('path', const.siString, settings.get('path')) tp = pS.AddParameter3('texpath', const.siString, settings.get('texpath')) tp.SetCapabilityFlag(2, not settings.get('btexpath')) pS.AddParameter3('btexpath', const.siBool, settings.get('btexpath'), '', '', 0, 0) pS.AddParameter3('framerange', const.siBool, settings.get('framerange'), '', '', 0, 0) pS.AddParameter3('applyonly', const.siBool, settings.get('applyonly'), '', '', 0, 0) pS.AddParameter3('expbit', const.siString, '') pS.AddParameter3('ignoreanim', const.siBool, settings.get('ignoreanim'), '', '', 0, 0) pS.AddParameter3('log', const.siBool, settings.get('log'), '', '', 0, 0) pS.AddParameter3('triangulate', const.siBool, settings.get('triangulate'), '', '', 0, 0) pS.AddParameter3('ignoregeo', const.siBool, settings.get('ignoregeo'), '', '', 0, 0) pS.AddParameter3('nullsize', const.siDouble, settings.get('nullsize'), 0.01, 5.0, 0, 0) pS.AddParameter3('wirecol', const.siBool, settings.get('wirecol'), '', '', 0, 0) pS.AddParameter3('hideeffs', const.siBool, settings.get('hideeffs'), '', '', 0, 0) pS.AddParameter3('hideroots', const.siBool, settings.get('hideroots'), '', '', 0, 0) pS.AddParameter3('weld', const.siBool, settings.get('weld'), '', '', 0, 0) pS.AddParameter3('Rbone', const.siDouble, settings.get('Rbone'), 0.0, 1.0, 0, 0) pS.AddParameter3('Gbone', const.siDouble, settings.get('Gbone'), 0.0, 1.0, 0, 0) pS.AddParameter3('Bbone', const.siDouble, settings.get('Bbone'), 0.0, 1.0, 0, 0) pS.AddParameter3('Rroot', const.siDouble, settings.get('Rroot'), 0.0, 1.0, 0, 0) pS.AddParameter3('Groot', const.siDouble, settings.get('Groot'), 0.0, 1.0, 0, 0) pS.AddParameter3('Broot', const.siDouble, settings.get('Broot'), 0.0, 1.0, 0, 0) pS.AddParameter3('Reff', const.siDouble, settings.get('Reff'), 0.0, 1.0, 0, 0) pS.AddParameter3('Geff', const.siDouble, settings.get('Geff'), 0.0, 1.0, 0, 0) pS.AddParameter3('Beff', const.siDouble, settings.get('Beff'), 0.0, 1.0, 0, 0) pS.AddParameter3('show_finished_dialog', const.siBool, settings.get('show_finished_dialog'), '', '', 0, 0) mLay = pS.PPGLayout mLay.SetAttribute( const.siUILogicFile, softimage.Softimage.get_plugin_origin('XSIZETools') + '\\Application\\Logic\\importer.py') mLay.Language = 'pythonscript' mLay.AddTab('Import') mLay.AddGroup('Import MSH', 1) # G0 mLay.AddRow() ctrlgrp = mLay.AddGroup('', False) ctrlgrp.SetAttribute(const.siUIWidthPercentage, 75) mLay.AddRow() # 6 mshPathI = mLay.AddItem('path', 'MSH File', const.siControlFilePath) mshPathI.SetAttribute(const.siUINoLabel, 1) mshPathI.SetAttribute(const.siUIFileFilter, 'MSH File (*.msh)|*.msh') mshPathI.SetAttribute(const.siUIOpenFile, True) mshPathI.SetAttribute(const.siUIFileMustExist, True) mLay.EndRow() # 6E mLay.AddRow() btp = mLay.AddItem('btexpath', 'Texture Folder') #btp.SetAttribute(const.siUINoLabel, 1) btp.SetAttribute(const.siUIWidthPercentage, 1) texPathI = mLay.AddItem('texpath', 'Texture Folder', const.siControlFolder) texPathI.SetAttribute(const.siUINoLabel, 1) texPathI.SetAttribute(const.siUIWidthPercentage, 55) mLay.EndRow() mLay.AddRow() # 4 repgrp = mLay.AddGroup('Misc', 1) # G2 repgrp.SetAttribute(const.siUIWidthPercentage, 35) mLay.AddItem('framerange', 'Set Frame Range') mLay.AddItem('applyonly', 'Apply animation to selected hierarchy') mLay.Additem('nullsize', 'Null Display Size') mLay.EndGroup() # G2E bboxg = mLay.AddGroup('', 0) # bbox and btns bboxg.SetAttribute(const.siUIWidthPercentage, 50) mLay.AddGroup('Ignore') # G1 mLay.Additem('ignoregeo', 'Ignore Geometry') mLay.Additem('ignoreanim', 'Ignore Animation') mLay.EndGroup() # G1E mLay.AddRow() # 0 mLay.AddGroup('', 0) # G3 mLay.AddRow() # 1 mLay.AddStaticText('') helpbtn = mLay.AddButton('help', 'Help') helpbtn.SetAttribute(const.siUICX, 40) mLay.EndRow() # 1E mLay.AddRow() # 2 mLay.AddStaticText('') storebtn = mLay.AddButton('store_flags', 'Store Flags') storebtn.SetAttribute(const.siUICX, 80) closebtn = mLay.AddButton('EClose', 'Close') closebtn.SetAttribute(const.siUICX, 40) mLay.EndRow() # 2E mLay.EndGroup() # G3E expgrp = mLay.AddGroup('', 0) # G4 expgrp.SetAttribute(const.siUIWidthPercentage, 1) mLay.AddRow() # 3 exportbtn = mLay.AddButton('importbutton', 'Import') exportbtn.SetAttribute(const.siUICX, 75) exportbtn.SetAttribute(const.siUICY, 45) mLay.EndRow() # 3E mLay.EndGroup() # G4E mLay.EndRow() # 0E mLay.EndGroup() # bbox and btn mLay.EndRow() # 4E mLay.EndGroup() # Controls icongroup = mLay.AddGroup('', 0) icongroup.SetAttribute('WidthPercentage', 1) imagepath = softimage.Softimage.get_plugin_origin( 'XSIZETools') + '\\Resources\\UI\\import_icon_zetools.bmp' expbitmap = mLay.AddEnumControl('expbit', None, '', const.siControlBitmap) expbitmap.SetAttribute(const.siUINoLabel, True) expbitmap.SetAttribute(const.siUIFilePath, imagepath) mLay.EndGroup() mLay.EndRow() mLay.EndGroup() # G0E mLay.AddTab('Settings') mLay.AddGroup('Settings') mLay.AddRow() mLay.AddGroup('Misc') mLay.AddItem('hideroots', 'Hide Roots') mLay.AddItem('hideeffs', 'Hide Effectors') mLay.AddItem('weld', 'Weld Boundary Edges') mLay.AddItem('log', 'Log MSH Unpack') mLay.AddItem('triangulate', 'Triangulate') mLay.AddItem('show_finished_dialog', 'Show dialog on completion') mLay.EndGroup() mLay.AddGroup('', 0) mLay.AddGroup('Colors') mLay.AddItem('wirecol', 'Color Nulls') mLay.AddRow() mLay.AddColor('Rbone', 'Bones', False) mLay.AddSpacer(1, 0) mLay.AddColor('Rroot', 'Roots', False) mLay.AddSpacer(1, 0) mLay.AddColor('Reff', 'Effs', False) mLay.EndRow() mLay.EndGroup() mLay.AddRow() mLay.AddStaticText('') mLay.AddButton('EClose', 'Close') mLay.EndRow() mLay.EndGroup() mLay.EndRow() mLay.EndGroup() desk = xsi.Desktop.ActiveLayout view = desk.CreateView('Property Panel', 'MSH Import') view.BeginEdit() view.Resize(600, 240) view.SetAttributeValue('targetcontent', pS.FullName) view.EndEdit() return True
def MSHExport_Execute(): add_to_path() import softimage reload(softimage) import zetcore reload(zetcore) for x in xsi.ActiveSceneRoot.Properties: if x.Name == 'MSHExport': xsi.DeleteObj('MSHExport') settings = zetcore.load_settings('export') pS = xsi.ActiveSceneRoot.AddProperty('CustomProperty', False, 'MSHExport') pS.AddParameter3('path', const.siString, settings.get('path')) pS.AddParameter3('expbit', const.siString, '') pS.AddParameter3('overwrite', const.siBool, settings.get('overwrite'), '', '', 0, 0) pS.AddParameter3('anim', const.siBool, settings.get('anim'), '', 0, 0, 0) # last readonly pS.AddParameter3('basepose', const.siBool, settings.get('basepose'), '', 0, 0) pS.AddParameter3('rootname', const.siBool, settings.get('rootname'), '', 0, 0) pS.AddParameter3('batch', const.siBool, settings.get('batch'), '', 0, 0) pS.AddParameter3('show_finished_dialog', const.siBool, settings.get('show_finished_dialog'), '', '', 0, 0) mLay = pS.PPGLayout mLay.SetAttribute( const.siUILogicFile, softimage.Softimage.get_plugin_origin('XSIZETools') + '\\Application\\Logic\\exporter.py') mLay.Language = 'pythonscript' mLay.AddGroup('Export MSH', 1) # G0 mLay.AddRow() ctrlgrp = mLay.AddGroup('', False) ctrlgrp.SetAttribute(const.siUIWidthPercentage, 75) mLay.AddRow() # 6 mshPathI = mLay.AddItem('path', 'MSH File', const.siControlFilePath) mshPathI.SetAttribute(const.siUINoLabel, 1) mshPathI.SetAttribute(const.siUIFileFilter, 'MSH File (*.msh)|*.msh') mshPathI.SetAttribute(const.siUIOpenFile, False) mshPathI.SetAttribute(const.siUIFileMustExist, False) mLay.EndRow() # 6E mLay.AddRow() # 4 repgrp = mLay.AddGroup('Misc', 1) # G2 repgrp.SetAttribute(const.siUIWidthPercentage, 30) mLay.AddItem('overwrite', 'Auto-Overwrite') mLay.AddItem('rootname', 'Use root model name for .msh filename') mLay.AddItem('batch', 'Batch Export') mLay.AddItem('show_finished_dialog', 'Show dialog on completion') mLay.EndGroup() # G2E mLay.AddGroup('', 0) # bbox and btns mLay.AddGroup('Animation') # G1 mLay.AddItem('anim', 'Export Animation') mLay.AddItem('basepose', 'Current frame as Basepose') mLay.EndGroup() # G1E mLay.AddRow() # 0 mLay.AddGroup('', 0) # G3 mLay.AddRow() # 1 mLay.AddStaticText('') csbtn = mLay.AddButton('check_sel', 'Check Sel') csbtn.SetAttribute(const.siUICX, 80) helpbtn = mLay.AddButton('help', 'Help') helpbtn.SetAttribute(const.siUICX, 40) mLay.EndRow() # 1E mLay.AddRow() # 2 mLay.AddStaticText('') storebtn = mLay.AddButton('store_flags', 'Store Flags') storebtn.SetAttribute(const.siUICX, 80) closebtn = mLay.AddButton('EClose', 'Close') closebtn.SetAttribute(const.siUICX, 40) mLay.EndRow() # 2E mLay.EndGroup() # G3E expgrp = mLay.AddGroup('', 0) # G4 expgrp.SetAttribute(const.siUIWidthPercentage, 1) mLay.AddRow() # 3 exportbtn = mLay.AddButton('exportbutton', 'Export') exportbtn.SetAttribute(const.siUICX, 75) exportbtn.SetAttribute(const.siUICY, 45) mLay.EndRow() # 3E mLay.EndGroup() # G4E mLay.EndRow() # 0E mLay.EndGroup() # bbox and btn mLay.EndRow() # 4E mLay.EndGroup() # Controls icongroup = mLay.AddGroup('', 0) icongroup.SetAttribute('WidthPercentage', 1) imagepath = softimage.Softimage.get_plugin_origin( 'XSIZETools') + '\\Resources\\UI\\export_icon_zetools.bmp' expbitmap = mLay.AddEnumControl('expbit', None, '', const.siControlBitmap) expbitmap.SetAttribute(const.siUINoLabel, True) expbitmap.SetAttribute(const.siUIFilePath, imagepath) mLay.EndGroup() mLay.EndRow() mLay.EndGroup() # G0E desk = xsi.Desktop.ActiveLayout view = desk.CreateView('Property Panel', 'MSH Export') view.BeginEdit() view.Resize(600, 200) view.SetAttributeValue('targetcontent', pS.FullName) view.EndEdit() return True