Beispiel #1
0
    def setTimelineRange(self, range=None, *args):

        rangeVisible = cmds.timeControl(G.playBackSliderPython,
                                        query=True,
                                        rangeVisible=True)

        if not rangeVisible and not range:
            range = [
                cmds.playbackOptions(query=True, minTime=True),
                cmds.playbackOptions(query=True, maxTime=True) + 1
            ]

        if range or rangeVisible:

            if not range: range = animMod.getTimelineRange(float=False)
            rFrom = range[0]
            rTo = range[1] - 1

            cmds.playbackOptions(minTime=rFrom, maxTime=rTo)

            if self.getTimelineRanges() != None:
                ranges = eval(self.getTimelineRanges())
            else:
                ranges = []
            if not range in ranges:
                ranges.append(range)
                aToolsMod.saveInfoWithScene(STORE_NODE, RANGE_ATTR, ranges)

        utilMod.deselectTimelineRange()
Beispiel #2
0
 def loadTwistObjsInfo(self):
     loadInfo = aToolsMod.loadInfoWithScene(self.STORE_NODE,
                                            self.MOTION_TRAIL_ATTR)
     if loadInfo:
         self.twistIkObjs = eval(loadInfo)
         # set ik twist back to 1
         self.reenableTwistObjs()
         aToolsMod.saveInfoWithScene(self.STORE_NODE,
                                     self.MOTION_TRAIL_ATTR, [])
Beispiel #3
0
 def saveTwistObjsInfo(self):
     self.loadTwistObjsInfo()
     # get twist ik objs
     self.twistIkObjs = []
     splineIkObjs = cmds.ls(type="ikHandle")
     for loopObj in splineIkObjs:
         att = "%s.dTwistControlEnable" % loopObj
         if cmds.objExists(att):
             if cmds.getAttr(att) == True:
                 self.twistIkObjs.append(loopObj)
     # set ik twist to 0
     aToolsMod.saveInfoWithScene(self.STORE_NODE, self.MOTION_TRAIL_ATTR,
                                 self.twistIkObjs)
Beispiel #4
0
def getShotCamera():
    STORE_NODE = "tUtilities"
    CAMERA_ATTR = "cameraSelected"

    shotCamera = aToolsMod.loadInfoWithScene(STORE_NODE, CAMERA_ATTR)

    if not shotCamera:
        cameras = utilMod.getAllCameras()
        if cameras:
            aToolsMod.saveInfoWithScene(STORE_NODE, CAMERA_ATTR, cameras[0])
            return cameras[0]

    return shotCamera
Beispiel #5
0
    def create(self, *args):

        img = cmds.iconTextButton("TempCustomPivotBtn", query=True, image=True)
        onOff = (img[-10:-4] == "active")
        if onOff:
            self.clear()
            cmds.select(self.sel)
            return

        cmds.undoInfo(openChunk=True)
        cmds.undoInfo(closeChunk=True)
        cmds.undoInfo(openChunk=True)
        cmds.undoInfo(closeChunk=True)
        cmds.undoInfo(openChunk=True)
        cmds.undoInfo(closeChunk=True)
        cmds.undoInfo(openChunk=True)

        self.clear()

        getCurves = animMod.getAnimCurves()
        animCurves = getCurves[0]
        getFrom = getCurves[1]

        if animCurves:
            keyTimes = animMod.getTarget("keyTimes", animCurves, getFrom)

        self.sel = cmds.ls(selection=True)
        if not self.sel: return

        cmds.iconTextButton(
            "TempCustomPivotBtn",
            edit=True,
            image=uiMod.getImagePath(
                "specialTools_create_temp_custom_pivot_active"),
            highlightImage=uiMod.getImagePath(
                "specialTools_create_temp_custom_pivot_active"))

        targetObj = self.sel[-1]
        aToolsMod.saveInfoWithScene(self.STORE_NODE, self.CTRLS, self.sel)

        currentFrame = cmds.currentTime(query=True)
        aToolsMod.saveInfoWithScene(self.STORE_NODE, self.CURRENTFRAME,
                                    currentFrame)

        locators = []
        for loopSel in self.sel:
            nameSpace = utilMod.getNameSpace([loopSel])
            loopSelName = "%s_%s" % (nameSpace[0][0], nameSpace[1][0])
            locatorName = "tempCustomPivot_%s" % loopSelName

            locator = animMod.createNull(locatorName)
            locators.append(locator)

            G.aToolsBar.align.align([locator], loopSel)

        locatorGroup = "tempCustomPivot_group"
        animMod.group(name=locatorGroup)
        G.aToolsBar.align.align([locatorGroup], targetObj)
        with G.aToolsBar.createAToolsNode:
            cmds.parent(locators, locatorGroup)
        cmds.select(locatorGroup, replace=True)

        locators.append(locatorGroup)

        aToolsMod.saveInfoWithScene(self.STORE_NODE, self.LOCATORS, locators)

        #parent ctrls to locator
        constraints = [
            "%s_tempCustomPivot_constraint" % loopConstraint
            for loopConstraint in self.sel
        ]

        aToolsMod.saveInfoWithScene(self.STORE_NODE, self.CONSTRAINTS,
                                    constraints)

        for n, loopSel in enumerate(self.sel):
            with G.aToolsBar.createAToolsNode:
                cmds.parentConstraint(locators[n],
                                      loopSel,
                                      name=constraints[n],
                                      maintainOffset=True)
            constraintNode = "%s.blendParent1" % loopSel
            if not cmds.objExists(constraintNode): continue
            cmds.setKeyframe(constraintNode)
            if keyTimes:
                for loopTime in keyTimes[0]:
                    cmds.setKeyframe("%s.tx" % locatorGroup,
                                     time=(loopTime, loopTime))
                    if loopTime != currentFrame:
                        cmds.setKeyframe(constraintNode,
                                         time=(loopTime, loopTime),
                                         value=0)

        #enter edit mode
        cmds.setToolTo(cmds.currentCtx())
        cmds.ctxEditMode()

        #scriptjob
        cmds.scriptJob(runOnce=True,
                       killWithScene=True,
                       event=('SelectionChanged',
                              self.scriptJob_SelectionChanged))
Beispiel #6
0
 def deleteAllTimelineRange(self, *args):
     aToolsMod.saveInfoWithScene(STORE_NODE, RANGE_ATTR, [])
Beispiel #7
0
    def deleteTimelineRange(self, range=None, *args):

        ranges = eval(self.getTimelineRanges())
        if not ranges: ranges = []
        if range in ranges: ranges.remove(range)
        aToolsMod.saveInfoWithScene(STORE_NODE, RANGE_ATTR, ranges)