def importXtraRig(path, model): return # Check Input if not os.path.exists(path): gear.log("Invalid File", gear.sev_error) return # Import xrig_model = xsi.ImportModel(path, xsi.ActiveSceneRoot, False, None, model.Name + "_xrig")(1) xrig_org = xrig_model.FindChild(XRIG_ORG_NAME) xrig_prop = xrig_model.Properties(XRIG_PROP_NAME) xrig_cns = xrig_prop.Parameters("constraints").Value if not xrig_org or xrig_prop: gear.log("This is not a valid Extra Rig Model", gear.sev_error) xsi.DeleteObj("B:" + xrig_model.Name) return # Merging rig model.AddChild(xrig_org) # Retrieve Groups for xrig_group in xrig_model.Groups: group = model.Groups(xrig_group.Name) if not group: group = model.AddGroup(None, xrig_group.Name) group.AddMember(xrig_group.Members) xsi.DeleteObj("B:" + xrig_model.Name) ## TODO : IMPORT CONSTRAINT !!! ## TODO : IMPORT PARAMETERS AND CONNECTION !!! ''' # Reconnect Controls oExtraControls = oExtraRig.Properties("anim_ctrl") oAnimCtrl = dynDispatch(oModel.Properties("anim_ctrl")) aSkipParameters = ["Debug", "Layout", "Logic", "LayoutLanguage"] for oParam in oExtraControls.Parameters: if oParam.Name in aSkipParameters: continue oAnimCtrl.AddProxyParameter(oParam, oParam.Name, oParam.Name) # Layout sLayout = "\r\noLayout.AddTab('ExtraRig');\r\n" + oExtraControls.Parameters("Layout").Value oAnimCtrl.Parameters("Layout").Value += sLayout # Retrive Constrains sXmlPath = sPath.replace(".emdl", ".xml") if os.path.exists(sXmlPath): xsi.gImportSkin(oExtraRig.Children, sXmlPath, True) ''' return
def finalize(self): # Properties -------------------------------------- self.plog.log("Filling layout and logic") self.ui.fillLayoutAndLogic() # Groups ------------------------------------------ self.plog.log("Creating groups") # Retrieve group content from components for name in self.componentsIndex: component = self.components[name] for name, objects in component.groups.items(): self.addToGroup(objects, name) # Creating all groups for name, objects in self.groups.items(): collection = XSIFactory.CreateObject("XSI.Collection") collection.AddItems(objects) self.groups[name] = self.model.AddGroup(collection, name + "_grp") # Hidden if self.options["setHidden"]: self.groups["hidden"].Parameters("viewvis").Value = 0 self.groups["hidden"].Parameters("rendvis").Value = 0 # Unselectable if self.options["setUnselectable"]: self.groups["unselectable"].Parameters("selectability").Value = 0 # Deformers if self.options["setDeformers"]: self.groups["deformers"].Parameters("viewvis").Value = 0 self.groups["deformers"].Parameters("rendvis").Value = 0 # Geometries if self.options["setGeometries"]: self.groups["geometries"].Parameters("selectability").Value = 0 prop = self.groups["geometries"].AddProperty("GeomApprox") par.addExpression(prop.Parameters("gapproxmosl"), self.pOGLLevel) # Skin -------------------------------------------- if self.options["addGeometry"]: self.plog.log("Applying skin") # Import geometry if self.options["geo_path"] and os.path.exists( self.options["geo_path"]): geo_model = xsi.ImportModel(self.options["geo_path"], xsi.ActiveSceneRoot, False, None)(1) geo_objects = geo_model.FindChildren() self.model.AddChild(geo_model.children) for group in geo_model.Groups: target_group = pri.createOrReturnGroup( self.model, group.Name) target_group.AddMember(group.Members) xsi.DeleteObj(geo_model) # Apply skin if self.options["skin_path"] and os.path.exists( self.options["skin_path"]): xml_objs = io.getObjectDefinitions( self.options["skin_path"], geo_objects, False) for obj in geo_objects: if obj.Name not in xml_objs.keys(): continue io.importSkin(xml_objs[obj.Name], obj) # Symmetry Mapping Template ----------------------- if self.options["mode"] == 1: env.createSymmetryMappingTemplate(self.groups["deformers"].Members) for geo in self.groups["geometries"].Members: if geo.Type == "polymsh": xsi.CreateSymmetryMap("SymmetryMap", geo, "Symmetry Map") # Mirror Animation Template ----------------------- if self.options["mode"] == 0: cnx_prop = ani.createMirrorCnxTemplate(self.model) for count, compName in enumerate(self.componentsIndex): component = self.components[compName] inversed_params = component.inv_params.GetAsText().split(",") for ctl in component.controlers: ani.addMirroringRule(ctl, cnx_prop, inversed_params, True) # Reset Pose -------------------------------------- self.plog.log("Creating rest pose") controlers = XSIFactory.CreateObject("XSI.Collection") for group in self.model.Groups: if group.Name.startswith("controlers"): controlers.AddItems(group.Members) keyableParams = controlers.FindObjectsByMarkingAndCapabilities( None, c.siKeyable) xsi.StoreAction(self.model, keyableParams, 1, "reset", False) # Isolate and popup ------------------------------- if self.options["isolateResult"]: xsi.SelectObj(self.model, "BRANCH") xsi.IsolateSelected(False, -1) xsi.DeselectAll() if self.options["popUpControls"]: xsi.InspectObj(self.ui.anim_prop)