Ejemplo n.º 1
0
def text():
    t = pm.textField(tx, q=True, tx=True)
    
    pm.textCurves(t=t, ch=True)
    objs = pm.listRelatives(ad=True, typ='transform')
    for obj in objs:
        if "Char_" in obj.name():
            objs.remove(obj)
    pm.parent(objs, "Text_*")
    pm.makeIdentity(objs, a=True, t=1, r=1, s=1, n=0, pn=1)
    cmds.ResetTransformations(pm.ls(objs))
    pm.delete(objs, ch=True)
    pm.parent(pm.listRelatives(objs, ad=True), "Text_*", r=True, s=True)
    pm.delete("Char_*", objs)
    pm.ls("Text_*")[0].rename(t+"_crv")
def petal(core=None, xyz=[0, 0, 0], rot=[0, 0, 0]):

    myname = "petalObj"
    if core:
        myname = "flowerPetalObj"

    # build the petal, position it
    UNUSED = cmds.sphere(name=myname, axis=[0, 1, 0])
    if core:
        cmds.move(0, 0, -1.6)
    else:
        cmds.move(*xyz)  # unpack xyz

    cmds.scale(0.7, 0.3, 1.7)

    if core:
        cmds.FreezeTransformations()
        cmds.ResetTransformations()

    p = cmds.ls(sl=True)[0]

    if core:
        cmds.parent(p, core)

    cmds.select(p)
    cmds.pickWalk(direction="down")
    myPetalShape = cmds.ls(sl=True)

    # move the tip of the petal
    cmds.select(p + ".cv[3][7]")
    cmds.move(0, 2, 0, relative=True)

    # Select the inner part of the petal pull down
    # One loop for the U direction
    for uCV in xrange(5, 7):  # These numbers are
        for vCV in xrange(0, 8):  # not arbitrary.
            suffix = ".cv[%i][%i]" % (uCV, vCV)
            cmds.select(p + suffix)
            cmds.move(0, -0.4, 0, relative=True)

    if rot:
        cmds.select(p)
        cmds.rotate(*rot, relative=False)

    return p
Ejemplo n.º 3
0
def flowerMaker():

    numPetals = 10
    createShader = 1

    #Check for Shader
    shads = cm.ls(materials=True)
    for myNode in shads:
        if myNode == "petalColor":
            createShader = 0

    if createShader == 0:
        print "The Shader is already there \n"
    elif createShader == 1:
        #build our shader network
        cm.shadingNode("lambert", asShader=True, name="petalColor")
        cm.shadingNode("ramp", asTexture=True, name="petalRamp")
        cm.sets(renderable=True,
                noSurfaceShader=True,
                empty=True,
                n="petalColorSG")
        cm.connectAttr("petalColor.outColor",
                       "petalColorSG.surfaceShader",
                       force=True)
        cm.connectAttr("petalRamp.outColor", "petalColor.color")

        cm.setAttr("petalRamp.colorEntryList[3].color",
                   1,
                   0,
                   0,
                   type="double3")
        cm.setAttr("petalRamp.colorEntryList[3].position", 1)

        cm.setAttr("petalRamp.colorEntryList[2].color",
                   1,
                   1,
                   0,
                   type="double3")
        cm.setAttr("petalRamp.colorEntryList[2].position", 0.5)

        cm.setAttr("petalRamp.colorEntryList[1].color",
                   1,
                   0,
                   0,
                   type="double3")
        cm.setAttr("petalRamp.colorEntryList[1].position", 0)
        cm.setAttr("petalRamp.type", 8)

    #build the flower core
    cm.sphere(ax=[0, 1, 0], name="core")
    myCore = cm.ls(sl=True)
    cm.scale(1, 0.5, 1)
    cm.move(0, 0.2, 0)

    #build the petal
    cm.sphere(ax=[0, 1, 0])
    cm.move(0, 0, -1.6)
    cm.scale(0.7, 0.3, 1.7)
    cm.FreezeTransformations()
    cm.ResetTransformations()

    myPetal = cm.ls(sl=True)
    cm.parent(myPetal, myCore)
    cm.select(myPetal[0])
    cm.pickWalk(d="down")
    myPetalShape = cm.ls(sl=True)
    cm.sets(myPetalShape[0], edit=True, forceElement="petalColorSG")

    #move the tip of the petal
    cm.select(myPetal[0] + ".cv[3] [7]")
    cm.move(0, 2, 0, r=True)

    #Select the inner part of the petal pull down
    #One loop for the U direction
    for uCV in range(5, 7):
        for vCV in range(0, 8):
            cm.select(myPetal[0] + ".cv[{0}][{1}]".format(uCV, vCV))
            cm.move(0, -0.4, 0, r=True)

    cm.select(myPetal[0])
    degreeApart = 360 / numPetals
    for i in range(2, numPetals + 1):
        cm.duplicate()
        cm.rotate(0, degreeApart, 0, r=True)

    cm.select(myCore)
    cm.rename("Flower")
Ejemplo n.º 4
0
def selectShape(obj):
    # circle
    if cmds.optionMenu(shapes, q=True, sl=1) == 1:
        if cmds.radioButtonGrp(axes, q=True, sl=1) == 1:
            c = cmds.circle(nr=(1,0,0))[0]
        elif cmds.radioButtonGrp(axes, q=True, sl=2) == 2:
            c = cmds.circle(nr=(0,1,0))[0]
        else:
            c = cmds.circle(nr=(0,0,1))[0]
    # box
    elif cmds.optionMenu(shapes, q=True, sl=2) == 2:
        c = cmds.curve(d=1, p=[(1,1,1),(1,-1,1), (1,-1,-1),(1,1,-1),(-1,1,-1),(-1,-1,-1),(1,-1,-1),(1,1,-1),(1,1,1),(-1,1,1),(-1,-1,1),(1,-1,1),(-1,-1,1),(-1,-1,-1),(-1,1,-1),(-1,1,1)])
    # ball
    elif cmds.optionMenu(shapes, q=True, sl=3) == 3:
        tmp1 = cmds.circle(nr=(1,0,0))
        tmp2 = cmds.circle(nr=(0,1,0))
        tmp3 = cmds.circle(nr=(0,0,1))
        sh2 = cmds.listRelatives(tmp2[0], ad=True)[0]
        sh3 = cmds.listRelatives(tmp3[0], ad=True)[0]
        cmds.parent(sh2, tmp1[0], r=True, s=True)
        cmds.parent(sh3, tmp1[0], r=True, s=True)
        cmds.delete(cmds.ls(tmp2))
        cmds.delete(cmds.ls(tmp3))
        c = cmds.ls(tmp1)[0]
    # diamond
    elif cmds.optionMenu(shapes, q=True, sl=4) == 4:
        c = cmds.curve(d=1, p=[(0,1,0),(0,0,1),(0,-1,0),(0,0,-1),(0,1,0),(-1,0,0),(1,0,0),(0,-1,0),(-1,0,0),(0,0,-1),(1,0,0),(0,1,0),(0,-1,0),(0,0,1),(0,0,-1),(1,0,0),(0,0,1),(-1,0,0)])
    # cross 1
    elif cmds.optionMenu(shapes, q=True, sl=5) == 5:
        c = cmds.curve(d=1, p=[(0,0,-2),(0,0,2),(0,0,0),(-2,0,0),(2,0,0)])
    # cross 2
    elif cmds.optionMenu(shapes, q=True, sl=6) == 6:
        c = cmds.curve(d=1, p=[(-1,0,-3),(1,0,-3),(1,0,-1),(3,0,-1),(3,0,1),(1,0,1),(1,0,3),(-1,0,3),(-1,0,1),(-3,0,1),(-3,0,-1),(-1,0,-1),(-1,0,-3)])
    # eye
    elif cmds.optionMenu(shapes, q=True, sl=7) == 7:
        tmp1 = cmds.circle(nr=(0,1,0))
        tmp2 = cmds.curve(d=3, p=[(-2.05541,0,-0.0124173),(-1.365656,0,-0.507243),(0.0138526,0,-1.496896),(1.337951,0,-0.498965),(2,0,0)])
        tmp3 = cmds.curve(d=3, p=[(-2.05541,0,-0.0124173),(-1.365656,0,-0.507243),(0.0138526,0,-1.496896),(1.337951,0,-0.498965),(2,0,0)])
        cmds.setAttr(tmp3+".scaleZ", -1)
        pm.makeIdentity(tmp3, a=True, t=1, r=1, s=1, n=0, pn=1)
        sh2 = cmds.listRelatives(tmp2, ad=True)[0]
        sh3 = cmds.listRelatives(tmp3, ad=True)[0]
        cmds.parent(sh2, tmp1[0], r=True, s=True)
        cmds.parent(sh3, tmp1[0], r=True, s=True)
        cmds.delete(cmds.ls(tmp2))
        cmds.delete(cmds.ls(tmp3))
        c = cmds.ls(tmp1)[0]
        
        if cmds.radioButtonGrp(axes, q=True, sl=1) == 1:
            cmds.setAttr(c+".rotateY", 90)
            cmds.setAttr(c+".rotateZ", 90)
        elif cmds.radioButtonGrp(axes, q=True, sl=2) == 3:
            cmds.setAttr(c+".rotateX", 90)
        pm.makeIdentity(c, a=True, t=1, r=1, s=1, n=0, pn=1)
    # handle
    elif cmds.optionMenu(shapes, q=True, sl=8) == 8:
        tmp1 = cmds.circle(nr=(1,0,0))
        tmp2 = cmds.circle(nr=(0,1,0))
        tmp3 = cmds.circle(nr=(0,0,1))
        sh2 = cmds.listRelatives(tmp2[0], ad=True)[0]
        sh3 = cmds.listRelatives(tmp3[0], ad=True)[0]
        cmds.parent(sh2, tmp1[0], r=True, s=True)
        cmds.parent(sh3, tmp1[0], r=True, s=True)
        cmds.delete(cmds.ls(tmp2))
        cmds.delete(cmds.ls(tmp3))
        cmds.setAttr(tmp1[0]+".translateY", 4)
        cmds.makeIdentity(tmp1[0], a=True, t=1, n=0, pn=1)

        tmp = cmds.curve(d=1, p=[(0,0,0),(0,3,0)])
        sh = cmds.listRelatives(tmp, ad=True)[0]
        cmds.parent(sh, tmp1[0], r=True, s=True)
        cmds.delete(cmds.ls(tmp))
        c = cmds.ls(tmp1)[0]
    # arrow 1
    elif cmds.optionMenu(shapes, q=True, sl=9) == 9:
        c = cmds.curve(d=1, p=[(-2,0,-1),(1,0,-1),(1,0,-2),(3,0,0),(1,0,2),(1,0,1),(-2,0,1),(-2,0,-1)])
    # arrow 2
    elif cmds.optionMenu(shapes, q=True, sl=10) == 10:
        c = cmds.curve(d=1, p=[(-1,0,-1),(1,0,-1),(1,0,-2),(3,0,0),(1,0,2),(1,0,1),(-1,0,1),(-1,0,2),(-3,0,0),(-1,0,-2),(-1,0,-1)])
    # arrow 4
    elif cmds.optionMenu(shapes, q=True, sl=11) == 11:
        c = cmds.curve(d=1, p=[(-1,0,-1),(-1,0,-3),(-2,0,-3),(0,0,-5),(2,0,-3),(1,0,-3),(1,0,-1),(3,0,-1),(3,0,-2),(5,0,0),(3,0,2),(3,0,1),(1,0,1),(1,0,3),(2,0,3),(0,0,5),(-2,0,3),(-1,0,3),(-1,0,1),(-3,0,1),(-3,0,2),(-5,0,0),(-3,0,-2),(-3,0,-1),(-1,0,-1)])
    grp = cmds.group(em=True)
    cmds.parent(c,grp)
    cmds.ResetTransformations(c)

    if cmds.optionMenu(shapes, q=True, sl=4) == 4 or cmds.optionMenu(shapes, q=True, sl=5) == 5 or cmds.optionMenu(shapes, q=True, sl=11) == 11:
        if cmds.radioButtonGrp(axes, q=True, sl=1) == 1:
            cmds.setAttr(c+".rotateZ", 90)
        elif cmds.radioButtonGrp(axes, q=True, sl=2) == 3:
            cmds.setAttr(c+".rotateX", 90)
        pm.makeIdentity(c, a=True, t=1, r=1, s=1, n=0, pn=1)
    elif cmds.optionMenu(shapes, q=True, sl=8) == 8:
        if cmds.radioButtonGrp(axes, q=True, sl=1) == 1:
            cmds.setAttr(c+".rotateZ", -90)
        elif cmds.radioButtonGrp(axes, q=True, sl=2) == 3:
            cmds.setAttr(c+".rotateX", 90)
    elif cmds.optionMenu(shapes, q=True, sl=9) == 9 or cmds.optionMenu(shapes, q=True, sl=10) == 10:
        if cmds.radioButtonGrp(axes, q=True, sl=2) == 2:
            cmds.setAttr(c+".rotateX", 90)
            cmds.setAttr(c+".rotateZ", 90)
        elif cmds.radioButtonGrp(axes, q=True, sl=2) == 3:
            cmds.setAttr(c+".rotateY", -90)

            
    pm.makeIdentity(c, a=True, t=1, r=1, s=1, n=0, pn=1)
    cmds.parentConstraint(obj, grp, mo=False, n="ex")
    cmds.delete("ex")
    if cmds.radioButtonGrp(ctrl_make, q=True, sl=1) == 1:
        constrains(c, obj, 0)
Ejemplo n.º 5
0
def flowerMaker():
    numPetals = 10
    hasShader = False
    ## Check for shader
    shades = cmds.ls(mat=True)
    for myNode in shades:
        if (myNode == "petalColor"):
            hasShader = True

    if hasShader == True:
        print "There is already a shader"
    elif hasShader == False:
        ## Build our shader network
        cmds.shadingNode('lambert', asShader=True, name="petalColor")
        cmds.shadingNode('ramp', asTexture=True, name="petalRamp")
        cmds.sets(empty=True,
                  noSurfaceShader=True,
                  renderable=True,
                  name="petalColorSG")
        cmds.connectAttr('petalColor.outColor',
                         'petalColorSG.surfaceShader',
                         force=True)
        cmds.connectAttr('petalRamp.outColor', 'petalColor.color')

        cmds.setAttr('petalRamp.colorEntryList[3].color',
                     1.0,
                     0.0,
                     0.0,
                     type="double3")
        cmds.setAttr('petalRamp.colorEntryList[3].positon', 1.0)

        cmds.setAttr('petalRamp.colorEntryList[2].color',
                     1.0,
                     1.0,
                     0.0,
                     type="double3")
        cmds.setAttr('petalRamp.colorEntryList[2].positon', 0.5)

        cmds.setAttr('petalRamp.colorEntryList[1].color',
                     1.0,
                     0.0,
                     0.0,
                     type="double")
        cmds.setAttr('petalRamp.colorEntryList[1].positon', 0.0)
        cmds.setAttr('petalRamp.type', 8.0)
    else:
        print "Catastrophic collapse in code!"

    ## Build the flower core
    cmds.sphere(axis=[0.0, 1.0, 0.0], name="core")
    myCore = cmds.ls(selection=True)
    cmds.scale(1.0, 0.5, 1.0)
    cmds.move(0.0, 0.2, 0.0)

    ## Build the petal
    cmds.sphere(axis=[0.0, 1.0, 0.0])
    cmds.move(0.0, 0.0, -1.6)
    cmds.scale(0.7, 0.3, 1.7)
    cmds.FreezeTransformations()
    cmds.ResetTransformations()

    myPetal = cmds.ls(selection=True)
    cmds.parent(myPetal, myCore)
    cmds.select(myPetal[0])
    cmds.pickWalk(direction="down")
    myPetalShape = cmds.ls(selection=True)
    cmds.sets(myPetalShape[0], edit=True, forceElement='petalColorSG')

    # Move the tip of the petal
    cmds.select(myPetal[0] + '.cv[3][7]')
    cmds.move(0.0, 2.0, 0.0, relative=True)

    # Select the inner part of the petal pull down
    # One loop for the U direction
    for uCV in xrange(5, 7):
        for vCV in xrange(0, 8):
            cmds.select(myPetal[0] + '.cv[' + str(uCV) + '][' + str(vCV) + ']')
            cmds.move(0.0, -0.4, 0.0, relative=True)

    cmds.select(myPetal[0])
    degreeApart = (360.0 / numPetals)
    for x in xrange(1, numPetals):
        cmds.duplicate()
        cmds.rotate(0.0, degreeApart, 0.0, relative=True)

    cmds.select(myCore)
    cmds.rename("Flower")
Ejemplo n.º 6
0
def makeFlower():
    ## Number of petals on the flower
    numPetals = 10
    
    ## Shaders for the flower
    myShader = cmds.shadingNode('lambert', n = "core", asShader = True)
    myShader1 = cmds.shadingNode('lambert', n = "petal", asShader = True)
    
    ## Build the flower core
    cmds.sphere(axis = [0.0, 1.0, 0.0], name = "core")
    myCore = cmds.ls(selection = True)
    cmds.scale(1.0, 0.5, 1.0)
    cmds.move(0.0, 0.2, 0.0)
    
    ## Colors the core of the flower
    cmds.select(myCore)
    shaderSet = cmds.sets(renderable = True, noSurfaceShader = True, empty = True, name = myShader + 'SG')
    cmds.setAttr(myShader + '.color', 0.18, 0.40, 0.698, type = 'double3')
    ##cmds.setAttr(myShader + '.incandescence', 0.0, 0.0, 0.0, type = 'double3')
    cmds.connectAttr(myShader + ".outColor", shaderSet + ".surfaceShader")
    cmds.sets(forceElement = shaderSet, e = True)
    
    ## Build the petal
    cmds.sphere(axis = [0.0, 1.0, 0.0])
    cmds.move(0.0, 0.0, -1.6)
    cmds.scale(0.7, 0.3, 1.7)
    cmds.FreezeTransformations()
    cmds.ResetTransformations()
    myPetal = cmds.ls(selection = True)
    
    # Curve the tip of the petal
    cmds.select(myPetal[0] + '.cv[3][7]')
    cmds.move(0.0, 2.0, 0.0, relative = True)
    
    # Select the inner part of the petal pull down
    # One loop for the U direction
    for uCV in xrange(5,7):
        for vCV in xrange(0,8):
            cmds.select(myPetal[0] + '.cv[' + str(uCV) + '][' + str(vCV) + ']')
            cmds.move(0.0, -0.4, 0.0, relative = True)
    
    ## Color the petal of the flower
    cmds.select(myPetal)
    shaderSet1 = cmds.sets(renderable = True, noSurfaceShader = True, empty = True, name = myShader1 + 'SG')
    cmds.setAttr(myShader1 + '.color', 1.0, 0.361, 0.169, type = 'double3')
    ##cmds.setAttr(myShader1 + '.incandescence', 0.0, 0.0, 0.0, type = 'double3')
    cmds.connectAttr(myShader1 + ".outColor", shaderSet1 + ".surfaceShader")
    cmds.sets(forceElement = shaderSet1, e = True)
    
    ## Parent the petal to the core of the flower
    cmds.parent(myPetal, myCore)
    cmds.select(myPetal[0])
    cmds.pickWalk(direction="down")
    
    ## Duplicates the petals and rotates them around the core
    cmds.select(myPetal[0])
    degreeApart = (360.0/numPetals)
    for x in xrange(1,numPetals):
        cmds.duplicate()
        cmds.rotate(0.0, degreeApart, 0.0, relative = True)
    cmds.select(myCore)
Ejemplo n.º 7
0
def flowerMaker(nf):
    #erases anything on stage creates a new file
    #cmds.file( f=True, new=True)
    #sets plaback time
    numPetals = 10
    createShader = 1
    #Check for Shader
    shads = cmds.ls()
    for myNode in shads:
        if myNode == "petalColor":
            createShader = 0

    if createShader == 0:
        print "The Shader is already there \n"

    elif createShader == 1:
        cmds.shadingNode('lambert', n="petalColor", asShader=True)
        cmds.shadingNode('ramp', asTexture=True, n="petalRamp")
        cmds.sets(renderable=True,
                  empty=True,
                  noSurfaceShader=True,
                  n='petalColorSG')
        cmds.connectAttr('petalColor.outColor',
                         'petalColorSG.surfaceShader',
                         f=True)
        cmds.connectAttr('petalRamp.outColor', 'petalColor.color')
        cmds.setAttr("petalRamp.colorEntryList[3].color",
                     1,
                     1,
                     0.5,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[3].position", 1)
        cmds.setAttr("petalRamp.colorEntryList[2].color",
                     1,
                     1,
                     1,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[2].position", .5)
        cmds.setAttr("petalRamp.colorEntryList[1].color",
                     1,
                     0.5,
                     0.5,
                     type='double3')
        cmds.setAttr("petalRamp.colorEntryList[1].position", 0)
        cmds.setAttr('petalRamp.type', 8)

        cmds.shadingNode('lambert', n="coreColor", asShader=True)
        cmds.shadingNode('ramp', asTexture=True, n="coreRamp")
        cmds.sets(renderable=True,
                  empty=True,
                  noSurfaceShader=True,
                  n='coreColorSG')
        cmds.connectAttr('coreColor.outColor',
                         'coreColorSG.surfaceShader',
                         f=True)
        cmds.connectAttr('coreRamp.outColor', 'coreColor.color')
        cmds.setAttr("coreRamp.colorEntryList[3].color",
                     1,
                     1,
                     0.5,
                     type='double3')
        cmds.setAttr("coreRamp.colorEntryList[3].position", 1)
        cmds.setAttr("coreRamp.colorEntryList[1].color",
                     1,
                     0.5,
                     0.5,
                     type='double3')
        cmds.setAttr("coreRamp.colorEntryList[1].position", 0)
        cmds.setAttr('coreRamp.type', 8)

    cmds.sphere(ax=(0, 1, 0), n="core")
    #build the flower core
    myCore = cmds.ls(sl=1)
    cmds.scale(1, .5, 1)
    cmds.move(0, 0.2, 0)
    cmds.sets(myCore[0], edit=True, forceElement='coreColorSG')
    #build the petal
    cmds.sphere(ax=(0, 1, 0))
    cmds.move(0, 0, -1.6)
    cmds.scale(.7, .3, 1.7)
    cmds.FreezeTransformations()
    cmds.ResetTransformations()
    myPetal = cmds.ls(sl=1)
    cmds.parent(myPetal, myCore, shape=True)
    cmds.select(myPetal[0])
    cmds.pickWalk(d='down')
    myPetalShape = cmds.ls(sl=1)
    cmds.sets(myPetalShape[0], edit=True, forceElement='petalColorSG')
    #move the tip of the petal
    cmds.select(myPetal[0] + ".cv[3][7]")
    cmds.move(0, 2, 0, r=1)
    #Select the inner part of the petal pull down
    #One loop for the U direction
    for uCV in range(5, 7):
        for vCV in range(0, 8):
            cmds.select(myPetal[0] + ".cv[" + str(uCV) + "][" + str(vCV) + "]")
            cmds.move(0, -0.4, 0, r=1)

    cmds.select(myPetal[0])
    degreeApart = float((360 / numPetals))

    for k in range(3):
        if k is not 0:
            cmds.duplicate()
            cmds.scale((k % 2 + 1) * 0.5)
            cmds.rotate(k * 20, k * 20)
        for i in range(2, numPetals + 1):
            cmds.duplicate()
            cmds.rotate(0, degreeApart, 0, r=1)

    cmds.select(myCore)
    cmds.rename('Flower' + str(nf))