Python maya.cmds.polyCube() Examples

The following are 16 code examples of maya.cmds.polyCube(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: test_cmt_blendshape.py    From cmt with MIT License 6 votes vote down vote up
def test_get_blendshape_on_new_shape(self):
        shape = cmds.polyCube()[0]
        blendshape = bs.get_or_create_blendshape_node(shape)
        self.assertTrue(cmds.objExists(blendshape))
        blendshapes = cmds.ls(type="blendShape")
        self.assertEqual(len(blendshapes), 1)
        self.assertEqual(blendshapes[0], blendshape)

        blendshape = bs.get_or_create_blendshape_node(shape)
        blendshapes = cmds.ls(type="blendShape")
        self.assertEqual(len(blendshapes), 1)
        self.assertEqual(blendshapes[0], blendshape) 
Example #2
Source File: test_skeleton.py    From cmt with MIT License 6 votes vote down vote up
def setUp(self):
        self.group = cmds.createNode("transform", name="skeleton_grp")
        cmds.select(cl=True)
        j1 = cmds.joint(p=(0, 10, 0))
        cmds.joint(p=(1, 9, 0))
        cmds.joint(p=(2, 8, 0))
        j = cmds.joint(p=(3, 9, 0))
        cmds.joint(p=(4, 6, 0))
        cmds.joint(p=(5, 5, 0))
        cmds.joint(p=(6, 3, 0))
        self.cube = cmds.polyCube()[0]
        cmds.parent(self.cube, j)
        cmds.parent(j1, self.group)

        cmds.joint(j1, e=True, oj="xyz", secondaryAxisOrient="yup", ch=True, zso=True)
        self.translates = [
            cmds.getAttr("{0}.t".format(x))[0] for x in cmds.ls(type="joint")
        ]
        self.rotates = [
            cmds.getAttr("{0}.r".format(x))[0] for x in cmds.ls(type="joint")
        ]
        self.orients = [
            cmds.getAttr("{0}.jo".format(x))[0] for x in cmds.ls(type="joint")
        ] 
Example #3
Source File: createGreenCageDeformer.py    From maya_greenCageDeformer with MIT License 6 votes vote down vote up
def doit(cage_tgt=None):
    if not cage_tgt:
        cage_tgt = cmds.ls(sl=True, o=True)
    cage = cage_tgt[0]
    tgt = cage_tgt[1:]

    cmds.loadPlugin('greenCageDeformer.py', qt=True)
    deformer = cmds.deformer(tgt, type='greenCageDeformer')[0]

    freezer = cmds.createNode('transformGeometry')
    cmds.connectAttr(cage + '.o', freezer + '.ig')
    cmds.connectAttr(cage + '.wm', freezer + '.txf')
    cmds.connectAttr(freezer + '.og', deformer + '.bc')
    cmds.disconnectAttr(freezer + '.og', deformer + '.bc')
    cmds.delete(freezer)

    cmds.connectAttr(cage + '.w', deformer + '.ic')
    cmds.dgeval(cmds.listConnections(deformer + '.og', s=False, d=True, sh=True, p=True))


#doit([cmds.polyCube(w=2.5, d=2.5, h=2.5)[0], cmds.polySphere()[0]]) 
Example #4
Source File: Create.py    From rush with MIT License 5 votes vote down vote up
def polyCube():
    cmds.polyCube() 
Example #5
Source File: formExamples.py    From mGui with MIT License 5 votes vote down vote up
def create_cube(*args, **kwargs):
    print "create my cube"
    cmds.polyCube() 
Example #6
Source File: test_Bindings.py    From mGui with MIT License 5 votes vote down vote up
def test_cmds_accessor_get(self):
        cmds.file(new=True, f=True)
        test_obj, _ = cmds.polyCube()
        cmds.xform(test_obj, rotation=(10, 10, 10))
        ac = bindings.CmdsAccessor(test_obj, 'r')
        assert ac.pull() == [(10, 10, 10)] 
Example #7
Source File: test_Bindings.py    From mGui with MIT License 5 votes vote down vote up
def test_py_accessor_get(self):
        cmds.file(new=True, f=True)
        test_obj, _ = cmds.polyCube()
        pynode = pm.PyNode(test_obj)
        ac = bindings.PyNodeAccessor(pynode, 'rx')
        assert ac.pull() == 0 
Example #8
Source File: test_Bindings.py    From mGui with MIT License 5 votes vote down vote up
def test_pynode_accessor(self):
        cmds.file(new=True, f=True)
        cube, shape = pm.polyCube()
        ac = bindings.get_accessor(cube, 'rx')
        assert isinstance(ac, bindings.PyNodeAccessor)
        ac2 = bindings.get_accessor(shape, 'width')
        assert isinstance(ac2, bindings.PyNodeAccessor) 
Example #9
Source File: test_Bindings.py    From mGui with MIT License 5 votes vote down vote up
def test_pynode_accessor_excepts_for_nonexistent_attrib(self):
        cmds.file(new=True, f=True)
        cube, _ = pm.polyCube()
        self.assertRaises(bindings.BindingError, lambda: bindings.get_accessor(cube, 'xyz')) 
Example #10
Source File: test_Bindings.py    From mGui with MIT License 5 votes vote down vote up
def test_bind_to_cmds_string(self):
        ex = self.Example('cube', 45)
        cmds.file(new=True, f=True)
        cmds.polyCube()
        tester = ex & 'val' > bindings.bind() > ('pCube1', 'tx')
        tester()
        assert cmds.getAttr('pCube1.tx') == 45
        tester2 = ex & 'val' > bindings.bind() > 'pCube1.ty'
        tester2()
        assert cmds.getAttr('pCube1.ty') == 45 
Example #11
Source File: test_Bindings.py    From mGui with MIT License 5 votes vote down vote up
def test_bind_to_pyAttr(self):
        ex = self.Example('cube', 45)
        cmds.file(new=True, f=True)
        cube, shape = pm.polyCube()
        tester = ex & 'val' > bindings.bind() > cube.tx
        tester()
        assert cmds.getAttr('pCube1.tx') == 45 
Example #12
Source File: test_Bindings.py    From mGui with MIT License 5 votes vote down vote up
def test_bind_to_pyNode(self):
        ex = self.Example('cube', 45)
        cmds.file(new=True, f=True)
        cube, shape = pm.polyCube()
        tester = ex & 'val' > bindings.bind() > (cube, 'tx')
        tester()
        assert cmds.getAttr('pCube1.tx') == 45 
Example #13
Source File: test_cmt_blendshape.py    From cmt with MIT License 5 votes vote down vote up
def test_get_blendshape_on_existing_blendshape(self):
        shape = cmds.polyCube()[0]
        blendshape = cmds.blendShape(shape)[0]
        existing_blendshape = bs.get_or_create_blendshape_node(shape)
        self.assertEqual(blendshape, existing_blendshape) 
Example #14
Source File: test_cmt_skinio.py    From cmt with MIT License 5 votes vote down vote up
def setUp(self):
        self.joint1 = cmds.joint(p=(-0.5, -0.5, 0))
        self.joint2 = cmds.joint(p=(0, 0.0, 0))
        self.joint3 = cmds.joint(p=(0.5, 0.5, 0))
        self.shape = cmds.polyCube()[0]
        cmds.delete(self.shape, ch=True)
        self.skin = cmds.skinCluster(self.joint1, self.joint2, self.joint3, self.shape)[
            0
        ]
        self.expected = {
            "bindMethod": 1,
            "blendWeights": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            "dropoffRate": 4.0,
            "heatmapFalloff": 0.0,
            "maintainMaxInfluences": False,
            "maxInfluences": 2,
            "name": u"skinCluster1",
            "normalizeWeights": 1,
            "shape": u"pCube1",
            "skinningMethod": 0,
            "useComponents": False,
            "weightDistribution": 0,
            "weights": {
                "joint1": [0.9, 0.5, 0.5, 0.0, 0.5, 0.0, 0.9, 0.5],
                "joint2": [
                    0.10000000000000002,
                    0.5,
                    0.5,
                    0.5,
                    0.5,
                    0.5,
                    0.10000000000000002,
                    0.5,
                ],
                "joint3": [0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0],
            },
        } 
Example #15
Source File: createdNodesContext.py    From AdvancedPythonForMaya with GNU General Public License v3.0 5 votes vote down vote up
def test():
    cmds.file(new=True, force=True)
    with CreatedNodesContext() as cnc:
        cubes = cmds.polyCube()
        cmds.polySphere()
        cmds.spaceLocator()
        cmds.delete(cubes)
        print "Created the following nodes:\n\t%s" % ('\n\t'.join(cnc.nodes())) 
Example #16
Source File: lib.py    From core with MIT License 4 votes vote down vote up
def imprint(node, data):
    """Write `data` to `node` as userDefined attributes

    Arguments:
        node (str): Long name of node
        data (dict): Dictionary of key/value pairs

    Example:
        >>> from maya import cmds
        >>> def compute():
        ...   return 6
        ...
        >>> cube, generator = cmds.polyCube()
        >>> imprint(cube, {
        ...   "regularString": "myFamily",
        ...   "computedValue": lambda: compute()
        ... })
        ...
        >>> cmds.getAttr(cube + ".computedValue")
        6

    """

    for key, value in data.items():

        if callable(value):
            # Support values evaluated at imprint
            value = value()

        if isinstance(value, bool):
            add_type = {"attributeType": "bool"}
            set_type = {"keyable": False, "channelBox": True}
        elif isinstance(value, basestring):
            add_type = {"dataType": "string"}
            set_type = {"type": "string"}
        elif isinstance(value, int):
            add_type = {"attributeType": "long"}
            set_type = {"keyable": False, "channelBox": True}
        elif isinstance(value, float):
            add_type = {"attributeType": "double"}
            set_type = {"keyable": False, "channelBox": True}
        elif isinstance(value, (list, tuple)):
            add_type = {"attributeType": "enum", "enumName": ":".join(value)}
            set_type = {"keyable": False, "channelBox": True}
            value = 0  # enum default
        else:
            raise TypeError("Unsupported type: %r" % type(value))

        cmds.addAttr(node, longName=key, **add_type)
        cmds.setAttr(node + "." + key, value, **set_type)