예제 #1
0
def worldMatrix_get(node=None, asEuclid=False):
    """
    Query the worldMatrix of a given node
    
    :parameters:
        node(str): node to query
        asMatrix(bool): whether to return a EUCLID.Matrix4

    :returns
        matrix
    """
    _str_func = 'worldMatrix_get'

    node = VALID.mNodeString(node)

    try:
        matrix_a = mc.xform(node, q=True, m=True, ws=True)
    except Exception, e:
        if not VALID.is_transform(node):
            log.error("|{0}| >> Not a transform: '{1}'".format(
                _str_func, node))
            return False

        log.error("|{0}| >> Failed: '{1}'".format(_str_func, node))
        #for arg in e.args:
        #log.error(arg)
        raise Exception, e
예제 #2
0
from cgm.core.rigger import ModuleShapeCaster as mShapeCast
reload(mShapeCast)
from cgm.core.lib import shapeCaster as ShapeCast
reload(ShapeCast)
mShapeCast.go(m1,l_toBuild)

m1 = cgmMeta.asMeta('l_arm_part')
mShapeCast.go(m1,['segmentFK_Loli'])
mShapeCast.go(m1,['settings'])
mShapeCast.go(m1,['midIK'])
mShapeCast.go(m1,['hand'])

#Issues========================================================
import cgm.core.cgmPy.validateArgs as VALID
reload(VALID)
VALID.is_transform('cgmObject_poly2_parentConstraint1')

mc.listAttr('cgmObject_poly2_parentConstraint1')

ATTR.set('cgmObject_poly2_parentConstraint1','ty',100)
ATTR.get('cgmObject_poly2_parentConstraint1','ty')


import cgm.core.lib.curve_Utils as CURVES
reload(CURVES)
import maya.cmds as mc
CURVES.mirror_worldSpace('l_eye_block|uprLid_rigHelper','r_eye_block|uprLid_rigHelper')
CURVES.mirror_worldSpace(mc.ls(sl=1)[0],mc.ls(sl=1)[1])

CURVES.Copy
예제 #3
0
    def __init__(self,
                 obj,
                 targets=[],
                 move=True,
                 orient=False,
                 aim=False,
                 pos=[],
                 snapToSurface=False,
                 midSurfacePos=False,
                 posOffset=False,
                 aimVector=[0, 0, 1],
                 upVector=[0, 1, 0],
                 worldUpType='scene',
                 snapComponents=False,
                 softSelection=False,
                 softSelectDistance=20,
                 mode=None,
                 **kws):
        """ 
        Asserts objects existance and that it has a transform. Then initializes. 

        Keyword arguments:
        obj(string/instance)
	targets(list) -- target objects
	
	snapToSurface -- if target is a snappable surface will try to do that
	posOffset
	snapComponents(bool) -- will try to use components if True
	aimVector(vector) -- aim vector for object
	upVector(vector) -- up vector for object (used as lathe axis for midpoint surface snap too)
	midSurfacePos(bool) -- mid point snap with a surface
	worldUpType(string) -- arg for various modes (aim, orient, etc)
	softSelection(bool) -- soft select mode for component objects only
	softSelectDistance(float) -- arg for mc.softSelect
	
	ToDo:
	1) midSurfacePos
        """
        #>>> Check our obj
        log.debug("obj: %s" % obj)
        log.debug("targets: %s" % targets)
        if issubclass(type(obj), cgmMeta.cgmNode):
            self.i_obj = obj
        else:
            i_node = cgmMeta.cgmNode(obj)
            if i_node.isComponent():
                self.i_obj = i_node
            else:
                self.i_obj = cgmMeta.cgmObject(obj)
        assert VALID.is_transform(self.i_obj.mNode) or self.i_obj.isComponent(
        ), "Not a snappable object. Not a transform: '%s" % self.i_obj.getShortName(
        )

        #>>> Pass through args
        self.b_snaptoSurface = snapToSurface
        self.b_midSurfacePos = midSurfacePos
        self.b_snapComponents = snapComponents
        self.b_softSelection = softSelection
        self.b_midSurfacePos = midSurfacePos
        self.b_aim = aim
        self._softSelectionDistance = softSelectDistance,
        self._posOffset = posOffset
        self._aimVector = aimVector
        self._upVector = upVector
        self._worldUpType = worldUpType

        #>>> Check our targets
        if targets and not type(targets) == list: targets = [targets]
        self.l_targets = []
        self.d_targetTypes = {}
        self.d_targetPositions = {}
        for t in targets:
            self.registerTarget(t)

        if not self.l_targets:
            log.error("No existing targets found")
            return

        if self.b_softSelection:
            #Should we save soft select info before changing?
            mc.softSelect(softSelectDistance=softSelectDistance)
            mc.softSelect(softSelectFalloff=0)
        log.debug("targetTypes: %s" % self.d_targetTypes)
        if move:
            log.debug("Moving")
            self.doMove(**kws)
        if orient:
            log.debug("orienting")
            self.doOrient(**kws)
        if aim:
            log.debug("orienting")
            self.doAim(**kws)
예제 #4
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