Esempio n. 1
0
    def fixXforms(self):
        ## Get the first selected object
        objs = pm.ls(selection=True)
        
        for obj in objs:
            pm.parent( obj, world=True )

        for obj in objs:        
            ## Unparent the object
            
            ## Move the pivot to the origin
            pm.move ( obj.scalePivot , [0,0,0] )
            pm.move ( obj.rotatePivot , [0,0,0] )
            ## Freeze transforms
            pm.makeIdentity(
                obj,
                apply = True,
                normal = 0,
                preserveNormals = True
            )
            ## Note that the options for makeIdentity were simply
            ## from the Mel script history or freeze transform
            
            ## Delete the history
            pm.delete (ch = True )        
Esempio n. 2
0
def putObjOnSnappableSpacing(obj, snappableSpacing):
    oSel = pm.ls(selection=True)
    destinationObj = obj
    usedObj = obj

    pm.select(destinationObj)
    t = pm.xform(query=True, rotatePivot=True, worldSpace=True)
    vt = pm.core.datatypes.Vector(t[0], t[1], t[2])
    vt = onSnappableSpacingVec(vt, snappableSpacing)

    pm.select(usedObj)
    pm.move(vt, worldSpace=True, absolute=True, worldSpaceDistance=True)

    ## We compensate by getting the *object being moved*'s
    ## pivot
    t2 = pm.xform(query=True, rotatePivot=True, worldSpace=True)
    vt2 = pm.core.datatypes.Vector(t2[0], t2[1], t2[2])

    ## vExtra is the additional amount compensated
    vExtra = vt - vt2

    vDest = vt + vExtra

    vFinal = vDest

    pm.move(vFinal, worldSpace=True, absolute=True, worldSpaceDistance=True)

    pm.select(oSel)
Esempio n. 3
0
def pivotToZeroDeleteHistoryAndFreezeTransformsInWorldSpace():

    original_selection = pm.ls(selection = True)
    objs = original_selection[:]

    for obj in objs:
        try:
            previous_parent = obj.getParent()
            pm.parent( obj, world=True )                
            pm.move ( obj.scalePivot , [0,0,0] )
            pm.move ( obj.rotatePivot , [0,0,0] )
            pm.makeIdentity (obj, apply = True, normal = 0, preserveNormals = True )
            pm.delete (ch = True )
            pm.parent( obj, previous_parent )                
        except:
            print( traceback.format_exc()     )
Esempio n. 4
0
def pivotToZeroDeleteHistoryAndFreezeTransformsInWorldSpace():

    original_selection = pm.ls(selection=True)
    objs = original_selection[:]

    for obj in objs:
        try:
            previous_parent = obj.getParent()
            pm.parent(obj, world=True)
            pm.move(obj.scalePivot, [0, 0, 0])
            pm.move(obj.rotatePivot, [0, 0, 0])
            pm.makeIdentity(obj, apply=True, normal=0, preserveNormals=True)
            pm.delete(ch=True)
            pm.parent(obj, previous_parent)
        except:
            print(traceback.format_exc())
Esempio n. 5
0
def motion_path(**kwargs):
    objs = kwargs.get("objs", None)
    point = int(len(objs) / 2)
    print objs[point]
    loc = pm.spaceLocator(name="up_loc")
    tmp_con = pm.parentConstraint(objs[point], loc, maintainOffset=False)
    pm.delete(tmp_con)
    pm.move(loc, 10, moveY=True, objectSpace=True)
    parts = 1.0 / float((len(objs) - 1))
    crv = kwargs.get("path_curve", None)
    print objs
    #print crv
    initU = 0.0
    pm.select(clear=True)
    #for obj in objs:
    #path_anim = pm.pathAnimation(obj, curve = crv, follow=True, followAxis = "x", upAxis = "y",
    #                             worldUpType = "object", worldUpObject = loc, fractionMode=True)
    #path_anim = pm.pathAnimation(obj, curve = crv, follow=True, followAxis = "x", upAxis = "y",
    #                             worldUpType = "vector", worldUpVector = [0,1,0], fractionMode=True)
    #pm.disconnectAttr(str(path_anim)+".uValue")
    #pm.setAttr(str(path_anim)+".uValue", initU)
    #initU += float(parts)
    return None
Esempio n. 6
0
def rsPhysicalLight():
    mel.eval('redshiftCreateLight("RedshiftPhysicalLight")')
    light = ls(selection=True)[0]
    setAttr(light + '.colorMode', 1)
    setAttr(light + '.intensity', 10)
    setAttr(light + '.areaVisibleInRender', 0)

    locator = spaceLocator()
    move(locator, (0, 0, -1))
    setAttr(locator + '.inheritsTransform', 0)
    locator.setParent(light)

    aim = aimConstraint(locator, light)
    setAttr(aim + '.aimVector', (0, 0, -1))

    position = autoPlace()
    move(light, position, relative=True)
    move(locator, position, relative=True)

    rename(locator, '{}_aim'.format(light))

    modelEditor('modelPanel4', e=True, lights=True, locators=True)
## type a number in for the distance between offsets
## in the dialog box that pops up


import pymel.all as pm

dist = input()
oSel = pm.ls(selection=True)
objs = oSel[:]  ## copy oSel list

for i, obj in enumerate(objs):
    
    vecList = [
        [1,0,0], [0,1,0], [0,0,1],
        [-1,0,0], [0,-1,0], [0,0,-1],
    ]
    
    hiObj = pm.PyNode( obj.name() + "_hi" )
    xMovement = 3 + i*dist
    pair = [obj,hiObj]
    for item in pair:
        #pm.move(item, [0,0,0] , absolute=True, worldSpace=True )
        vec = vecList[i%len(vecList)]
        multVec = [ vec[0]*dist, vec[1]*dist, vec[2]*dist]
        pm.move(
            item, multVec,
            relative=True, worldSpace=True
        )
## type a number in for the distance between offsets
## in the dialog box that pops up

import pymel.all as pm

dist = input()
oSel = pm.ls(selection=True)
objs = oSel[:]  ## copy oSel list

for i, obj in enumerate(objs):

    vecList = [
        [1, 0, 0],
        [0, 1, 0],
        [0, 0, 1],
        [-1, 0, 0],
        [0, -1, 0],
        [0, 0, -1],
    ]

    hiObj = pm.PyNode(obj.name() + "_hi")
    xMovement = 3 + i * dist
    pair = [obj, hiObj]
    for item in pair:
        #pm.move(item, [0,0,0] , absolute=True, worldSpace=True )
        vec = vecList[i % len(vecList)]
        multVec = [vec[0] * dist, vec[1] * dist, vec[2] * dist]
        pm.move(item, multVec, relative=True, worldSpace=True)