當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.spaceLocator方法代碼示例

本文整理匯總了Python中maya.cmds.spaceLocator方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.spaceLocator方法的具體用法?Python cmds.spaceLocator怎麽用?Python cmds.spaceLocator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.spaceLocator方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: middlePoint

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def middlePoint(self, a, b, createLocator=False, *args):
        """ Find the point location in the middle of two items.
            Return the middle point position as a vector and a locator in it if want.
        """
        if cmds.objExists(a) and cmds.objExists(b):
            # get xform datas:
            aPos = cmds.xform(a, query=True, worldSpace=True, rotatePivot=True)
            bPos = cmds.xform(b, query=True, worldSpace=True, rotatePivot=True)
            # calculating the result position:
            resultPosX = ( aPos[0] + bPos[0] )/2
            resultPosY = ( aPos[1] + bPos[1] )/2
            resultPosZ = ( aPos[2] + bPos[2] )/2
            resultPos = [resultPosX, resultPosY, resultPosZ]
            if createLocator:
                middleLoc = cmds.spaceLocator(name=a+"_"+b+"_Middle_Loc", position=resultPos)[0]
                cmds.xform(middleLoc, centerPivots=True)
                return [resultPos, middleLoc]
            return[resultPos] 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:20,代碼來源:dpControls.py

示例2: test_seamless_switch

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_seamless_switch(self):
        target = cmds.spaceLocator()[0]
        driver1 = cmds.spaceLocator()[0]
        cmds.setAttr("{}.t".format(driver1), 10, 0, 5)
        driver2 = cmds.spaceLocator()[0]
        cmds.setAttr("{}.t".format(driver2), -5, 2, 1)
        cmds.setAttr("{}.r".format(driver2), 40, 0, 0)

        ss.create_space_switch(
            target, [(driver1, "local"), (driver2, "world")], "space"
        )

        cmds.setAttr("{}.rx".format(driver1), 30)
        m1 = cmds.getAttr("{}.worldMatrix[0]".format(target))

        ss.switch_space(target, "space", 1)

        m2 = cmds.getAttr("{}.worldMatrix[0]".format(target))
        self.assertListAlmostEqual(m1, m2) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:21,代碼來源:test_cmt_spaceswitch.py

示例3: test_create

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_create(self):
        loc1 = cmds.spaceLocator()[0]
        node = rbf.RBF.create(
            inputs=["{}.t{}".format(loc1, x) for x in "xyz"],
            outputs=["{}.s{}".format(loc1, x) for x in "xyz"],
        )
        inputs = node.inputs()
        self.assertEqual(inputs, ["{}.translate{}".format(loc1, x) for x in "XYZ"])
        outputs = node.outputs()
        self.assertEqual(outputs, ["{}.scale{}".format(loc1, x) for x in "XYZ"])
        node.add_sample(input_values=[5, 4, 6], output_values=[2, 1, 2])
        node.add_sample(input_values=[-5, -6, -4], output_values=[0.5, 2, 3])
        cmds.setAttr("{}.t".format(loc1), 0, 0, 0)
        s = cmds.getAttr("{}.s".format(loc1))[0]
        self.assertListAlmostEqual(s, [1.0, 1.0, 1.0])
        cmds.setAttr("{}.t".format(loc1), 5, 4, 6)
        s = cmds.getAttr("{}.s".format(loc1))[0]
        self.assertListAlmostEqual(s, [2.0, 1.0, 2.0])
        cmds.setAttr("{}.t".format(loc1), -5, -6, -4)
        s = cmds.getAttr("{}.s".format(loc1))[0]
        self.assertListAlmostEqual(s, [0.5, 2.0, 3.0]) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:23,代碼來源:test_cmt_rbf.py

示例4: test_create_plot_demo

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_create_plot_demo(self):
        loc1 = cmds.spaceLocator()[0]
        node = rbf.RBF.create(
            inputs=["{}.t{}".format(loc1, x) for x in "xy"],
            outputs=["{}.tz".format(loc1)],
            add_neutral_sample=False,
        )
        node.add_sample(input_values=[0, 0], output_values=[1])
        node.add_sample(input_values=[2, 3], output_values=[0.5])
        node.add_sample(input_values=[3, -1], output_values=[1.5])
        node.add_sample(input_values=[-4, -2], output_values=[-1])
        node.add_sample(input_values=[-2, 3], output_values=[2])
        cmds.setAttr("{}.tx".format(loc1), 0)
        cmds.setAttr("{}.ty".format(loc1), 0)
        tz = cmds.getAttr("{}.tz".format(loc1))
        self.assertAlmostEqual(tz, 1.0) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:18,代碼來源:test_cmt_rbf.py

示例5: test_input_rotation

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_input_rotation(self):
        loc1 = cmds.spaceLocator()[0]
        loc2 = cmds.spaceLocator()[0]
        node = rbf.RBF.create(
            input_transforms=[loc1], outputs=["{}.s{}".format(loc2, x) for x in "xyz"]
        )
        input_transforms = node.input_transforms()
        self.assertEqual(input_transforms, [loc1])
        outputs = node.outputs()
        self.assertEqual(outputs, ["{}.scale{}".format(loc2, x) for x in "XYZ"])
        node.add_sample(input_rotations=[[90, 45, 0]], output_values=[2, 1, 2])
        node.add_sample(input_rotations=[[-90, -60, 0]], output_values=[0.5, 2, 3])
        cmds.setAttr("{}.rx".format(loc1), 90)
        cmds.setAttr("{}.ry".format(loc1), 45)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [2.0, 1.0, 2.0])
        cmds.setAttr("{}.rx".format(loc1), -90)
        cmds.setAttr("{}.ry".format(loc1), -60)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [0.5, 2.0, 3.0])
        cmds.setAttr("{}.rx".format(loc1), 0)
        cmds.setAttr("{}.ry".format(loc1), 0)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [1.0, 1.0, 1.0]) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:26,代碼來源:test_cmt_rbf.py

示例6: test_opm_point_constraint

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_opm_point_constraint(self):
        loc1 = cmds.spaceLocator()[0]
        loc2 = cmds.spaceLocator()[0]
        cmds.setAttr("{}.t".format(loc1), 1, 2, 3)
        cmds.setAttr("{}.t".format(loc2), 2, 2, 4)
        common.opm_point_constraint(loc2, loc1)
        m1 = cmds.getAttr("{}.worldMatrix[0]".format(loc1))
        m2 = cmds.getAttr("{}.worldMatrix[0]".format(loc2))
        self.assertListAlmostEqual(m1, m2)
        cmds.setAttr("{}.tx".format(loc2), 5)
        m1 = cmds.getAttr("{}.worldMatrix[0]".format(loc1))
        m2 = cmds.getAttr("{}.worldMatrix[0]".format(loc2))
        self.assertListAlmostEqual(m1, m2)

        cmds.setAttr("{}.rx".format(loc2), 30)
        m1 = cmds.getAttr("{}.worldMatrix[0]".format(loc1))
        self.assertListAlmostEqual(m1, m2) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:19,代碼來源:test_rig_common.py

示例7: main

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def main(self, objects=None, dummyParent=None, srtDummyParent=None, mode='cut', preSelection=None):
        self.objects = objects
        self.dummyParent = dummyParent
        self.srtDummyParent = srtDummyParent
        self.preSelection = preSelection
        # リストタイプじゃなかったらリストに変換する
        if not isinstance(self.objects, list):
            temp = self.objects
            self.objects = []
            self.objects.append(temp)
        for self.node in self.objects:
            if mode == 'create':
                self.dummyParent = cmds.spaceLocator(name='dummyLocatorForParent')
                return self.dummyParent
            elif mode == 'delete':
                cmds.delete(self.dummyParent)
                return
            elif mode == 'cut':
                self.cutChildNode()
                return
            elif mode == 'custom_cut':
                self.customCutChildNode()
                return
            elif mode == 'parent':
                self.reparentNode()
                return 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:28,代碼來源:common.py

示例8: locator

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def locator():
    cmds.spaceLocator(p=[0, 0, 0])


# Measure Tools 
開發者ID:minoue,項目名稱:rush,代碼行數:7,代碼來源:Create.py

示例9: create_skeleton

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def create_skeleton():
    """
    Create a skeleton hierarchy using the variables provided in the path
    module.

    :return: Skeleton data
    :rtype: dict
    """
    # variable
    joints = {}

    # clear selection
    cmds.select(clear=True)

    # create body
    for body in BODY_HIERARCHY:
        joint = cmds.joint(name="{}_jnt".format(body))
        joints[body] = joint

    # create limbs
    for side in ["l", "r"]:
        cmds.select(joints["hip"])
        for leg in LEG_HIERARCHY:
            joint = cmds.joint(name="{}_{}_jnt".format(side, leg))
            joints["{}_{}".format(side, leg)] = joint

        cmds.select(joints["spine"])
        for arm in ARM_HIERARCHY:
            joint = cmds.joint(name="{}_{}_jnt".format(side, arm))
            joints["{}_{}".format(side, arm)] = joint

    # reference
    reference_name = "reference"
    reference = cmds.spaceLocator(name=reference_name)[0]
    joints["reference"] = reference

    # parent hip to reference
    cmds.parent(joints["hip"], reference)

    return joints 
開發者ID:robertjoosten,項目名稱:video2mocap,代碼行數:42,代碼來源:skeleton.py

示例10: test_input_rotation_swing

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_input_rotation_swing(self):
        loc1 = cmds.spaceLocator()[0]
        loc2 = cmds.spaceLocator()[0]
        node = rbf.RBF.create(
            input_transforms=[loc1], outputs=["{}.s{}".format(loc2, x) for x in "xyz"]
        )
        node.add_sample(
            input_rotations=[[0, 0, 90]],
            output_values=[2, 1, 2],
            rotation_type=rbf.RBF.swing,
        )
        node.add_sample(
            input_rotations=[[0, 0, -90]],
            output_values=[0.5, 2, 3],
            rotation_type=rbf.RBF.swing,
        )
        cmds.setAttr("{}.rx".format(loc1), 90)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [1.0, 1.0, 1.0])
        cmds.setAttr("{}.rx".format(loc1), 0)
        cmds.setAttr("{}.rz".format(loc1), 90)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [2, 1, 2])
        cmds.setAttr("{}.rx".format(loc1), 90)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [2, 1, 2]) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:28,代碼來源:test_cmt_rbf.py

示例11: test_input_rotation_twist

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_input_rotation_twist(self):
        loc1 = cmds.spaceLocator()[0]
        loc2 = cmds.spaceLocator()[0]
        node = rbf.RBF.create(
            input_transforms=[loc1], outputs=["{}.s{}".format(loc2, x) for x in "xyz"]
        )
        node.add_sample(
            input_rotations=[[90, 0, 0]],
            output_values=[2, 1, 2],
            rotation_type=rbf.RBF.twist,
        )
        node.add_sample(
            input_rotations=[[-90, 0, 0]],
            output_values=[0.5, 2, 3],
            rotation_type=rbf.RBF.twist,
        )
        cmds.setAttr("{}.ry".format(loc1), 90)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [1.0, 1.0, 1.0])
        cmds.setAttr("{}.ry".format(loc1), 0)
        cmds.setAttr("{}.rx".format(loc1), 90)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [2, 1, 2])
        cmds.setAttr("{}.rz".format(loc1), 90)
        s = cmds.getAttr("{}.s".format(loc2))[0]
        self.assertListAlmostEqual(s, [2, 1, 2]) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:28,代碼來源:test_cmt_rbf.py

示例12: test_opm_parent_constraint

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_opm_parent_constraint(self):
        loc1 = cmds.spaceLocator()[0]
        loc2 = cmds.spaceLocator()[0]
        cmds.setAttr("{}.t".format(loc1), 1, 2, 3)
        cmds.setAttr("{}.t".format(loc2), 2, 2, 4)
        m1 = cmds.getAttr("{}.worldMatrix[0]".format(loc1))
        common.opm_parent_constraint(loc2, loc1, maintain_offset=True)
        m2 = cmds.getAttr("{}.worldMatrix[0]".format(loc1))
        self.assertListAlmostEqual(m1, m2)
        cmds.setAttr("{}.rx".format(loc2), 30)
        m2 = cmds.getAttr("{}.worldMatrix[0]".format(loc1))
        expected = [
            1.0,
            0.0,
            0.0,
            0.0,
            0.0,
            0.8660254037844387,
            0.49999999999999994,
            0.0,
            0.0,
            -0.49999999999999994,
            0.8660254037844387,
            0.0,
            1.0,
            2.5,
            3.133974596215561,
            1.0,
        ]
        self.assertListAlmostEqual(expected, m2) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:32,代碼來源:test_rig_common.py

示例13: test_add

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_add(self):
        loc = cmds.spaceLocator()[0]
        result = dge("x+3.5", x="{}.tx".format(loc))
        cmds.connectAttr(result, "{}.ty".format(loc))
        cmds.setAttr("{}.tx".format(loc), 5)
        y = cmds.getAttr("{}.ty".format(loc))
        self.assertAlmostEquals(y, 8.5) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:9,代碼來源:test_cmt_dge.py

示例14: test_add_3_to_1

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_add_3_to_1(self):
        loc = cmds.spaceLocator()[0]
        result = dge("x+3", x="{}.t".format(loc))
        cmds.connectAttr(result, "{}.r".format(loc))
        cmds.setAttr("{}.tx".format(loc), 5)
        y = cmds.getAttr("{}.rx".format(loc))
        self.assertAlmostEquals(y, 8.0, places=6) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:9,代碼來源:test_cmt_dge.py

示例15: test_add_1_to_3

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import spaceLocator [as 別名]
def test_add_1_to_3(self):
        loc = cmds.spaceLocator()[0]
        result = dge("3+x", x="{}.t".format(loc))
        cmds.connectAttr(result, "{}.r".format(loc))
        cmds.setAttr("{}.tx".format(loc), 5)
        y = cmds.getAttr("{}.rx".format(loc))
        self.assertAlmostEquals(y, 8.0, places=6) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:9,代碼來源:test_cmt_dge.py


注:本文中的maya.cmds.spaceLocator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。