Beispiel #1
0
def quickSel(in_mousebutton, in_keymodifier, port="A"):

    synoptic_prop = getSynoptic()
    quickSel_param = synoptic_prop.Parameters(QUICKSEL_PARAM_PREFIX + port)

    # Left click - Call selection
    if in_mousebutton == 0:
        if quickSel_param.Value == "":
            xsi.DeselectAll()
        else:
            model = getModel()

            selection = [
                model.FindChild(name)
                for name in quickSel_param.Value.split(",")
                if model.FindChild(name)
            ]
            xsi.SelectObj(selection)

    # Middle click - Save selection
    elif in_mousebutton == 1:
        selection = [obj.name for obj in xsi.Selection]
        quickSel_param.Value = ",".join(selection)

    # Right click - Do nothing
    elif in_mousebutton == 2:
        return
Beispiel #2
0
def gear_Select6MoreBranchesStars_Execute():

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

    objects = [obj for obj in xsi.Selection if obj.Type in ["polymsh"]]

    if not objects:
        gear.log("Invalid Selection", gear.sev_error)
        return

    xsi.DeselectAll()

    for obj in objects:

        stars = geo.getStars(obj, 6, True)

        if stars:
            gear.log("There is " + str(len(stars)) +
                     " stars with 6 branches or more on " + obj.FullName)
            xsi.AddToSelection(obj.FullName + ".pnt" + str(stars), "", True)
        else:
            gear.log("There is no stars with 6 branches or more on " +
                     obj.FullName)
Beispiel #3
0
def gear_MirrorObjectWeights_Execute():

    xsi.DeselectAll()

    # Get Source Mesh
    source_mesh = uit.pickSession(c.siGenericObjectFilter,
                                  "Pick Enveloped Mesh", True)
    if not source_mesh:
        return

    if source_mesh.Type not in ["polymsh", "surfmsh", "crvlist"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    envelope_op = ope.getOperatorFromStack(source_mesh, "envelopop")
    if not envelope_op:
        gear.log("There is no envelope on selected mesh", gear.sev_error)
        return

    # Get Target Mesh
    target_mesh = uit.pickSession(c.siGenericObjectFilter, "Pick Target Mesh",
                                  True)
    if not target_mesh:
        return

    if target_mesh.Type not in ["polymsh", "surfmsh", "crvlist"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Process
    env.copyMirrorEnvelope(source_mesh, target_mesh)
Beispiel #4
0
def gear_groupManagerProp_Select_OnChanged():
    lm("gear_groupManager_Select_OnChanged called", c.siVerbose)
    oParam = PPG.Select
    paramVal = oParam.Value

    group = PPG.grpName.Parent.Parent

    if paramVal:
        val = 2
    else:
        val = 0
    group.Parameters("selectability").Value = val
    xsi.DeselectAll()

    lm(str("New value: ") + str(paramVal), c.siVerbose)
Beispiel #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)