Ejemplo n.º 1
0
def buildJointFromEdgeLineVertices( edges ):
    pymel.core.select( edges )
    resultCurve = pymel.core.ls( pymel.core.polyToCurve( form=2, degree=1 )[0] )[0]
    resultCurveShape = resultCurve.getShape()
    maxValue = int( resultCurveShape.maxValue.get() ) + 1
    
    nulls = sgCmds.createPointOnCurve( resultCurve, maxValue )
    
    startObj = nulls[0]
    endObj = nulls[-1]
    
    poseStart = OpenMaya.MPoint( *pymel.core.xform( startObj, q=1, ws=1, t=1 ) )
    poseEnd   = OpenMaya.MPoint( *pymel.core.xform( endObj,   q=1, ws=1, t=1 ) )
    
    dist = poseStart.distanceTo( poseEnd )
    if dist == 0:
        pymel.core.delete( nulls.pop() )
    
    newJoints = []
    for null in nulls:
        newJoint = pymel.core.createNode( 'joint' )
        sgCmds.replaceObject( null, newJoint )
        newJoints.append( newJoint )
    pymel.core.select( newJoints )
    pymel.core.delete( nulls )
Ejemplo n.º 2
0
from sgMaya import sgCmds
from maya import cmds

sels = cmds.ls(sl=1)
newObjects = []
for sel in sels:
    newObject = cmds.spaceLocator()[0]
    newObject = sgCmds.replaceObject(sel, newObject)

    replaceNamedSel = cmds.rename(sel, 'replaceBefore_' + sel)
    newObject.rename(sel.split('|')[-1])
    cmds.delete(replaceNamedSel)
    newObjects.append(newObject)
pymel.core.select(newObjects)
Ejemplo n.º 3
0
from sgMaya import sgCmds
from maya import cmds

sels = cmds.ls( sl=1 )
newObjects = []
for sel in sels:
    newObject = cmds.createNode( 'transform' )
    cmds.setAttr( newObject + '.dh', 1 )
    newObject = sgCmds.replaceObject( sel, newObject )
    
    replaceNamedSel = cmds.rename( sel, 'replaceBefore_' + sel )
    newObject.rename( sel.split( '|' )[-1] )
    cmds.delete( replaceNamedSel )
    newObjects.append( newObject )
pymel.core.select( newObjects )