Created
March 24, 2011 19:54
-
-
Save pboucher/885737 to your computer and use it in GitHub Desktop.
Try to recreate material libraries to fix the disconnecting shaders issue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from win32com.client import constants as c | |
xsi = Application | |
log = xsi.LogMessage | |
def XSILoadPlugin(reg): | |
reg.Author = "pboucher" | |
reg.Name = "MatLibFix" | |
reg.Major = 1 | |
reg.Minor = 0 | |
reg.RegisterCommand("MatLibFixStep1","MatLibFixStep1") | |
reg.RegisterCommand("MatLibFixStep2","MatLibFixStep2") | |
#RegistrationInsertionPoint - do not remove this line | |
return True | |
def MatLibFixStep1_Init(ctxt): | |
cmd = ctxt.Source | |
cmd.Description = "Pre save step of the 2011 MatLib fix problem" | |
cmd.SetFlag(c.siCannotBeUsedInBatch, True) | |
cmd.SetFlag(c.siNoLogging, True) | |
cmd.ReturnValue = True | |
return True | |
def MatLibFixStep1_Execute(): | |
msg = 'After processing mat libs and saving scene, this will quit Softimage.' | |
flags = c.siMsgOkCancel | c.siMsgExclamation | |
if XSIUIToolkit.MsgBox(msg, flags, 'Process and Quit?') == c.siMsgCancel: | |
return True | |
for matLib in xsi.ActiveProject.ActiveScene.MaterialLibraries: | |
matLib.Parameters('storage').Value = 2 | |
matLib.Parameters('filename').Value = 'MatLibs\\' + xsi.ActiveProject.ActiveScene.Name + '__' + matLib.Name + '.xsi' | |
path = XSIUtils.ResolvePath(matLib.Parameters('filename').Value) | |
xsi.ExportMaterialLibrary(path, matLib, "") | |
xsi.SaveSceneAs() | |
xsi.Quit() | |
return True | |
def MatLibFixStep2_Init(ctxt): | |
cmd = ctxt.Source | |
cmd.Description = "Post save step of the 2011 MatLib fix problem" | |
cmd.SetFlag(c.siCannotBeUsedInBatch, True) | |
cmd.SetFlag(c.siNoLogging, True) | |
cmd.ReturnValue = True | |
return True | |
def MatLibFixStep2_Execute(): | |
for matLib in xsi.ActiveProject.ActiveScene.MaterialLibraries: | |
if matLib.LockLevel != c.siLockLevelNone: | |
matLib.UnSetLock() | |
matLib.Parameters('storage').Value = 0 | |
xsi.SaveSceneAs() | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment