def clear(obj):
    """   
    Clear existing spacePivots

    :parameters:
        obj(str) - Should have space pivots on it

    :returns
       MPtjomg
    """ 
    _str_func = 'clear'    
    mObj = cgmMeta.validateObjArg(obj,'cgmObject',noneValid=False)    
    _res = False
    ml_spacePivots = mObj.msgList_get('spacePivots')
    if ml_spacePivots:
        log.debug("|{0}| >> SpacePivots found...".format(_str_func))    
        mc.delete([mPivot.mNode for mPivot in ml_spacePivots])
        _res = True
    
    for a in mc.listAttr(obj,ud=True) or []:
        if a.startswith('pivot_'):
            log.debug("|{0}| >> Removing attr: {1}".format(_str_func,a))                
            ATTR.delete(mObj.mNode,a)
            _res = True
            
    return True
Ejemplo n.º 2
0
def push_controlResizeObj(target=None):
    _str_func = "push_controlResizeObj"
    if target is None:
        _sel = mc.ls(sl=True)
        if _sel:
            _res = []
            for t in _sel:
                _res.append(push_controlResizeObj(t))
            mc.select(_res)
            return _res
    if not target:
        raise ValueError, "|{0}|  >> Must have a target".format(_str_func)

    if ATTR.has_attr(target, 'cgmControlResizerSource'):
        source = ATTR.get_message(target, 'cgmControlResizerSource')
        if not source:
            raise ValueError, "|{0}|  >> no cgmControlResizerSource data on target: {1}".format(
                _str_func, target)
        source = source[0]
        shapeParent_in_place(source,
                             target,
                             keepSource=False,
                             replaceShapes=True)
        if ATTR.has_attr(source, 'cgmControlResizer'):
            ATTR.delete(source, 'cgmControlResizer')
        ATTR.set(source, 'template', 0)
        mc.select(source)
        return source

    else:
        raise ValueError, "|{0}|  >> no cgmControlResizerSource attr on target: {1}".format(
            _str_func, target)
Ejemplo n.º 3
0
def verify_aimAttrs(obj=None, aim=None, up=None, checkOnly=False):
    """
    Make sure an object has aim attributes.
    
    :parameters:
        obj(str): Object to modify
        aim(arg): Value to set with on call
        up(arg): Value to set with on call
        out(arg): Value to set with on call
        checkOnly(bool): Check only, no adding attrs

    :returns
        success(bool)
    """
    _str_func = 'verify_aimAttrs'
    _str_enum = 'x+:y+:z+:x-:y-:z-'

    _obj = VALID.objString(obj,
                           noneValid=False,
                           calledFrom=__name__ + _str_func + ">> validate obj")

    _l = [aim, up]
    _l_defaults = [aim or 2, up or 1]

    for i, a in enumerate(['axisAim', 'axisUp']):
        _d = ATTR.validate_arg(_obj, a)
        _good = False
        if mc.objExists(_d['combined']):
            if ATTR.get_type(_d) == 'enum':
                if ATTR.get_enum(_d) == _str_enum:
                    _good = True
        if not _good:
            if checkOnly:
                return False
            log.debug("|{0}| >> {1} not a good attr. Must rebuild".format(
                _str_func, _d['combined']))
            ATTR.delete(_d)
            ATTR.add(_d, 'enum', enumOptions=_str_enum, hidden=False)
            ATTR.set(_d, value=_l_defaults[i])
            ATTR.set_keyable(_d, False)
        _v = _l[i]
        if _v is not None:
            ATTR.set(_d, value=_v)

    return True
Ejemplo n.º 4
0
def matchTarget_clear(obj = None):
    """
    Clear the match target of an object
    
    :parameters:
        obj(str): Object to modify

    :returns
        success(bool)
    """     
    _str_func = 'matchTarget_set'
    
    _obj = VALID.objString(obj, noneValid=False, calledFrom = __name__ + _str_func + ">> validate obj")
    
    ATTR.delete(_obj,'cgmMatchTarget')
    ATTR.delete(_obj,'cgmMatchDat')
    
    return True
Ejemplo n.º 5
0
def fbx_cleaner(delete = False, spaceString = '03FBXASC032'):
    """
    Find all the sill attributes fbx adds on import

    :parameters:
        delete | whether to delete all userDefined attrs or not
        spaceString | Search string for what fbx did with spaces from max or other app. Replaces with underscore
    """
    _str_func = 'fbx_cleaner'
    log.debug("|{0}| >> ...".format(_str_func))

    _res = {}
    for o in mc.ls():
        _res[o] = []
        _l = mc.listAttr(o,userDefined=True) or []
        for a in _l:
            _res[o].append(a)
        _shapes = TRANS.shapes_get(o)

        if _shapes:
            for s in _shapes:
                _res[s] = []
                _l = mc.listAttr(s,userDefined=True) or []
                for a in _l:
                    _res[s].append(a)

    print cgmGEN._str_hardBreak
    l_renamed = []
    for k,l in _res.iteritems():
        if l:
            print cgmGEN._str_subLine
            print(cgmGEN._str_baseStart * 2 + " node: '{0}' | attrs: {1}...".format(k,len(l)))
            for i,a in enumerate(l):
                print("   {0} | '{1}'".format(i,a))
                if delete:
                    ATTR.delete(k,a)
        if spaceString:
            if spaceString in NAMES.get_base(k) and k not in l_renamed:
                new = mc.rename(k, NAMES.get_base(k).replace(spaceString,'_'))
                print(" Rename  {0} | '{1}'".format(k,new))
                l_renamed.append(k)


    print cgmGEN._str_hardBreak