Esempio n. 1
0
def gear_InspectSolvers_Execute( ):

    if xsi.Selection.Count:
        try:
            xsi.InspectObj(".Kine.Global.sn_*")
        except:
            lm("Any of the selected objects have GEAR,s 'sn_solver' solvers", 2)
Esempio n. 2
0
def gear_InspectSolvers_Execute():

    if xsi.Selection.Count:
        try:
            xsi.InspectObj(".Kine.Global.sn_*")
        except:
            lm("Any of the selected objects have GEAR,s 'sn_solver' solvers",
               2)
Esempio n. 3
0
def gear_createIcon_Execute(iconPreset):
    reload(gear.xsi.icon)
    funcDic = {"cube":icon.cube,
                "pyramid":icon.pyramid,
                "square":icon.square,
                "flower":icon.flower,
                "circle":icon.circle,
                "cylinder":icon.cylinder,
                "compas":icon.compas,
                "foil":icon.foil,
                "diamond":icon.diamond,
                "leash":icon.leash,
                "cubewithpeak":icon.cubewithpeak,
                "sphere":icon.sphere,
                "arrow":icon.arrow,
                "crossarrow":icon.crossarrow,
                "bendedarrow":icon.bendedarrow,
                "bendedarrow2":icon.bendedarrow2,
                "cross":icon.cross,
                "glasses":icon.glasses,
                "lookat":icon.lookat,
                "eyearrow":icon.eyearrow,
                "anglesurvey":icon.anglesurvey,
                "eyeball":icon.eyeball,
                "rectanglecube":icon.rectanglecube,
                "man":icon.man,
                "null":icon.null,
                "boomerang":icon.boomerang}


    if xsi.Selection.Count:
        XSIDial  = XSIFactory.CreateObject(  "XSIDial.XSIDialog")

        items = ["Only in Place", "Make it Parent", "Make it Child"]
        out = XSIDial.Combo("Creating Controls on Selected Objects", items)
        if out == -1:
            lm("Controls creation cancelled")
            return
        for obj in xsi.Selection:
            crv = funcDic[iconPreset]()
            source_object = obj

            tra.matchGlobalTransform( crv, source_object)
            if out == 1:
                oParent = obj.Parent
                #check if 2 objects have the same parent.
                if oParent.Name != crv.Parent.Name:
                    xsi.ParentObj(oParent, crv)
                xsi.ParentObj(crv, obj)
            elif out == 2:
                xsi.ParentObj(obj, crv)
            crv.Name = obj.Name + "_" + iconPreset
    else:
        crv = funcDic[iconPreset]()
        xsi.SelectObj(crv)
    return crv
Esempio n. 4
0
def gear_selectionSets_outObject_OnClicked():
    from win32com.client import constants as c
    oList = PPG.pSetsList.Value.split(";")[0]

    if len(oList) <= 1:
        xsi.LogMessage("Select one Set before remove objects to it, and Only one set at the time", 4)
    else:
        oReturn = XSIUIToolkit.MsgBox( "REMOVE Selected objects to first selected Set?, Remember if you have more than one set, only the first one will be used. ", c.siMsgYesNo )
        if oReturn:
            xsi.RemoveFromGroup(oList)

        else:
            lm("You cancel the adding operation.", 4)
Esempio n. 5
0
def gear_poseLibManager_removePose_OnClicked():
    oSel = xsi.Selection(0)
    if oSel and oSel.Type == "customparamset":
        oParam = oSel.Parameters("poseEditList")
        if oParam:
            currPose = oSel.Parameters("poseEditList").Value.split(";")
            setName = oSel.Name
            xsi.DeleteObj(oSel)
            gear_poseLibManager_createPoseSet_OnClicked(currPose , setName, True)

        else:
            lm("The custom paramenter set selected is not a Pose Set", 4)
    else:
        lm("Select a custom paramenter set", 4)
Esempio n. 6
0
def gear_poseLibManager_syncPose_OnClicked():
    oSel = xsi.Selection(0)
    if oSel and oSel.Type == "customparamset":
        oParam = oSel.Parameters("poseEditList")
        if oParam:
            pose_items = []
            rawList = oSel.Parameters("poseEditList").Value.split(";")
            for posePath in rawList:
                pose_items.append(posePath.split(SEP)[-1])
                pose_items.append(posePath)
                gear_poseLibManager_refreshList_OnClicked(pose_items)
        else:
            lm("The custom paramenter set selected is not a Pose Set", 4)
    else:
        lm("Select a custom paramenter set", 4)
Esempio n. 7
0
def gear_InspectGuideSettings_Execute():
    if xsi.Selection.Count:
        oSel = xsi.Selection(0)
        settings = False
        while not settings :
            if oSel.Properties("settings"):
                settings = oSel.Properties("settings")
                xsi.InspectObj(settings)
            else:
                oSel = oSel.Parent
                if oSel.Type == "#model":
                    settings = True
                    lm("The selected object is not part of a guide, or the guide do not have settings", 4)
    else:
        lm("Nothing selected. Please select an object from a GEAR guide", 4)
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
0
def gear_selectionSets_deleteSet_OnClicked():
    from win32com.client import constants as c

    oList = PPG.pSetsList.Value.split(";")[0]
    for x in PPG.pSetsList.Value.split(";")[1:]:
        oList = oList + "," + x
    if len(oList) <= 1:
        xsi.LogMessage("Select a Set before Delete it", 4)
    else:
        oReturn = XSIUIToolkit.MsgBox(
            "Are you sure? Want to delete selected sets?", c.siMsgYesNo)
        if oReturn:
            xsi.DeleteObj(oList)
            gear_selectionSets_OnInit()
        else:
            lm("You cancel the delete operation.")
Esempio n. 11
0
def gear_selectionSets_outObject_OnClicked():
    from win32com.client import constants as c
    oList = PPG.pSetsList.Value.split(";")[0]

    if len(oList) <= 1:
        xsi.LogMessage(
            "Select one Set before remove objects to it, and Only one set at the time",
            4)
    else:
        oReturn = XSIUIToolkit.MsgBox(
            "REMOVE Selected objects to first selected Set?, Remember if you have more than one set, only the first one will be used. ",
            c.siMsgYesNo)
        if oReturn:
            xsi.RemoveFromGroup(oList)

        else:
            lm("You cancel the adding operation.", 4)
Esempio n. 12
0
def gear_selectionSets_deleteSet_OnClicked():
    from win32com.client import constants as c



    oList = PPG.pSetsList.Value.split(";")[0]
    for x in PPG.pSetsList.Value.split(";")[1:]:
        oList = oList + "," + x
    if len(oList) <= 1:
        xsi.LogMessage("Select a Set before Delete it", 4)
    else:
        oReturn = XSIUIToolkit.MsgBox( "Are you sure? Want to delete selected sets?", c.siMsgYesNo )
        if oReturn:
            xsi.DeleteObj(oList)
            gear_selectionSets_OnInit()
        else:
            lm("You cancel the delete operation.")
Esempio n. 13
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 )
Esempio n. 14
0
def gear_groupManagerProp_OnInit( ):
    lm("gear_groupManager_OnInit called",c.siVerbose)
    group = PPG.grpName.Parent.Parent
    PPG.grpName.Value = group.FullName
    vVal = group.Parameters("viewvis").Value
    rVal = group.Parameters("rendvis").Value
    sVal = group.Parameters("selectability").Value

    if vVal:
        PPG.Vis.Value = True
    else:
        PPG.Vis.Value = False

    if rVal:
        PPG.Ren.Value = True
    else:
        PPG.Ren.Value = False

    if sVal:
        PPG.Select.Value = True
    else:
        PPG.Select.Value = False
    PPG.Refresh()
Esempio n. 15
0
def gear_groupManagerProp_OnInit():
    lm("gear_groupManager_OnInit called", c.siVerbose)
    group = PPG.grpName.Parent.Parent
    PPG.grpName.Value = group.FullName
    vVal = group.Parameters("viewvis").Value
    rVal = group.Parameters("rendvis").Value
    sVal = group.Parameters("selectability").Value

    if vVal:
        PPG.Vis.Value = True
    else:
        PPG.Vis.Value = False

    if rVal:
        PPG.Ren.Value = True
    else:
        PPG.Ren.Value = False

    if sVal:
        PPG.Select.Value = True
    else:
        PPG.Select.Value = False
    PPG.Refresh()
Esempio n. 16
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)
Esempio n. 17
0
def gear_poseLibManager_refreshList_OnClicked(Sync = False):
    repo = PPG.parRepo.Value
    user = PPG.parUser.Value
    model = PPG.parModel.Value

    currentProject = xsi.ActiveProject2.Path
    currentRepoPath = os.path.join(currentProject, "PoseLib")


    if xsi.Preferences.Categories("gear_prefPoseLib"):
        globlaRepoPath = xsi.GetValue("preferences.gear_prefPoseLib.global_Repo")
    else:
        globlaRepoPath = False

    oSel = xsi.Selection

    #Populating List
    if Sync:
        pose_items = Sync
    else:
        pose_items = []

        if repo in ["Current_DB", "Both"]:
                if user == "All":
                    oUserFolders = [d for d in os.listdir(currentRepoPath)]
                    for oFolder in oUserFolders:
                        oPoseFolders = [d for d in os.listdir(os.path.join(currentRepoPath, oFolder))]
                        if model == "All":
                            for iPose in oPoseFolders:
                                pose_items.append(oFolder+" : "+iPose)
                                pose_items.append(os.path.join(currentRepoPath, oFolder, iPose))
                        elif model == "Selected":
                            oModelCheck = []
                            for iSel in oSel:
                                if iSel.Type == "#model":
                                    oModelCheck.append(iSel.Name.split("_")[0])
                                else:
                                    oModelCheck.append(iSel.Model.Name.split("_")[0])
                            for iPose in oPoseFolders:
                                if iPose.split("_")[0] in oModelCheck:
                                    pose_items.append(oFolder+" : "+iPose)
                                    pose_items.append(os.path.join(currentRepoPath, oFolder, iPose))
                        elif model == "In_Scene":
                            oRoot = xsi.ActiveSceneRoot
                            oModelCheck = []
                            for iModel in oRoot.FindChildren2():
                                if iModel.Type == "#model":
                                    oModelCheck.append(iModel.Name.split("_")[0])
                            for iPose in oPoseFolders:
                                if iPose.split("_")[0] in oModelCheck:
                                    pose_items.append(oFolder+" : "+iPose)
                                    pose_items.append(os.path.join(currentRepoPath, oFolder, iPose))

                else:
                    if user == "Self":
                        userName = os.environ.get( "USERNAME" )
                    else:
                        userName = user
                    if os.path.isdir(os.path.join(currentRepoPath, userName)):
                        oPoseFolders = [d for d in os.listdir(os.path.join(currentRepoPath, userName))]
                        if model == "All":
                            for iPose in oPoseFolders:
                                pose_items.append(iPose)
                                pose_items.append(os.path.join(currentRepoPath, userName, iPose))
                        elif model == "Selected":
                            oModelCheck = []
                            for iSel in oSel:
                                if iSel.Type == "#model":
                                    oModelCheck.append(iSel.Name.split("_")[0])
                                else:
                                    oModelCheck.append(iSel.Model.Name.split("_")[0])
                            for iPose in oPoseFolders:
                                if iPose.split("_")[0] in oModelCheck:
                                    pose_items.append(iPose)
                                    pose_items.append(os.path.join(currentRepoPath, userName, iPose))
                        elif model == "In_Scene":
                            oRoot = xsi.ActiveSceneRoot
                            oModelCheck = []
                            for iModel in oRoot.FindChildren2():
                                if iModel.Type == "#model":
                                    oModelCheck.append(iModel.Name.split("_")[0])
                            for iPose in oPoseFolders:
                                if iPose.split("_")[0] in oModelCheck:
                                    pose_items.append(iPose)
                                    pose_items.append(os.path.join(currentRepoPath, userName, iPose))
                    else:
                         lm("No poses found for: " + userName, 4)


        if repo in ["Global", "Both"]:
            if globlaRepoPath :
                if user == "All":
                    oUserFolders = [d for d in os.listdir(globlaRepoPath)]
                    for oFolder in oUserFolders:
                        oPoseFolders = [d for d in os.listdir(os.path.join(globlaRepoPath, oFolder))]
                        if model == "All":
                            for iPose in oPoseFolders:
                                pose_items.append("Global: "+oFolder+" : "+iPose)
                                pose_items.append(os.path.join(globlaRepoPath, oFolder, iPose))
                        elif model == "Selected":
                            oModelCheck = []
                            for iSel in oSel:
                                if iSel.Type == "#model":
                                    oModelCheck.append(iSel.Name.split("_")[0])
                                else:
                                    oModelCheck.append(iSel.Model.Name.split("_")[0])
                            for iPose in oPoseFolders:
                                if iPose.split("_")[0] in oModelCheck:
                                    pose_items.append("Global: "+oFolder+" : "+iPose)
                                    pose_items.append(os.path.join(globlaRepoPath, oFolder, iPose))
                        elif model == "In_Scene":
                            oRoot = xsi.ActiveSceneRoot
                            oModelCheck = []
                            for iModel in oRoot.FindChildren2():
                                if iModel.Type == "#model":
                                    oModelCheck.append(iModel.Name.split("_")[0])
                            for iPose in oPoseFolders:
                                if iPose.split("_")[0] in oModelCheck:
                                    pose_items.append("Global: "+oFolder+" : "+iPose)
                                    pose_items.append(os.path.join(globlaRepoPath, oFolder, iPose))

                else:
                    if user == "Self":
                        userName = os.environ.get( "USERNAME" )
                    else:
                        userName = user
                    if os.path.isdir(os.path.join(globlaRepoPath, userName)):
                        oPoseFolders = [d for d in os.listdir(os.path.join(globlaRepoPath, userName))]
                        if model == "All":
                            for iPose in oPoseFolders:
                                pose_items.append("Global: "+iPose)
                                pose_items.append(os.path.join(globlaRepoPath, userName, iPose))
                        elif model == "Selected":
                            oModelCheck = []
                            for iSel in oSel:
                                if iSel.Type == "#model":
                                    oModelCheck.append(iSel.Name.split("_")[0])
                                else:
                                    oModelCheck.append(iSel.Model.Name.split("_")[0])
                            for iPose in oPoseFolders:
                                if iPose.split("_")[0] in oModelCheck:
                                    pose_items.append("Global: "+iPose)
                                    pose_items.append(os.path.join(globlaRepoPath, userName, iPose))
                        elif model == "In_Scene":
                            oRoot = xsi.ActiveSceneRoot
                            oModelCheck = []
                            for iModel in oRoot.FindChildren2():
                                if iModel.Type == "#model":
                                    oModelCheck.append(iModel.Name.split("_")[0])
                            for iPose in oPoseFolders:
                                if iPose.split("_")[0] in oModelCheck:
                                    pose_items.append("Global: "+iPose)
                                    pose_items.append(os.path.join(globlaRepoPath, userName, iPose))
            else:
                lm("No poses found", 4)




    gear_poseLibManager_OnInit(repo , user, model, pose_items)
Esempio n. 18
0
def gear_newPoseProp_saveNewPose_OnClicked():


    #Check if the name is valid
    oName = PPG.parPoseName.Value
    if not  oName.isalnum():
        lm("The name is not valid, use alphanumeric characters only ", 2)
    else:
        #Check is something is selected
        oSel = xsi.Selection
        if oSel.Count:
            #Construt the path
            userName = os.environ.get( "USERNAME" )
            #Global Path
            if PPG.parRepo.Value == "Global":
                if xsi.Preferences.Categories("gear_prefPoseLib"):
                    globalPath = Application.GetValue("preferences.gear_prefPoseLib.global_Repo")
                else:
                    globalPath = "Ops! you forget to set the preferences"
                    userPath = False

                if  os.path.isdir(globalPath):
                    userPath = os.path.join(globalPath, userName)
                    if not os.path.isdir(userPath):
                        os.makedirs(userPath)

                else:
                    lm("Global Path preferences are not set correctly. Looks like the folder: " + globalPath +" Doesn't exist.", 4 )

            #Current DB user path
            else:
                currentProject = xsi.ActiveProject2.Path
                currentPosePath = os.path.join(currentProject, "PoseLib")
                if not os.path.isdir(currentPosePath):
                    os.makedirs(currentPosePath)
                    lm("New folder for poses in the current datebase (DB) was created: " + currentPosePath )

                userPath = os.path.join(currentPosePath, userName)
                if not os.path.isdir(userPath):
                    os.makedirs(userPath)

            if userPath:
                oModel = oSel(0).Model
                modName = oModel.Name.split("_")[0]
                #Check if the pose exist and ask for overwrite
                oReturn = 6 # is the return value fo "yes" in the msgBox. We use it as default.
                if os.path.isdir(os.path.join(userPath, modName + "_" + oName)):
                   oReturn = XSIUIToolkit.MsgBox( "The pose exist!!. Do you want to overwrite it?", c.siMsgYesNo )
                else:
                    #Create folders if doesn't exist
                    os.makedirs(os.path.join(userPath, modName + "_" + oName))
                if oReturn == 6:
                    #Create xml pose
                    oModel = oSel(0).Model
                    root = xml.Element(oModel.Name)

                    # Function indentation ===============================
                    def indent(elem, level=0):
                        i = "\n" + level*" "
                        if len(elem):
                            if not elem.text or not elem.text.strip():
                                elem.text = i + " "
                            if not elem.tail or not elem.tail.strip():
                                elem.tail = i
                            for elem in elem:
                                indent(elem, level+1)
                            if not elem.tail or not elem.tail.strip():
                                elem.tail = i
                        else:
                            if level and (not elem.tail or not elem.tail.strip()):
                                elem.tail = i
                    # ===========================================


                    for oItem in oSel:
                        collection = XSIFactory.CreateActiveXObject( "XSI.Collection" )

                        collection.AddItems( oItem )

                        oKeyable = collection.FindObjectsByMarkingAndCapabilities( None, c.siKeyable )

                        child = xml.Element(oItem.Name)
                        root.append(child)

                        for oParam in oKeyable:
                            childParam = xml.Element(".".join(oParam.FullName.split(".")[2:]))
                            childParam.attrib["Value"] = str(oParam.Value)
                            #childParam.attrib["scriptName"] = str(oParam.ScriptName)
                            child.append(childParam)

                    indent(root)
                    posePath = os.path.join(userPath, modName +  "_" + oName, oName + ".xml")
                    file = open(posePath, "w")

                    xml.ElementTree(root).write(file)

                    file.close()

                    #Capture the image
                    currFrame = xsi.ActiveProject.Properties("Play Control").Parameters("Current").Value

                    oViewportCapture = xsi.Dictionary.GetObject("ViewportCapture")


                    xsi.SetValue("Views.view*.*Camera.camvis.gridaxisvis", False, "")
                    xsi.SetValue("Views.view*.*Camera.camvis.constructionlevel", False, "")
                    xsi.SetValue("*Camera.camvis.gridaxisvis", False, "")
                    xsi.SetValue("*Camera.camvis.constructionlevel", False, "")

                    oViewportCapture.NestedObjects[0].PutValue2(None, os.path.join(userPath, modName + "_" + oName, oName + ".jpg"))  # path FileName
                    oViewportCapture.NestedObjects[1].PutValue2(None, "(fn)(ext)")  # frame Padding
                    oViewportCapture.NestedObjects[2].PutValue2(None, "75")  # Width
                    oViewportCapture.NestedObjects[3].PutValue2(None, "75")  # Height
                    oViewportCapture.NestedObjects[4].PutValue2(None, "1")  # Scale Factor
                    oViewportCapture.NestedObjects[5].PutValue2(None, "True")  # user pixel ratio
                    oViewportCapture.NestedObjects[6].PutValue2(None, "1.0")  # pixel ratio
                    oViewportCapture.NestedObjects[10].PutValue2(None, currFrame) # Start Frame
                    oViewportCapture.NestedObjects[11].PutValue2(None, currFrame) # End Frame
                    oViewportCapture.NestedObjects[12].PutValue2(None, "False")  # Launch Flipbook

                    xsi.CaptureViewport( -1, False )

                    xsi.SetValue("Views.view*.*Camera.camvis.gridaxisvis", True, "")
                    xsi.SetValue("Views.view*.*Camera.camvis.constructionlevel", True, "")
                    xsi.SetValue("*Camera.camvis.gridaxisvis", True, "")
                    xsi.SetValue("*Camera.camvis.constructionlevel", True, "")

                    #Create the miniSynoptic
                    imageName = oName +".jpg"
                    oDate =  strftime("%a, %d %b %Y %H:%M:%S")
                    synCretor(posePath, imageName,  oName, userName, oDate, oModel.Name)
                else:
                    lm("Creation cancelled", 2)
            else:
                lm("Set preferences before save poses in the global repo", 2)
        else:
            lm("Nothing selected, Pose can not be stored", 2)

    PPG.Close()
    if xsi.ActiveSceneRoot.Properties("gear_newPoseProp"):
        xsi.DeleteObj(xsi.ActiveSceneRoot.Properties("gear_newPoseProp"))
Esempio n. 19
0
def gear_groupManager_DefineLayout(in_ctxt):
    lm("gear_groupManager_DefineLayout called", c.siVerbose)
Esempio n. 20
0
def XSIUnloadPlugin(in_reg):
    strPluginName = in_reg.Name
    lm(str(strPluginName) + str(" has been unloaded."), c.siVerbose)
    return true
Esempio n. 21
0
def XSIUnloadPlugin( in_reg ):
    strPluginName = in_reg.Name
    lm(str(strPluginName) + str(" has been unloaded."),c.siVerbose)
    return true
Esempio n. 22
0
def gear_groupManager_DefineLayout( in_ctxt ):
    lm("gear_groupManager_DefineLayout called",c.siVerbose)