def gear_PSet_DefineLayout(in_ctxt): layout = in_ctxt.Source path = plu.getPluginFullPath("gear_PSet") f = open(path) layout.Logic = f.read() return True
def gear_Synoptic_DefineLayout(in_ctxt): layout = in_ctxt.Source # Logic path = plu.getPluginFullPath("gear_Synoptic") file = open(path) layout.Logic = file.read() return True
def gear_PSet_OnInit(): prop = PPG.Inspected(0) layout = PPG.PPGLayout # Define the Logic ----------------------------------------------- path = plu.getPluginFullPath("gear_PSet") f = open(path) layout.Logic = f.read() layout.Logic += PPG.Logic.Value # Define Layout -------------------------------------------------- layout.Clear() baseParameters = ["layout", "logic", "debug"] # If there is no parameters and debug mode is False if not PPG.debug.Value and prop.Parameters.Count == len(baseParameters): layout.AddStaticText("No Parameter to display") # If Debug Mode is True or no layout has been define elif PPG.debug.Value or PPG.layout.Value == "": layout.AddTab("DEBUG LAYOUT") layout.AddGroup() layout.AddRow() layout.AddButton("refresh", "Refresh") layout.AddSpacer() layout.AddButton("hide", "Hide Me") layout.AddButton("generateLayout", "Generate Layout") layout.EndRow() layout.EndGroup() layout.AddGroup("Layout") item = layout.AddString("layout", "", True, 300) item.SetAttribute(c.siUINoLabel, True) layout.EndGroup() layout.AddTab("DEBUG LOGIC") layout.AddGroup() layout.AddRow() layout.AddButton("refresh", "Refresh") layout.AddSpacer() layout.AddButton("hide", "Hide Me") layout.AddButton("generateLayout", "Generate Layout") layout.EndRow() layout.EndGroup() layout.AddGroup("Logic") item = layout.AddString("logic", "", True, 300) item.SetAttribute(c.siUINoLabel, True) layout.EndGroup() # If there is no layout define we still display the parameter with a default layout if PPG.layout.Value == "": drawDefaultLayout(prop, baseParameters) # Add custom Layout ----------------------------------------- layoutcode = PPG.layout.Value.replace("\r\n", "\r\n ") code = "def readLayout(layout, PPG):\r\n " + layoutcode + "\r\n return\r\n" try: xsi.ExecuteScriptCode(code, "Python", "readLayout", [layout, PPG]) except Exception, e: gear.log("INVALID LAYOUT DETECTED ========================", gear.sev_error) for arg in e.args: gear.log(arg, gear.sev_error) gear.log("LAYOUT CODE ====================================", gear.sev_error) gear.log("\r\n" + code, gear.sev_error) gear.log("END OF LAYOUT CODE =============================", gear.sev_error) drawDefaultLayout(prop, baseParameters)
def gear_Synoptic_OnInit(): # Get Property prop = PPG.Inspected(0) layout = PPG.PPGLayout layout.Clear() # Plugin Folder Path path = plu.getPluginPath("gear_Synoptic") # Get Active Model ----------------------------- model_items = getRigModels() if model_items and PPG.Model.Value not in model_items: PPG.Model.Value = model_items[1] # Common Logic file = open(plu.getPluginFullPath("gear_Synoptic")) layout.Logic = file.read() # Default Layout if not PPG.Model.Value: layout.AddString("No valid model in the scene") layout.AddButton("RefreshModelList", "Refresh") return # Parse Tabs ----------------------------------- model = xsi.ActiveSceneRoot.FindChild(PPG.Model.Value, c.siModelType) model_prop = model.Properties("info") tab_names = model_prop.Parameters("synoptic").Value if not tab_names: layout.AddTab("Default Tab") layout.AddGroup("Active Model") layout.AddRow() item = layout.AddEnumControl("Model", model_items, "Model", c.siControlCombo) item.SetAttribute(c.siUINoLabel, True) item = layout.AddButton("RefreshModelList", "Refresh") item = layout.AddButton("Highlight", "Highlight") layout.EndRow() layout.EndGroup() layout.AddGroup("") layout.AddStaticText("No tab in this model") layout.EndGroup() else: for tab in tab_names.split(","): tab_path = os.path.join(path, "tabs", tab) if not tab or not os.path.exists(tab_path): continue param_path = os.path.join(tab_path, "parameters.py") logic_path = os.path.join(tab_path, "logic.py") layout_path = os.path.join(tab_path, "layout.py") # Parameters ------------- if os.path.exists(param_path): xsi.ExecuteScript(param_path, "Python", "addParameters", [prop]) # Logic ------------------ if os.path.exists(logic_path): file = open(logic_path) layout.Logic += file.read() # Layout ----------------- if os.path.exists(layout_path): layout.AddTab(tab[tab.find("/")+1:]) layout.AddGroup("Active Model") layout.AddRow() item = layout.AddEnumControl("Model", model_items, "Model", c.siControlCombo) item.SetAttribute(c.siUINoLabel, True) item = layout.AddButton("RefreshModelList", "Refresh") item = layout.AddButton("Highlight", "Highlight") layout.EndRow() layout.EndGroup() layout.AddGroup("") xsi.ExecuteScript(layout_path, "Python", "addLayout", [layout, prop]) layout.EndGroup() PPG.Refresh()
def gear_PSet_OnInit(): prop = PPG.Inspected(0) layout = PPG.PPGLayout # Define the Logic ----------------------------------------------- path = plu.getPluginFullPath("gear_PSet") f = open(path) layout.Logic = f.read() layout.Logic += PPG.Logic.Value # Define Layout -------------------------------------------------- layout.Clear() baseParameters = ["layout", "logic", "debug"] # If there is no parameters and debug mode is False if not PPG.debug.Value and prop.Parameters.Count == len(baseParameters): layout.AddStaticText("No Parameter to display") # If Debug Mode is True or no layout has been define elif PPG.debug.Value or PPG.layout.Value == "": layout.AddTab("DEBUG LAYOUT") layout.AddGroup() layout.AddRow() layout.AddButton("refresh", "Refresh") layout.AddSpacer() layout.AddButton("hide", "Hide Me") layout.AddButton("generateLayout", "Generate Layout") layout.EndRow() layout.EndGroup() layout.AddGroup("Layout") item = layout.AddString("layout", "", True, 300) item.SetAttribute(c.siUINoLabel, True) layout.EndGroup() layout.AddTab("DEBUG LOGIC") layout.AddGroup() layout.AddRow() layout.AddButton("refresh", "Refresh") layout.AddSpacer() layout.AddButton("hide", "Hide Me") layout.AddButton("generateLayout", "Generate Layout") layout.EndRow() layout.EndGroup() layout.AddGroup("Logic") item = layout.AddString("logic", "", True, 300) item.SetAttribute(c.siUINoLabel, True) layout.EndGroup() # If there is no layout define we still display the parameter with a default layout if PPG.layout.Value == "": drawDefaultLayout(prop, baseParameters) # Add custom Layout ----------------------------------------- layoutcode = PPG.layout.Value.replace("\r\n", "\r\n ") code = "def readLayout(layout, PPG):\r\n "+layoutcode+"\r\n return\r\n" try: xsi.ExecuteScriptCode(code, "Python", "readLayout", [layout, PPG]) except Exception, e: gear.log("INVALID LAYOUT DETECTED ========================", gear.sev_error) for arg in e.args: gear.log(arg, gear.sev_error) gear.log("LAYOUT CODE ====================================", gear.sev_error) gear.log("\r\n"+code, gear.sev_error) gear.log("END OF LAYOUT CODE =============================", gear.sev_error) drawDefaultLayout(prop, baseParameters)