예제 #1
0
def gear_ApplySpinePointAtOp_Execute():

    start_obj = uit.pickSession(c.siGenericObjectFilter, "Pick Start Reference", True)
    if not start_obj:
        return

    end_obj = uit.pickSession(c.siGenericObjectFilter, "Pick End Reference", True)
    if not end_obj:
        return

    count = xsi.Selection.Count+0.0
    operators = []
    for i, sel in enumerate(Application.Selection):

        path_cns = False
        for cns in sel.Kinematics.Constraints:
            if cns.Type in ["crvcns", "pathcns"]:
                path_cns = cns
                break

        if not path_cns:
            gear.log("There is no path or curve constraint on this object : %s"%sel.Name, gear.sev_warning)
            continue

        blend = i/count
        op = aop.spinePointAtOp(cns, start_obj, end_obj, blend)
        operators.append(op)
        
    xsi.InspectObj(operators)
        
    
예제 #2
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)
예제 #3
0
def gear_ApplySpinePointAtOp_Execute():

    start_obj = uit.pickSession(c.siGenericObjectFilter,
                                "Pick Start Reference", True)
    if not start_obj:
        return

    end_obj = uit.pickSession(c.siGenericObjectFilter, "Pick End Reference",
                              True)
    if not end_obj:
        return

    count = xsi.Selection.Count + 0.0
    operators = []
    for i, sel in enumerate(Application.Selection):

        path_cns = False
        for cns in sel.Kinematics.Constraints:
            if cns.Type in ["crvcns", "pathcns", "dircns"]:
                path_cns = cns
                break

        if not path_cns:
            gear.log(
                "There is no path ,curve or direction constraint on this object : %s"
                % sel.Name, gear.sev_warning)
            continue

        blend = i / count
        op = aop.spinePointAtOp(cns, start_obj, end_obj, blend)
        operators.append(op)

    xsi.InspectObj(operators)
예제 #4
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)
예제 #5
0
def gear_ReplaceDeformer_Execute():

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

    sel = xsi.Selection(0)

    if sel.Type == "polymsh":
        mesh = sel
        points = range(mesh.ActivePrimitive.Geometry.Points.Count)
    elif sel.Type == "pntSubComponent":
        mesh = sel.SubComponent.Parent3DObject
        points = sel.SubComponent.ElementArray
    else:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Get Envelope from object
    envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
    if not envelope_op:
        gear.log("There is no envelope on selected mesh", gear.sev_error)
        return False

    # Source deformers
    source_deformers = XSIFactory.CreateObject("XSI.Collection")
    while True:
        picked = uit.pickSession(c.siGenericObjectFilter, "Pick Source Deformers", False)
        if not picked:
            break

        if picked.Type == "#Group":
            source_deformers.AddItems(picked.Members)
        else:
            source_deformers.Add(picked)

    if not source_deformers.Count:
        return False

    # Target deformers
    target_deformers = XSIFactory.CreateObject("XSI.Collection")
    while True:
        picked = uit.pickSession(c.siGenericObjectFilter, "Pick Target Deformers", False)
        if not picked:
            break

        if picked.Type == "#Group":
            target_deformers.AddItems(picked.Members)
        else:
            target_deformers.Add(picked)

    if not target_deformers.Count:
        return False

    # Some log to be sure of what we have selected
    gear.log("Geometry: " + mesh.FullName + "  \nSource(s): " + str(source_deformers) + "  \nTarget(s): " + str(target_deformers))

    env.replaceDeformerInEnvelope(envelope_op, source_deformers, target_deformers, points)
예제 #6
0
def gear_CopyWeightsAverage_Execute():

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

    sel = xsi.Selection(0)

    # Check input
    if sel.Type not in ["pntSubComponent"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    target_point = sel.SubComponent.ElementArray

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

    # Pick Session
    source_points = []
    while True:
        source_pnt = uit.pickSession(c.siPointFilter, "Pick Source Point",
                                     False)
        if not source_pnt:
            break

        source_points.extend(source_pnt.SubComponent.ElementArray)

    if not source_points:
        gear.log("No Points Selected", gear.sev_error)
        return

    # Get Weights
    weights_tuple = envelope_op.Weights.Array
    weights = [
        weights_tuple[j][i] for i in range(len(weights_tuple[0]))
        for j in range(len(weights_tuple))
    ]
    deformer_count = envelope_op.Deformers.Count

    # Array of average value of weights
    avr_weights = [0] * deformer_count
    for point_index in source_points:
        for deformer_index in range(deformer_count):
            avr_weights[deformer_index] += weights_tuple[deformer_index][
                point_index] / len(source_points)

    # Replace Weights in Weight Array
    for point_index in target_point:
        for deformer_index in range(deformer_count):
            weights[point_index * deformer_count +
                    deformer_index] = avr_weights[deformer_index]

    envelope_op.Weights.Array = weights

    return
예제 #7
0
def gear_MatchSR_Execute():

    source_object = xsi.Selection(0)
    target_object = uit.pickSession()
    if not target_object:
        return

    tra.matchGlobalTransform(source_object, target_object, False, True, True)
예제 #8
0
def gear_MatchSR_Execute():

    source_object = xsi.Selection(0)
    target_object = uit.pickSession()
    if not target_object:
        return

    tra.matchGlobalTransform(source_object, target_object, False, True, True)
예제 #9
0
def gear_InterLocalOri_Execute():

    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return
        
    out = xsi.Selection(0)
        
    ref_A = uit.pickSession(c.siGenericObjectFilter, "Pick Reference A", True)
    if not start_obj:
        return

    ref_B = uit.pickSession(c.siGenericObjectFilter, "Pick Reference B", True)
    if not end_obj:
        return
        
    op = aop.sn_interLocalOri_op(out, ref_A, ref_B, .5)
    
    xsi.InspectObj(op)
예제 #10
0
def gear_Interpose_Execute():

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

    out = xsi.Selection(0)

    ref_A = uit.pickSession(c.siGenericObjectFilter, "Pick Reference A", True)
    if not ref_A:
        return

    ref_B = uit.pickSession(c.siGenericObjectFilter, "Pick Reference B", True)
    if not ref_B:
        return

    op = aop.sn_interpose_op(out, ref_A, ref_B)

    xsi.InspectObj(op)
예제 #11
0
def gear_CopyWeightsAverage_Execute():

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

    sel = xsi.Selection(0)

    # Check input
    if sel.Type not in ["pntSubComponent"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    target_point = sel.SubComponent.ElementArray

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

    # Pick Session
    source_points = []
    while True:
        source_pnt = uit.pickSession(c.siPointFilter, "Pick Source Point", False)
        if not source_pnt:
            break

        source_points.extend(source_pnt.SubComponent.ElementArray)

    if not source_points:
        gear.log("No Points Selected", gear.sev_error)
        return

    # Get Weights
    weights_tuple = envelope_op.Weights.Array
    weights = [weights_tuple[j][i] for i in range(len(weights_tuple[0])) for j in range(len(weights_tuple))]
    deformer_count = envelope_op.Deformers.Count

    # Array of average value of weights
    avr_weights = [0] * deformer_count
    for point_index in source_points:
        for deformer_index in range(deformer_count):
            avr_weights[deformer_index] += weights_tuple[deformer_index][point_index] / len(source_points)

    # Replace Weights in Weight Array
    for point_index in target_point:
        for deformer_index in range(deformer_count):
            weights[point_index*deformer_count + deformer_index] = avr_weights[deformer_index]

    envelope_op.Weights.Array = weights

    return
예제 #12
0
def gear_MatchT_Execute():

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

    source_object = xsi.Selection(0)
    target_object = uit.pickSession()
    if not target_object:
        return

    tra.matchGlobalTransform(source_object, target_object, True, False, False)
예제 #13
0
def gear_MatchT_Execute():

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

    source_object = xsi.Selection(0)
    target_object = uit.pickSession()
    if not target_object:
        return

    tra.matchGlobalTransform(source_object, target_object, True, False, False)
예제 #14
0
def gear_CopyWeights_Execute():

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

    sel = xsi.Selection(0)

    # Check input
    if sel.Type not in ["pntSubComponent"]:
        gear.log("Invalid selection", gear.sev_error)
        return

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

    cls = obj.ActivePrimitive.Geometry.AddCluster(
        c.siVertexCluster, "gear_CopyWeightsOp_Cls",
        sel.SubComponent.ElementArray)

    # Pick Session
    source_pnt = uit.pickSession(c.siPointFilter, "Pick Source Point", True)
    if not source_pnt:
        return

    points = source_pnt.SubComponent.ElementArray
    if len(points) != 1:
        gear.log("Please Select Only One Point", gear.sev_error)
        return

    # Need to find the cluster
    for port in envelope_op.InputPorts:
        if port.Target2.Type == "envweights":
            env_cls = port.Target2

    if not env_cls:
        gear.log("Invalid Envelop, no cluster was found", gear.sev_error)
        return

    # Apply Operator ----------------------
    op = XSIFactory.CreateObject("gear_CopyWeightsOp")

    op.AddIOPort(env_cls)
    op.AddInputPort(cls)
    op.Index = points[0]
    op.Connect()

    xsi.InspectObj(op)

    return op
예제 #15
0
def gear_CopyEnvWithGator_Execute():

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

    meshes = []
    for item in xsi.Selection:
        if item.Type == "#Group":
            for member in item.Members:
                if member.Type == "polymsh":
                    meshes.append(member)
                else:
                    gear.log("Invalid Selection : %s" % member.FullName,
                             gear.sev_warning)
        elif item.Type == "polymsh":
            meshes.append(item)
        else:
            gear.log("Invalid Selection : %s" % item.FullName,
                     gear.sev_warning)

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

    # Pick Session for the sources
    source_meshes = XSIFactory.CreateObject("XSI.Collection")
    while True:
        picked = uit.pickSession(c.siGenericObjectFilter, "Pick Source Mesh",
                                 False)
        if not picked:
            break

        if picked.Type in ["#Group"]:
            for member in picked.Members:
                if ope.getOperatorFromStack(member, "envelopop"):
                    source_meshes.AddItems(member)
                else:
                    gear.log("No Envelope on " + member.Name, gear.sev_warning)
        else:
            if ope.getOperatorFromStack(picked, "envelopop"):
                source_meshes.Add(picked)
            else:
                gear.log("No Envelope on " + picked.Name, gear.sev_warning)

    if not source_meshes:
        gear.log("Invalid Picking", gear.sev_error)
        return

    # Process
    for mesh in meshes:
        env.copyEnvelopeWithGator(mesh, source_meshes)
예제 #16
0
def gear_CopyWeights_Execute():

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

    sel = xsi.Selection(0)

    # Check input
    if sel.Type not in ["pntSubComponent"]:
        gear.log("Invalid selection", gear.sev_error)
        return

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

    cls = obj.ActivePrimitive.Geometry.AddCluster(c.siVertexCluster, "gear_CopyWeightsOp_Cls", sel.SubComponent.ElementArray)

    # Pick Session
    source_pnt = uit.pickSession(c.siPointFilter, "Pick Source Point", True)
    if not source_pnt:
      return

    points = source_pnt.SubComponent.ElementArray
    if len(points) != 1:
      gear.log("Please Select Only One Point" , gear.sev_error)
      return

    # Need to find the cluster
    for port in envelope_op.InputPorts:
      if port.Target2.Type == "envweights":
            env_cls = port.Target2

    if not env_cls:
      gear.log("Invalid Envelop, no cluster was found",  gear.sev_error)
      return

    # Apply Operator ----------------------
    op = XSIFactory.CreateObject("gear_CopyWeightsOp")

    op.AddIOPort(env_cls)
    op.AddInputPort(cls)
    op.Index = points[0]
    op.Connect()

    xsi.InspectObj(op)

    return op
예제 #17
0
def gear_MergeSymmetryMappingTemplate_Execute():

    # Pick Session
    source_SMT = uit.pickSession(c.siGenericObjectFilter, "Pick Source Symmetry Mapping Template", True)
    if not source_SMT:
      return
    elif source_SMT.Type != "MixerProp":
        lm("The selction is not a Symmetry mapping template", 4)
        return
    target_SMT = uit.pickSession(c.siGenericObjectFilter, "Pick Target Symmetry Mapping Template", True)
    if not target_SMT:
      return
    elif target_SMT.Type != "MixerProp":
        lm("The selction is not a Symmetry mapping template", 4)
        return

    oNumRules =  xsi.GetNumMappingRules( source_SMT)


    for x in range(oNumRules):
        oFrom = xsi.GetMappingRule( source_SMT, x + 1)[1]
        oTo = xsi.GetMappingRule( source_SMT, x + 1)[3]
        xsi.AddMappingRule( target_SMT, oFrom, oTo, 0 )
예제 #18
0
def gear_CopyWireFrameColor_Execute():

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

    ref = uit.pickSession(c.siGenericObjectFilter, "Pick Reference", True)
    if not ref:
        return

    color = dis.getColor(ref)

    for sel in xsi.Selection:
        dis.setColor(sel, color)
예제 #19
0
def gear_CopyWireFrameColor_Execute():

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

    ref = uit.pickSession(c.siGenericObjectFilter, "Pick Reference", True)
    if not ref:
        return

    color = dis.getColor(ref)

    for sel in xsi.Selection:
        dis.setColor(sel, color)
예제 #20
0
def gear_CopyEnvWithGator_Execute():
     
    # Check Selection
    if not xsi.Selection.Count:
        gear.log("No selection", gear.sev_error)
        return
    
    meshes = []
    for item in xsi.Selection:
        if item.Type == "#Group":
            for member in item.Members:
                if member.Type == "polymsh":
                    meshes.append(member)
                else:
                    gear.log("Invalid Selection : %s"%member.FullName, gear.sev_warning)
        elif item.Type == "polymsh":
            meshes.append(item)
        else:
            gear.log("Invalid Selection : %s"%item.FullName, gear.sev_warning)
        
    if not meshes:
        gear.log("Invalid Selection", gear.sev_error)
        return

    # Pick Session for the sources
    source_meshes = XSIFactory.CreateObject("XSI.Collection")
    while True:
        picked = uit.pickSession(c.siGenericObjectFilter, "Pick Source Mesh", False)
        if not picked:
            break

        if picked.Type in ["#Group"]:
            for member in picked.Members:
                if ope.getOperatorFromStack(member, "envelopop"):
                    source_meshes.AddItems(member)
                else:
                    gear.log("No Envelope on " + member.Name, gear.sev_warning)
        else:
            if ope.getOperatorFromStack(picked, "envelopop"):
                source_meshes.Add(picked)
            else:
                gear.log("No Envelope on " + picked.Name, gear.sev_warning)

    if not source_meshes:
        gear.log("Invalid Picking", gear.sev_error)
        return

    # Process
    for mesh in meshes:
        env.copyEnvelopeWithGator(mesh, source_meshes)
예제 #21
0
def gear_MergeSymmetryMappingTemplate_Execute():

    # Pick Session
    source_SMT = uit.pickSession(c.siGenericObjectFilter,
                                 "Pick Source Symmetry Mapping Template", True)
    if not source_SMT:
        return
    elif source_SMT.Type != "MixerProp":
        lm("The selction is not a Symmetry mapping template", 4)
        return
    target_SMT = uit.pickSession(c.siGenericObjectFilter,
                                 "Pick Target Symmetry Mapping Template", True)
    if not target_SMT:
        return
    elif target_SMT.Type != "MixerProp":
        lm("The selction is not a Symmetry mapping template", 4)
        return

    oNumRules = xsi.GetNumMappingRules(source_SMT)

    for x in range(oNumRules):
        oFrom = xsi.GetMappingRule(source_SMT, x + 1)[1]
        oTo = xsi.GetMappingRule(source_SMT, x + 1)[3]
        xsi.AddMappingRule(target_SMT, oFrom, oTo, 0)
예제 #22
0
def gear_MatchGeometry_Execute():

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

    target = xsi.Selection(0)
    if target.Type not in ["pntSubComponent", "polymsh", "surfmsh", "crvlist"]:
        gear.log("Invalid Selection, select a geometry or a point selection",
                 gear.sev_error)
        return

    # Get reference
    source = uit.pickSession(c.siGenericObjectFilter, "Pick Source Geometry")
    if not source:
        return

    # Get cluster
    if target.Type == "pntSubComponent":
        obj = target.SubComponent.Parent3DObject
        cls = obj.ActivePrimitive.Geometry.AddCluster(
            c.siVertexCluster, "gear_MatchGeometryOp_cls",
            target.SubComponent.ElementArray)
    else:
        obj = target
        cls = obj.ActivePrimitive.Geometry.AddCluster(
            c.siVertexCluster, "gear_MatchGeometryOp_cls")

    if source.Type != obj.Type:
        gear.log("Invalid Selection", gear.sev_error)
        xsi.DeleteObj(cls)
        return

    # Apply Operator
    op = XSIFactory.CreateObject("gear_MatchGeometryOp")

    op.AddIOPort(obj.ActivePrimitive)
    op.AddInputPort(source.ActivePrimitive)
    op.AddInputPort(cls)
    op.AddInputPort(obj.Kinematics.Global)
    op.AddInputPort(source.Kinematics.Global)

    op.Connect()

    xsi.InspectObj(op)

    return op
예제 #23
0
파일: logic.py 프로젝트: jeanim/gear
def pickReferences(prop, list_name, item_name, onlyOne=False):

    # Get reference using pick session
    references = []
    while True:
        ref = uit.pickSession(c.siGenericObjectFilter, "Pick References",
                              False)
        if not ref:
            break
        references.append(ref)

        if onlyOne:
            break

    # Get current reference array
    if not prop.Parameters(list_name).Value:
        a = []
    else:
        a = prop.Parameters(list_name).Value.split(",")

    # Check picked references
    for ref in references:
        if not ref.Model.IsEqualTo(prop.Model):
            gear.log("Reference doesnt belong to the guide model",
                     gear.sev_warning)
            continue

        elif ref.Name in a:
            gear.log("Reference already in the list", gear.sev_warning)
            continue
        a.append(ref.Name)

    if not a:
        return

    # build combobox items array
    items = []
    for i, name in enumerate(a):
        items.append(name)
        items.append(i)

    layout = prop.PPGLayout
    item = layout.Item(item_name)
    item.UIItems = items

    prop.Parameters(list_name).Value = ",".join(a)
    prop.Parameters(item_name).Value = items[-1]
예제 #24
0
def gear_NormalizeToDeformer_Execute():

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

    sel = xsi.Selection(0)

    if sel.Type in ["polymsh", "surfmsh", "crvlist"]:
        mesh = sel
        points = range(mesh.ActivePrimitive.Geometry.Points.Count)
    elif sel.Type == "pntSubComponent":
        mesh = sel.SubComponent.Parent3DObject
        points = sel.SubComponent.ElementArray
    else:
        gear.log("Invalid selection", gear.sev_error)
        return

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

    # Get The deformers
    deformers = XSIFactory.CreateObject("XSI.Collection")
    while True:
        deformer = uit.pickSession(c.siGenericObjectFilter, "Pick Deformer",
                                   False)
        if not deformer:
            break

        if env.isDeformer(envelope_op, deformer):
            deformers.Add(deformer)
        else:
            gear.log("Picked object is not a deformer for this envelope",
                     c.siWarning)

    if not deformers.Count:
        return

    # Process
    env.normalizeToDeformer(envelope_op, deformers, points)
    env.freezeEnvelope(envelope_op)
    env.rebuiltEnvelope(envelope_op)
예제 #25
0
파일: logic.py 프로젝트: UIKit0/gear-1
def pickReferences(prop, list_name, item_name, onlyOne=False):

    # Get reference using pick session
    references = []
    while True:
        ref = uit.pickSession(c.siGenericObjectFilter, "Pick References", False)
        if not ref:
            break
        references.append(ref)

        if onlyOne:
            break

    # Get current reference array
    if not prop.Parameters(list_name).Value:
        a = []
    else:
        a = prop.Parameters(list_name).Value.split(",")

    # Check picked references
    for ref in references:
        if not ref.Model.IsEqualTo(prop.Model):
            gear.log("Reference doesnt belong to the guide model",gear.sev_warning)
            continue

        elif ref.Name in a:
            gear.log("Reference already in the list",gear.sev_warning)
            continue
        a.append(ref.Name)

    if not a:
        return

    # build combobox items array
    items = []
    for i, name in enumerate(a):
        items.append(name)
        items.append(i)

    layout = prop.PPGLayout
    item = layout.Item(item_name)
    item.UIItems = items

    prop.Parameters(list_name).Value = ",".join(a)
    prop.Parameters(item_name).Value = items[-1]
예제 #26
0
def gear_CurveResampler_Execute():

    if not xsi.Selection.Count or xsi.Selection(0).Type not in ["crvlist"]:
        gear.log("No selection or invalid Selection", gear.sev_error)
        return

    curve = xsi.Selection(0)
    if curve.ActivePrimitive.Geometry.Curves.Count > 1:
        gear.log("Curve Resampler works only with single curve", gear.sev_error)
        return

    ref_crv = uit.pickSession(c.siCurveFilter, "Pick Reference Curve", False)
    if not ref_crv:
        ref_crv = curve

    op = aop.gear_resampler_op(curve, ref_crv, 0, 1)

    xsi.InspectObj(op)
예제 #27
0
def gear_MatchGeometry_Execute():

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

    target = xsi.Selection(0)
    if target.Type not in ["pntSubComponent", "polymsh", "surfmsh", "crvlist"]:
        gear.log("Invalid Selection, select a geometry or a point selection", gear.sev_error)
        return

    # Get reference
    source = uit.pickSession(c.siGenericObjectFilter, "Pick Source Geometry")
    if not source:
        return

    # Get cluster
    if target.Type == "pntSubComponent":
        obj = target.SubComponent.Parent3DObject
        cls = obj.ActivePrimitive.Geometry.AddCluster(c.siVertexCluster, "gear_MatchGeometryOp_cls", target.SubComponent.ElementArray)
    else:
        obj = target
        cls = obj.ActivePrimitive.Geometry.AddCluster(c.siVertexCluster, "gear_MatchGeometryOp_cls")

    if source.Type != obj.Type:
        gear.log("Invalid Selection", gear.sev_error)
        xsi.DeleteObj(cls)
        return

    # Apply Operator
    op = XSIFactory.CreateObject("gear_MatchGeometryOp")

    op.AddIOPort(obj.ActivePrimitive)
    op.AddInputPort(source.ActivePrimitive)
    op.AddInputPort(cls)
    op.AddInputPort(obj.Kinematics.Global)
    op.AddInputPort(source.Kinematics.Global)

    op.Connect()

    xsi.InspectObj(op)

    return op
예제 #28
0
def gear_CurveResampler_Execute():

    if not xsi.Selection.Count or xsi.Selection(0).Type not in ["crvlist"]:
        gear.log("No selection or invalid Selection", gear.sev_error)
        return

    curve = xsi.Selection(0)
    if curve.ActivePrimitive.Geometry.Curves.Count > 1:
        gear.log("Curve Resampler works only with single curve",
                 gear.sev_error)
        return

    ref_crv = uit.pickSession(c.siCurveFilter, "Pick Reference Curve", False)
    if not ref_crv:
        ref_crv = curve

    op = aop.gear_resampler_op(curve, ref_crv, 0, 1)

    xsi.InspectObj(op)
예제 #29
0
def gear_CurveSlide2Op_Execute():

    if not xsi.Selection.Count or xsi.Selection(0).Type not in ["crvlist"]:
        gear.log("No selection or invalid Selection", gear.sev_error)
        return

    out_crv = xsi.Selection(0)

    if out_crv.ActivePrimitive.Geometry.Curves.Count > 1:
        gear.log("Curve Resampler works only with single curve", gear.sev_error)
        return

    in_crv = uit.pickSession(c.siCurveFilter, "Pick Reference Curve", True)
    if not in_crv:
        return

    op = aop.sn_curveslide2_op(out_crv, in_crv)

    xsi.InspectObj(op)
예제 #30
0
def gear_GuideToolsUI_extractCtrl_OnClicked():

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

    # Get guide target
    guide_model = uit.pickSession(c.siModelFilter, "Pick Guide Model", False)
    if not guide_model:
      return

    if not guide_model.Properties("options"):
      gear.log("Invalid model", gear.sev_error)
      return

    guidectrl_org = guide_model.FindChild("controlers_org")
    guidectrl_grp = guide_model.Groups("controlers_grp")

    # Recreate Controlers -----------------------------
    for rig_ctl in xsi.Selection:

        if guide_model.FindChild(rig_ctl.Name):
            xsi.DeleteObj(guide_model.FindChild(rig_ctl.Name))

        guide_ctl = xsi.Duplicate(rig_ctl, 1,
                                          c.siCurrentHistory,
                                          c.siNoParent,
                                          c.siNoGrouping,
                                          c.siNoProperties,
                                          c.siNoAnimation,
                                          c.siNoConstraints,
                                          c.siNoSelection,
                                          c.siGlobalXForm)(0)

        #Get color from rig
        rR = rig_ctl.Properties('display').Parameters(12).GetValue2(None)
        rG = rig_ctl.Properties('display').Parameters(13).GetValue2(None)
        rB = rig_ctl.Properties('display').Parameters(14).GetValue2(None)
        uti.setColor(guide_ctl, [rR, rG,rB])
        guidectrl_org.AddChild(guide_ctl)
        guidectrl_grp.AddMember(guide_ctl)

        guide_ctl.Name = rig_ctl.Name
예제 #31
0
def gear_NormalizeToDeformer_Execute():

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

    sel = xsi.Selection(0)

    if sel.Type in ["polymsh", "surfmsh", "crvlist"]:
        mesh = sel
        points = range(mesh.ActivePrimitive.Geometry.Points.Count)
    elif sel.Type == "pntSubComponent":
        mesh = sel.SubComponent.Parent3DObject
        points = sel.SubComponent.ElementArray
    else:
        gear.log("Invalid selection", gear.sev_error)
        return

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

    # Get The deformers
    deformers = XSIFactory.CreateObject("XSI.Collection")
    while True:
        deformer =  uit.pickSession(c.siGenericObjectFilter, "Pick Deformer", False)
        if not deformer:
            break

        if env.isDeformer(envelope_op, deformer):
            deformers.Add(deformer)
        else:
            gear.log("Picked object is not a deformer for this envelope", c.siWarning)

    if not deformers.Count:
        return

    # Process
    env.normalizeToDeformer(envelope_op, deformers, points)
    env.freezeEnvelope(envelope_op)
    env.rebuiltEnvelope(envelope_op)
예제 #32
0
def gear_MatchShapeKey_Execute():

    if not xsi.Selection.Count:
        gear.log("Select shape key", gear.sev_error)
        return

    target_shape = xsi.Selection(0)
    if target_shape.Type not in ["clskey"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    source_shape = uit.pickSession(c.siPropertyFilter, "Pick Source Shape", True)
    if not source_shape:
        return

    if source_shape.Type not in ["clskey"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    sha.matchShapeKey(target_shape, source_shape)
예제 #33
0
def gear_MatchShapeKey_Execute():

    if not xsi.Selection.Count:
        gear.log("Select shape key", gear.sev_error)
        return

    target_shape = xsi.Selection(0)
    if target_shape.Type not in ["clskey"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    source_shape = uit.pickSession(c.siPropertyFilter, "Pick Source Shape",
                                   True)
    if not source_shape:
        return

    if source_shape.Type not in ["clskey"]:
        gear.log("Invalid selection", gear.sev_error)
        return

    sha.matchShapeKey(target_shape, source_shape)
예제 #34
0
def gear_CopyEnvWithGator_Execute():

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

    source_meshes = XSIFactory.CreateObject("XSI.Collection")
    while True:
        picked = uit.pickSession(c.siGeometryFilter, "Pick Source Mesh", False)
        if not picked:
            break

        if not ope.getOperatorFromStack(picked, "envelopop"):
            gear.log("No Envelope on " + picked.Name, c.siWarning)
            continue

        source_meshes.Add(picked)

    if not source_meshes:
        return

    for mesh in xsi.Selection:
        env.copyEnvelopeWithGator(mesh, source_meshes)
예제 #35
0
def gear_CopyEnvWithGator_Execute():

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

    source_meshes = XSIFactory.CreateObject("XSI.Collection")
    while True:
        picked = uit.pickSession(c.siGeometryFilter, "Pick Source Mesh", False)
        if not picked:
            break

        if not ope.getOperatorFromStack(picked, "envelopop"):
            gear.log("No Envelope on " + picked.Name, c.siWarning)
            continue

        source_meshes.Add(picked)

    if not source_meshes:
        return

    for mesh in xsi.Selection:
        env.copyEnvelopeWithGator(mesh, source_meshes)
예제 #36
0
def gear_ReplaceDeformer_Execute():

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

    sel = xsi.Selection(0)

    if sel.Type == "polymsh":
        mesh = sel
        points = range(mesh.ActivePrimitive.Geometry.Points.Count)
    elif sel.Type == "pntSubComponent":
        mesh = sel.SubComponent.Parent3DObject
        points = sel.SubComponent.ElementArray
    else:
        gear.log("Invalid selection", gear.sev_error)
        return

    # Get Envelope from object
    envelope_op = ope.getOperatorFromStack(mesh, "envelopop")
    if not envelope_op:
        gear.log("There is no envelope on selected mesh", gear.sev_error)
        return False

    # Source deformers
    source_deformers = XSIFactory.CreateObject("XSI.Collection")
    while True:
        picked = uit.pickSession(c.siGenericObjectFilter,
                                 "Pick Source Deformers", False)
        if not picked:
            break

        if picked.Type == "#Group":
            source_deformers.AddItems(picked.Members)
        else:
            source_deformers.Add(picked)

    if not source_deformers.Count:
        return False

    # Target deformers
    target_deformers = XSIFactory.CreateObject("XSI.Collection")
    while True:
        picked = uit.pickSession(c.siGenericObjectFilter,
                                 "Pick Target Deformers", False)
        if not picked:
            break

        if picked.Type == "#Group":
            target_deformers.AddItems(picked.Members)
        else:
            target_deformers.Add(picked)

    if not target_deformers.Count:
        return False

    # Some log to be sure of what we have selected
    gear.log("Geometry: " + mesh.FullName + "  \nSource(s): " +
             str(source_deformers) + "  \nTarget(s): " + str(target_deformers))

    env.replaceDeformerInEnvelope(envelope_op, source_deformers,
                                  target_deformers, points)