Пример #1
0
def gear_ImportEnvelope_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Import Envelope", xsi.ActiveProject2.OriginPath, "", ["xml"], False)
    if not path:
        return

    # -----------------------------------------------------
    xml_objs = io.getObjectDefinitions(path, xsi.Selection, True)
    if not xml_objs:
        return

    # -----------------------------------------------------
    for sel in xsi.Selection:

        if sel.Type in ["pntSubComponent"]:
            obj = sel.SubComponent.Parent3DObject
            pnt_selection = sel.SubComponent.ElementArray
        else:
            obj = sel
            pnt_selection = None

        if obj.Name not in xml_objs.keys():
            continue

        io.importEnvelope(xml_objs[obj.Name], obj, pnt_selection)
Пример #2
0
def gear_ImportSkin_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Import Skin", xsi.ActiveProject2.OriginPath, "",
                           ["xml"], False)
    if not path:
        return

    # -----------------------------------------------------
    xml_objs = io.getObjectDefinitions(path, xsi.Selection, True)
    if not xml_objs:
        return

    # -----------------------------------------------------
    for obj in xsi.Selection:

        if obj.Name not in xml_objs.keys():
            continue

        io.importSkin(xml_objs[obj.Name], obj)
Пример #3
0
def gear_ImportEnvelope_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Import Envelope", xsi.ActiveProject2.OriginPath,
                           "", ["xml"], False)
    if not path:
        return

    # -----------------------------------------------------
    xml_objs = io.getObjectDefinitions(path, xsi.Selection, True)
    if not xml_objs:
        return

    # -----------------------------------------------------
    for sel in xsi.Selection:

        if sel.Type in ["pntSubComponent"]:
            obj = sel.SubComponent.Parent3DObject
            pnt_selection = sel.SubComponent.ElementArray
        else:
            obj = sel
            pnt_selection = None

        if obj.Name not in xml_objs.keys():
            continue

        io.importEnvelope(xml_objs[obj.Name], obj, pnt_selection)
Пример #4
0
def gear_ImportSkin_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return

    # -----------------------------------------------------
    # Getting the file path
    path = uit.fileBrowser("Import Skin", xsi.ActiveProject2.OriginPath, "", ["xml"], False)
    if not path:
        return

    # -----------------------------------------------------
    xml_objs = io.getObjectDefinitions(path, xsi.Selection, True)
    if not xml_objs:
        return

    # -----------------------------------------------------
    for obj in xsi.Selection:

        if obj.Name not in xml_objs.keys():
            continue

        io.importSkin(xml_objs[obj.Name], obj)
Пример #5
0
    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)
Пример #6
0
    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)