Пример #1
0
def get_constraintsByDrivingObject(node=None, driver = None, fullPath = False):
    """
    Get a list of constraints driving a node by the drivers of those constraints.
    node 1 is driven by 3 constraints. 2 of those constraints use our driver as a target.
    Those 2 will be returned.
    
    :parameters:
        node(str): node to query
        driver(str): driver to check against
        fullPath(bool): How you want list
    :returns
        list of constraints(list)
    """   
    _str_func = 'get_constraintsTo'
    
    node = VALID.mNodeString(node)
    
    driver = VALID.mNodeString(driver)
    _long = NAMES.long(driver)   
    log.debug("|{0}| >> node: {1} | target: {2}".format(_str_func,node, _long))             
    
    l_constraints = get_constraintsTo(node,True)
    _res = False
    
    if l_constraints:
        _res = []
        for c in l_constraints:
            targets = get_targets(c,True)
            log.debug("|{0}| >> targets: {1}".format(_str_func, targets))              
            if _long in targets:
                log.debug("|{0}| >> match found: {1}".format(_str_func, c))                  
                _res.append(c)
    if _res and not fullPath:
        return [NAMES.short(o) for o in _res]
    return _res   
Пример #2
0
def get_dat(surface=None, uKnots=True, vKnots=True):
    """
    Function to split a curve up u positionally 
    
    :parameters:
        'curve'(None)  -- Curve to split
    :returns
        list of values(list)
        
    hat tip: http://ewertb.soundlinker.com/mel/mel.074.php
    """
    _str_func = 'get_dat'
    log.debug("|{0}| >>  ".format(_str_func) + '-' * 80)

    surface = VALID.shapeArg(surface, 'nurbsSurface', True)

    mSurfaceInfo = False
    _res = {}

    _short = NAMES.short(surface)
    mSurfaceInfo = cgmMeta.asMeta(NODES.create(_short, 'surfaceInfo'))
    mSurfaceInfo.doConnectIn('inputSurface', '{0}.worldSpace'.format(surface))

    if uKnots:
        _res['uKnots'] = [u for u in mSurfaceInfo.knotsU[0]]
    if vKnots:
        _res['vKnots'] = [u for u in mSurfaceInfo.knotsV[0]]

    if mSurfaceInfo: mSurfaceInfo.delete()
    return _res
Пример #3
0
def parent_create(node, parentName=None):
    """
    Create a child transform 
    
    :parameters:
        node(str): Object to check
        parentName(str): what to call it
    
    :returns
        newParent(str)
    """
    _str_func = 'parent_create'
    _node = VALID.mNodeString(node)

    if parentName == None:
        parentName = NAME.short(_node) + "_grp"

    parent = mc.group(em=True, n=parentName)
    snap(parent, _node, rotateAxis=True, rotateOrder=True)

    parent = parent_set(parent, parent_get(_node))
    parent_set(_node, parent)

    return parent
Пример #4
0
def child_create(node, childName=None):
    """
    Create a child transform 
    
    :parameters:
        node(str): Object to check
        childName(str): what to call it

    :returns
        newChild(str)
    """
    _str_func = 'child_create'
    _node = VALID.mNodeString(node)

    if childName == None:
        childName = NAME.short(_node) + "_child"

    child = mc.group(em=True, n=childName)
    snap(child, _node, rotateAxis=True, rotateOrder=True)

    parent_set(child, _node)
    rotate_set(child, [0, 0, 0])
    scaleLocal_set(child, [0, 0, 0])
    return child
Пример #5
0
def siblings_get(node=None, fullPath=True):
    """
    Get all the parents of a given node where the last parent is the top of the heirarchy
    
    :parameters:
        node(str): Object to check
        fullPath(bool): Whether you want long names or not

    :returns
        siblings(list)
    """
    _str_func = 'siblings_get'
    _node = VALID.mNodeString(node)

    _l_res = []
    _type = VALID.get_mayaType(_node)

    log.debug("|{0}| >> node: [{1}] | type: {2}".format(
        _str_func, _node, _type))

    if VALID.is_shape(_node):
        log.debug("|{0}| >> shape...".format(_str_func))
        _long = NAME.long(_node)
        for s in shapes_get(_node, True):
            if s != _long:
                _l_res.append(s)

    elif not VALID.is_transform(_node):
        log.debug("|{0}| >> not a transform...".format(_str_func))
        if VALID.is_component(_node):
            log.debug("|{0}| >> component...".format(_str_func))
            _comp = VALID.get_component(_node)
            log.debug("|{0}| >> component: {1}".format(_str_func, _comp))
            _comb = "{0}.{1}".format(_comp[1], _comp[0])
            for c in mc.ls("{0}.{1}[*]".format(_comp[1], _comp[2]),
                           flatten=True):
                if str(c) != _comb:
                    _l_res.append(c)
        else:
            _long = NAME.long(_node)
            log.debug("|{0}| >> something else...".format(_str_func))
            _l = mc.ls(type=_type)
            for o in _l:
                if NAME.long(o) != _long:
                    _l_res.append(o)
            #raise ValueError,"Shouldn't have arrived. node: [{0}] | type: {1}".format(_node,_type)
    elif parents_get(_node):
        log.debug("|{0}| >> parented...".format(_str_func))
        _long = NAME.long(_node)
        for c in children_get(parent_get(node), True):
            if c != _long:
                _l_res.append(c)
    else:
        log.debug("|{0}| >> root transform...".format(_str_func))
        l_rootTransforms = get_rootList()
        _short = NAME.short(_node)
        for o in l_rootTransforms:
            if o != _short and VALID.get_mayaType(o) == _type:
                _l_res.append(o)

    if not fullPath:
        return [NAME.short(o) for o in _l_res]
    return _l_res