Пример #1
0
def mirror_getNextIndex(self, side):
    try:
        _str_func = ' mirror_getNextIndex'.format(self)
        log.debug("|{0}| >> ... [{1}]".format(_str_func, self) + '-' * 80)

        l_return = []
        ml_modules = modules_get(self)
        int_lenModules = len(ml_modules)
        str_side = cgmGEN.verify_mirrorSideArg(side)
        for i, mModule in enumerate(ml_modules):
            #self.log.info("Checking: '%s'"%mModule.p_nameShort)
            _str_module = mModule.p_nameShort
            if mModule.get_mirrorSideAsString() == str_side:
                #self.progressBar_set(status = "Checking Module: '%s' "%(_str_module),progress = i, maxValue = int_lenModules)
                try:
                    mi_moduleSet = mModule.rigNull.moduleSet.getMetaList()
                except:
                    mi_moduleSet = []
                for mObj in mi_moduleSet:
                    int_side = mObj.getAttr('mirrorSide')
                    int_idx = mObj.getAttr('mirrorIndex')
                    str_side = mObj.getEnumValueString('mirrorSide')
                    l_return.append(int_idx)
                    l_return.sort()

        if l_return:
            return max(l_return) + 1
        else:
            return 0

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #2
0
def mirror_getDict(self):
    try:
        _str_func = ' mirror_getDict'.format(self)
        log.debug("|{0}| >> ... [{1}]".format(_str_func, self) + '-' * 80)

        d_return = {}
        ml_modules = modules_get(self)
        int_lenModules = len(ml_modules)

        for i, mModule in enumerate(ml_modules):
            _str_module = mModule.p_nameShort
            try:
                mi_moduleSet = mModule.rigNull.moduleSet.getMetaList()
            except:
                mi_moduleSet = []
            for mObj in mi_moduleSet:

                if mObj.hasAttr('mirrorSide') and mObj.hasAttr('mirrorIndex'):
                    int_side = mObj.getAttr('mirrorSide')
                    int_idx = mObj.getAttr('mirrorIndex')
                    str_side = mObj.getEnumValueString('mirrorSide')

                    if not d_return.get(int_side):
                        d_return[int_side] = []

                    if int_idx in d_return[int_side]:
                        pass
                        #self.log_debug("%s mModule: %s | side: %s | idx :%s already stored"%(self._str_reportStart,_str_module, str_side,int_idx))
                    else:
                        d_return[int_side].append(int_idx)
        return d_return

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #3
0
def module_connect(self, mModule, **kws):
    try:
        _short = self.p_nameShort
        _str_func = ' module_connect'.format(self)
        log.debug("|{0}| >> ... [{1}]".format(_str_func, self) + '-' * 80)

        ml_buffer = copy.copy(self.getMessage(
            'moduleChildren', asMeta=True)) or [
            ]  #Buffer till we have have append functionality
        #self.i_masterNull = self.masterNull

        mModule = cgmMeta.validateObjArg(mModule, 'cgmRigModule')

        if mModule not in ml_buffer:
            ml_buffer.append(mModule)
            self.__setMessageAttr__(
                'moduleChildren', [mObj.mNode for mObj in ml_buffer]
            )  #Going to manually maintaining these so we can use simpleMessage attr  parents

        mModule.modulePuppet = self.mNode

        mModule.parent = self.masterNull.partsGroup.mNode

        if mModule.getMessage('moduleMirror'):
            log.debug(
                "|{0}| >> moduleMirror found. connecting...".format(_str_func))
            #module_connect(self,mModule.moduleMirror)

        return True

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #4
0
def cgmSnapTools():
    try:
        import cgm.core.tools.snapTools as SNAP
        reload(SNAP)
        SNAP.ui()
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #5
0
def distanceMeasure(start=None, end=None, baseName='measureThis', asMeta=True):
    """
    Get the the closest return based on a source and target and variable modes
    
    :parameters:
        :start(str): Our start obj
        :end(str): End obj
        :baseName(str):What mode are we checking data from
        :asMeta(bool)
    :returns
        {shape,dag,loc_start,loc_end,start,end}
    """
    try:
        _str_func = 'create_distanceMeasure'

        _res = DIST.create_distanceMeasure(start, end, baseName)

        if not asMeta:
            return _res

        _res['mShape'] = cgmMeta.asMeta(_res['shape'])
        _res['mDag'] = cgmMeta.asMeta(_res['dag'])
        _res['mStart'] = cgmMeta.asMeta(_res['start'])
        _res['mEnd'] = cgmMeta.asMeta(_res['end'])
        if _res.get('loc_start'):
            _res['mLoc_start'] = cgmMeta.asMeta(_res['loc_start'])
        if _res.get('loc_end'):
            _res['mLoc_end'] = cgmMeta.asMeta(_res['loc_end'])
        return _res
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #6
0
def rigJoint_connect(joints=[]):
    try:
        if not joints:
            joints = mc.ls(sl=True, type='joint')

        ml_joints = cgmMeta.validateObjListArg(joints, 'cgmObject')
        ml_rigJoints = []

        for i, mObj in enumerate(ml_joints):
            mDirect = mObj.getMessageAsMeta('rigJoint')
            if not mDirect:
                log.error("{0} missing rig joint!".format(mObj.p_nameShort))
                continue
            ml_rigJoints.append(mDirect)
            mc.pointConstraint([mDirect.mNode],
                               mObj.mNode,
                               maintainOffset=True)
            mc.orientConstraint([mDirect.mNode],
                                mObj.mNode,
                                maintainOffset=True)
            mc.scaleConstraint([mDirect.mNode],
                               mObj.mNode,
                               maintainOffset=True)

        return ml_rigJoints

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, msg=vars())
Пример #7
0
def rigJoint_connectFromRig(joints=[]):
    try:
        if not joints:
            joints = mc.ls(sl=True, type='joint')

        ml_joints = cgmMeta.validateObjListArg(joints, 'cgmObject')
        ml_rigJoints = []

        for i, mObj in enumerate(ml_joints):
            mDriven = mObj.getMessageAsMeta('skinJoint')
            if not mDriven:
                log.error("{0} missing skin joint!".format(mObj.p_nameShort))
                continue
            ml_rigJoints.append(mDriven)
            log.error("Connecting {0} --> {1}".format(mObj.p_nameShort,
                                                      mDriven.p_nameShort))

            mc.pointConstraint([mObj.mNode],
                               mDriven.mNode,
                               maintainOffset=True)
            mc.orientConstraint([mObj.mNode],
                                mDriven.mNode,
                                maintainOffset=True)
        return ml_rigJoints

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, msg=vars())
Пример #8
0
def mocapBakeTool():
    try:
        import cgm.core.tools.mocapBakeTools as MOCAPBAKE
        reload(MOCAPBAKE)
        MOCAPBAKE.ui()
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #9
0
def segment_handles(self, ml_handles=None):
    try:
        _str_func = 'segment_handles'
        log_start(_str_func)

        mBlock = self.mBlock
        mRigNull = self.mRigNull
        _offset = self.v_offset
        _jointOrientation = self.d_orientation['str']

        if not ml_handles:
            raise ValueError, "{0} | ml_handles required".format(_str_func)

        ml_handleShapes = self.atBuilderUtils(
            'shapes_fromCast',
            targets=ml_handles,
            offset=_offset,
            mode='limbSegmentHandle')  #'segmentHandle') limbSegmentHandle

        for i, mCrv in enumerate(ml_handleShapes):
            log.debug("|{0}| >> Shape: {1} | Handle: {2}".format(
                _str_func, mCrv.mNode, ml_handles[i].mNode))
            self.mHandleFactory.color(mCrv.mNode, controlType='sub')
            CORERIG.shapeParent_in_place(ml_handles[i].mNode,
                                         mCrv.mNode,
                                         False,
                                         replaceShapes=True)

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, localDat=vars())
Пример #10
0
def skeleton_build(self):
    #
    try:
        if skeleton_check(self):
            return True
        if self.addMotionJoint:
            mPuppet = self.moduleTarget
            if not mPuppet:
                raise ValueError, "No moduleTarget connected"

            mJoint = self.rootMotionHelper.doCreateAt('joint')
            mPuppet.connectChildNode(mJoint, 'rootJoint', 'module')
            mJoint.connectParentNode(self, 'module', 'rootJoint')
            mJoint.doStore('cgmName', 'ignore')
            #self.copyAttrTo('cgmName',mJoint.mNode,'cgmName',driven='target')
            mJoint.doStore('cgmTypeModifier', 'rootMotion')
            mJoint.doName()

            mJoint.radius = self.controlOffset

            #self.atBlockUtils('skeleton_connectToParent')
            if self.moduleTarget.masterNull.getMessage('skeletonGroup'):
                mJoint.p_parent = self.moduleTarget.masterNull.skeletonGroup
            return mJoint.mNode

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, localDat=vars())
Пример #11
0
def cgmUpdateTool():
    try:
        import cgm.core.tools.updateTool as CGMUPDATE
        reload(CGMUPDATE)
        CGMUPDATE.ui()
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #12
0
def rigJoint_verify(joints = [], name=True, connect=True):
    try:
        if not joints:
            joints = mc.ls(sl=True,type='joint')
            
        ml_joints = cgmMeta.validateObjListArg(joints,'cgmObject')
        ml_rigJoints = []
        
        for i,mObj in enumerate(ml_joints):
            mDirect = mObj.getMessageAsMeta('rigJoint')
            if not mDirect:
                mDirect = mObj.doDuplicate(po=True)
                if name:
                    if 'sknJnt' not in mObj.p_nameBase:
                        mObj.rename( "{0}_sknJnt".format(mObj.p_nameBase) )
                mDirect.rename( mObj.p_nameBase.replace('sknJnt','rig') )
                mDirect.connectChildNode(mObj,'skinJoint','rigJoint')
            
            ml_rigJoints.append(mDirect)
            """
            if i > 0:
                if ml_joints[i].parent:
                    _buffer = ml_joints[i].getParent(asMeta=True).getMessage('rigJoint')
                    if _buffer:
                        mDirect.parent =_buffer[0]"""
            
            if connect:
                mc.pointConstraint([mDirect.mNode], mObj.mNode, maintainOffset = True)
                mc.orientConstraint([mDirect.mNode], mObj.mNode, maintainOffset = True)
                mc.scaleConstraint([mDirect.mNode], mObj.mNode, maintainOffset = True)
                
        return ml_rigJoints
    
    except Exception,err:
        cgmGEN.cgmExceptCB(Exception,err,msg=vars())
Пример #13
0
def uiFunc_createLoc(self,selfMode = False):
    try:
        _d = uiQuery_advancedSnap(self)
        _sel = _d.pop('sl')
        if not _sel:
            return log.error("Nothing selected")
        
        if len(_sel) == 1:
            targets = None
        else:
            targets = _sel[1:]
            
        obj = _sel[0]
        _d['queryMode'] = True
        
        if selfMode:
            _d['objLoc'] = True
        else:
            _d['targetLoc'] = True
            
        #cgmGEN.func_snapShot(vars())
        SNAPCALLS.snap( obj,targets, **_d)
        
    except Exception,err:
        cgmGEN.cgmExceptCB(Exception,err)
Пример #14
0
def get_spinGroup(self):
    try:
        _str_func = 'get_spinGroup'
        log_start(_str_func)

        #Make a spin group
        mSpinGroup = mStart.doGroup(False, False, asMeta=True)
        mSpinGroup.doCopyNameTagsFromObject(self.mModule.mNode,
                                            ignore=['cgmName', 'cgmType'])
        mSpinGroup.addAttr('cgmName',
                           '{0}NoFlipSpin'.format(self.d_module['partName']))
        mSpinGroup.doName()

        mSpinGroup.parent = mRoot

        mSpinGroup.doGroup(True, True, typeModifier='zero')

        #Setup arg
        mPlug_spin = cgmMeta.cgmAttr(mIKControl,
                                     'spin',
                                     attrType='float',
                                     keyable=True,
                                     defaultValue=0,
                                     hidden=False)
        mPlug_spin.doConnectOut("%s.r%s" %
                                (mSpinGroup.mNode, _jointOrientation[0]))
        return mSpinGroup
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, localDat=vars())
Пример #15
0
def returnRawGeneratedName(obj, ignore=[False], removeDups=True):
    """  
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    DESCRIPTION:
    Returns a generated name

    ARGUMENTS:
    obj(string) - object
    ignore(list) -  only culls out cgmtags that are 
                     generated via returnCGMOrder() function

    RETURNS:
    name(string)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    """
    try:
        rawNamesDict = returnObjectGeneratedNameDict(obj, ignore)
        divider = returnCGMDivider()
        order = returnCGMOrder()

        nameBuilder = []
        #>>> Dictionary driven order
        for item in order:
            buffer = rawNamesDict.get(item)
            if buffer > 0 and item not in ignore:
                if removeDups:
                    if str(buffer) in nameBuilder:
                        continue
                nameBuilder.append(str(buffer))
        return divider.join(nameBuilder)
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #16
0
def layer_verify(self, **kws):
    try:
        _str_func = ' layer_verify'.format(self)
        log.debug("|{0}| >> ... [{1}]".format(_str_func, self) + '-' * 80)

        if not self.getMessage('displayLayer'):
            mLayer = cgmMeta.validateObjArg(mc.createDisplayLayer(),
                                            'cgmNode',
                                            setClass=True)

            ATTR.copy_to(self.mNode, 'cgmName', mLayer.mNode, driven='target')
            mLayer.doStore('cgmName', 'main')
            mLayer.doName()
            self.connectChildNode(mLayer.mNode, 'displayLayer')

        if not self.getMessage('controlLayer'):
            mLayer = cgmMeta.validateObjArg(mc.createDisplayLayer(),
                                            'cgmNode',
                                            setClass=True)

            #ATTR.copy_to(self.mNode,'cgmName',mLayer.mNode,driven='target')
            mLayer.doStore('cgmName', 'control')
            mLayer.doName()
            self.connectChildNode(mLayer.mNode, 'controlLayer')

        return self.displayLayer, self.controlLayer
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #17
0
def example(self):
    try:
        _short = self.p_nameShort
        _str_func = ' example'.format(self)
        log.debug("|{0}| >> ... [{1}]".format(_str_func, self) + '-' * 80)

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #18
0
def anim_select(self):
    try:
        _str_func = ' anim_select'.format(self)
        log.debug("|{0}| >> ... [{1}]".format(_str_func, self) + '-' * 80)
        self.puppetSet.select()
        return True
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #19
0
def rigDelete(self):
    try:
        _str_func = 'rigDelete'
        log.debug("|{0}| >> ...".format(_str_func, ) + '-' * 80)
        log.debug(self)
        self.template = False

        self.moduleTarget.eyeLook.masterGroup.delete()

        return True

        self.noTransFormNull.template = True
        mPuppet = self.moduleTarget
        mRootMotion = self.moduleTarget.getMessageAsMeta('rootMotionHandle')
        if mRootMotion:
            if mRootMotion.getMessage('dynParentGroup'):
                mRootMotion.dynParentGroup.doPurge()
            mRootMotion.masterGroup.delete()

        if self.moduleTarget.masterControl.getMessage('dynParentGroup'):
            self.moduleTarget.masterControl.dynParentGroup.doPurge()

        ml_spacePivots = self.moduleTarget.masterControl.msgList_get(
            'spacePivots')
        if ml_spacePivots:
            for mObj in ml_spacePivots:
                log.info("|{0}| >> SpacePivot: {1}".format(_str_func, mObj))
                for link in [
                        'constraintGroup', 'constrainGroup', 'masterGroup'
                ]:
                    mGroup = mObj.getMessageAsMeta(link)
                    if mGroup:
                        mGroup.delete()
                        break

        if self.moduleTarget.masterControl.getMessage('masterGroup'):
            self.moduleTarget.masterControl.masterGroup.delete()

        log.debug("|{0}| >> rigNodes...".format(_str_func, ) + '-' * 40)
        ml_rigNodes = mPuppet.getMessageAsMeta('rigNodes')
        for mNode in ml_rigNodes:
            try:
                log.debug("|{0}| >> deleting: {1}".format(_str_func, mNode))
                mNode.delete()
            except:
                log.debug("|{0}| >> failed...".format(_str_func, mNode))

        return True
        self.v = 1
        try:
            self.moduleTarget.masterControl.masterGroup.delete()
        except Exception, err:
            cgmGEN.cgmExceptCB(Exception, err, msg=vars())
            raise Exception, err
        return True
Пример #20
0
def combineShapes(targets=[],
                  keepSource=True,
                  replaceShapes=False,
                  snapFirst=False):
    try:
        for o in targets[:-1]:
            shapeParent_in_place(targets[-1], o, keepSource, replaceShapes,
                                 snapFirst)
        return targets[-1]
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, msg=vars())
Пример #21
0
def define(self):
    try:
        _short = self.mNode
        ATTR.set_alias(_short,'sy','blockScale')    
        self.setAttrFlags(attrs=['sx','sz','sz'])
        self.doConnectOut('sy',['sx','sz'])
        ATTR.set_min(_short,'controlOffset',.001)
        
        try:mc.delete(self.getShapes())
        except:pass
    except Exception,err:
        cgmGEN.cgmExceptCB(Exception,err,localDat=vars())    
Пример #22
0
def get_axisBox_size(targets=None, maxDistance=10000000, mark=False):
    try:
        _str_func = 'get_axisBox_size'
        log.debug("|{0}| >> ".format(_str_func) + '-' * 80)

        targets = VALID.listArg(targets)
        _targets = VALID.mNodeStringList(targets)

        if not _targets:
            raise ValueError, "Must have targets!"

        d_res = {'x': [], 'y': [], 'z': []}

        for t in _targets:
            log.debug("|{0}| >> On t: {1}".format(_str_func, t))
            _proxy = CORERIG.create_axisProxy(t)
            _startPoint = POS.get(_proxy, 'bb')
            for k in d_res.keys():
                log.debug("|{0}| >> On t: {1} | {2}".format(_str_func, t, k))

                pos_positive = RAYS.get_cast_pos(t,
                                                 k + '+',
                                                 'near',
                                                 _proxy,
                                                 startPoint=_startPoint,
                                                 mark=False,
                                                 maxDistance=maxDistance)
                pos_neg = RAYS.get_cast_pos(t,
                                            k + '-',
                                            'near',
                                            _proxy,
                                            startPoint=_startPoint,
                                            mark=False,
                                            maxDistance=maxDistance)

                if mark:
                    LOCINATOR.LOC.create(position=pos_positive,
                                         name="{0}_{1}Pos_loc".format(t, k))
                    LOCINATOR.LOC.create(position=pos_neg,
                                         name="{0}_{1}Neg_loc".format(t, k))

                dist = DIST.get_distance_between_points(pos_positive, pos_neg)
                d_res[k].append(dist)
            mc.delete(_proxy)

        for k, v in d_res.iteritems():
            d_res[k] = COREMATH.average(v)

        return d_res['x'], d_res['y'], d_res['z']

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #23
0
def create_distanceMeasure(start=None, end=None, baseName='measure'):
    """
    Get the the closest return based on a source and target and variable modes
    
    :parameters:
        :start(str): Our start obj
        :end(str): End obj
        :baseName(str):What mode are we checking data from
    
    :returns
        {shape,dag,loc_start,loc_end,start,end}
    """
    try:
        _str_func = 'create_distanceMeasure'

        #Create ====================================================================================
        plug_start = POS.get_positionPlug(start)
        plug_end = POS.get_positionPlug(end)
        _res = {'start': start, 'end': end}

        if not plug_start:
            pos_start = POS.get(start)
            loc_start = mc.spaceLocator(name="{0}_{1}_start_loc".format(
                NAMES.get_base(start), baseName))[0]
            POS.set(loc_start, pos_start)
            plug_start = POS.get_positionPlug(loc_start)
            _res['loc_start'] = loc_start
        if not plug_end:
            pos_end = POS.get(end)
            loc_end = mc.spaceLocator(name="{0}_{1}_end_loc".format(
                NAMES.get_base(end), baseName))[0]
            POS.set(loc_end, pos_end)
            plug_end = POS.get_positionPlug(loc_end)
            _res['loc_end'] = loc_end

        mDistShape = r9Meta.MetaClass(mc.createNode('distanceDimShape'))
        mDistShape.rename("{0}_distShape".format(baseName))

        mDistTrans = r9Meta.MetaClass(VALID.getTransform(mDistShape.mNode))
        mDistTrans.rename("{0}_dist".format(baseName))

        _res['dag'] = mDistTrans.mNode
        _res['shape'] = mDistShape.mNode

        ATTR.set_message(_res['dag'], 'distShape', _res['shape'], simple=True)

        ATTR.connect(plug_start, "{0}.startPoint".format(_res['shape']))
        ATTR.connect(plug_end, "{0}.endPoint".format(_res['shape']))

        return _res
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #24
0
def modules_gather(self, **kws):
    try:
        _short = self.p_nameShort
        _str_func = ' modules_gather'.format(self)
        log.debug("|{0}| >> ... [{1}]".format(_str_func, self) + '-' * 80)

        ml_modules = modules_get(self)
        int_lenModules = len(ml_modules)

        for i, mModule in enumerate(ml_modules):
            _str_module = mModule.p_nameShort
            module_connect(self, mModule, **kws)
        return ml_modules
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #25
0
def backup(self, ml_handles=None):
    try:
        _str_func = 'segment_handles'
        log_start(_str_func)

        mBlock = self.mBlock
        mRigNull = self.mRigNull
        _offset = self.v_offset
        _jointOrientation = self.d_orientation['str']

        if not ml_handles:
            raise ValueError, "{0} | ml_handles required".format(_str_func)

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, localDat=vars())
Пример #26
0
def clean(arg=None,
          invalidChars="""`~!@#$%^&*()-+=[]\\{}|;':"/?><., """,
          noNumberStart=True,
          functionSwap=False,
          replaceChar='',
          cleanDoubles=True,
          stripTailing=True):
    """
    Modified from Hamish MacKenzie's zoo one

    :parameters:
    arg(str) - String to clean
    invalidChars(str) - Sequence of characters to remove
    	noNumberStart(bool) - remove numbers at start
    	functionSwap(bool) - whether to replace functions with string from dict
    	replaceChar(str) - Character to use to replace with
    	cleanDoubles(bool) - remove doubles
    	stripTrailing(bool) - remove trailing '_'

    returns l_pos
    """
    _str_funcName = 'clean'
    try:
        str_Clean = arg

        for char in invalidChars:
            if functionSwap and char in d_functionStringSwaps.keys():
                str_Clean = str_Clean.replace(char,
                                              d_functionStringSwaps.get(char))
            else:
                str_Clean = str_Clean.replace(char, replaceChar)

        if noNumberStart:
            for n in range(10):
                while str_Clean.startswith(str(n)):
                    log.debug("Cleaning : %s" % str(n))
                    str_Clean = str_Clean[1:]
        if cleanDoubles and replaceChar:
            doubleChar = replaceChar + replaceChar
            while doubleChar in cleanStr:
                str_Clean = str_Clean.replace(doubleChar, replaceChar)

        if stripTailing:
            while str_Clean.endswith('_'):
                str_Clean = str_Clean[:-1]
        return str_Clean
    except Exception, err:
        cgmGeneral.cgmExceptCB(Exception, err, msg=vars())
Пример #27
0
def uiFunc_snap(self):
    try:
        _d = uiQuery_advancedSnap(self)
        _sel = _d.pop('sl')
        if not _sel:
            return log.error("Nothing selected")
        
        if len(_sel) == 1:
            targets = None
        else:
            targets = _sel[1:]
        obj = _sel[0]
        SNAPCALLS.snap( obj,targets, **_d)
        
    except Exception,err:
        cgmGEN.cgmExceptCB(Exception,err)
Пример #28
0
def groups_verify(self):
    try:
        _str_func = "groups_verify".format()
        log.debug("|{0}| >> ...".format(_str_func))

        mMasterNull = self.masterNull

        if not mMasterNull:
            raise ValueError, "No masterNull"

        for attr in [
                'rig', 'deform', 'noTransform', 'geo', 'skeleton', 'parts',
                'worldSpaceObjects', 'puppetSpaceObjects'
        ]:
            _link = attr + 'Group'
            mGroup = mMasterNull.getMessage(_link,
                                            asMeta=True)  # Find the group
            if mGroup: mGroup = mGroup[0]

            if not mGroup:
                mGroup = mMasterNull.doCreateAt(setClass=True)
                mGroup.connectParentNode(mMasterNull.mNode, 'puppet',
                                         attr + 'Group')

            mGroup.rename(attr)
            log.debug("|{0}| >> attr: {1} | mGroup: {2}".format(
                _str_func, attr, mGroup))

            # Few Case things
            #----------------------------------------------------
            if attr in ['rig', 'geo', 'skeleton']:
                mGroup.p_parent = mMasterNull
            elif attr in ['deform', 'puppetSpaceObjects'
                          ] and self.getMessage('masterControl'):
                mGroup.p_parent = self.getMessage('masterControl')[0]
            else:
                mGroup.p_parent = mMasterNull.rigGroup

            ATTR.set_standardFlags(mGroup.mNode)

            if attr == 'worldSpaceObjects':
                mGroup.addAttr('cgmAlias', 'world')
            elif attr == 'puppetSpaceObjects':
                mGroup.addAttr('cgmAlias', 'puppet')

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err)
Пример #29
0
def ik_base(self,ikBase = None, ml_baseJoints = None, ml_fkShapes = None):
    try:
        _str_func = 'segment_handles'
        log_start(_str_func)
        
        mBlock = self.mBlock
        mRigNull = self.mRigNull
        _offset = self.v_offset
        _jointOrientation = self.d_orientation['str']
        ml_formHandles = self.ml_formHandles
        
        if ikBase == None:
            ikBase = mBlock.getEnumValueString('ikBase')        
        
        if not ml_baseJoints:
            raise ValueError,"{0} | ml_baseJoints required".format(_str_func)
        
        
        log.debug("|{0}| >> {1} ...".format(_str_func,ikBase))
            
        if ikBase in ['hips','simple']:
            if ikBase ==  'hips':
                mIKBaseCrv = ml_baseJoints[1].doCreateAt(setClass=True)
                mIKBaseCrv.doCopyNameTagsFromObject(ml_baseJoints[0].mNode,ignore=['cgmType'])                
                mIKBaseCrv.doStore('cgmName','hips')
            else:
                mIKBaseCrv = ml_baseJoints[0].doCreateAt(setClass=True)
                mIKBaseCrv.doCopyNameTagsFromObject(ml_baseJoints[0].mNode,ignore=['cgmType'])
                
            CORERIG.shapeParent_in_place(mIKBaseCrv.mNode, ml_fkShapes[0].mNode, True)
            
        else:
            log.debug("|{0}| >> default IK base shape...".format(_str_func))
            mIK_formHandle = ml_formHandles[ 0 ]
            #bb_ik = mHandleFactory.get_axisBox_size(mIK_formHandle.mNode)
            bb_ik = POS.get_bb_size(mIK_formHandle.mNode,True,mode='max')
            
            _ik_shape = CURVES.create_fromName('cube', size = bb_ik)
            ATTR.set(_ik_shape,'scale', 1.1)
        
            mIKBaseShape = cgmMeta.validateObjArg(_ik_shape, 'cgmObject',setClass=True)
        
            mIKBaseShape.doSnapTo(mIK_formHandle)
            #pos_ik = POS.get_bb_center(mProxyHelper.mNode)
            #SNAPCALLS.get_special_pos(mEndHandle.p_nameLong,
            #                                   'axisBox','z+',False)                
        
            #mIKBaseShape.p_position = pos_ik
            mIKBaseCrv = ml_baseJoints[0].doCreateAt()
            mIKBaseCrv.doCopyNameTagsFromObject(ml_baseJoints[0].mNode,ignore=['cgmType'])
            CORERIG.shapeParent_in_place(mIKBaseCrv.mNode, mIKBaseShape.mNode, False)                            

        mIKBaseCrv.doStore('cgmTypeModifier','ikBase')
        mIKBaseCrv.doName()

        self.mHandleFactory.color(mIKBaseCrv.mNode, controlType = 'main')
        self.mRigNull.connectChildNode(mIKBaseCrv,'controlIKBase','rigNull')#Connect                
      
    except Exception,err:cgmGEN.cgmExceptCB(Exception,err,localDat=vars())
Пример #30
0
def ik_segMid(self, mHandle=None):
    try:
        _str_func = 'ik_segMid'
        log_start(_str_func)
        ml_shapes = self.atBuilderUtils('shapes_fromCast',
                                        targets=mHandle,
                                        offset=self.v_offset,
                                        mode='simpleCast')  #'segmentHan
        CORERIG.shapeParent_in_place(mHandle.mNode, ml_shapes[0].mNode, False)

        mHandle.doStore('cgmTypeModifier', 'ik')
        mHandle.doStore('cgmType', 'handle')
        mHandle.doName()
        self.mHandleFactory.color(mHandle.mNode, controlType='sub')
        return mHandle
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, localDat=vars())