示例#1
0
 def mirrorSelection(self):
     #try:
         nobjs = pm.instance()
         gr = pm.group(em=True, n = "Mirrored")
         for nobj in nobjs:
             pm.parent( nobj, gr )  ### **** Fix this later to use pymel
         pm.scale( gr, -1,1,1 )
示例#2
0
 def scale_uniform(self, **kwargs):
     ctr = kwargs.get("ctr", None)
     size_offset = kwargs.get("size_offset", 0.5)
     cur_scl = ctr.getScale()
     new_scl = [
         cur_scl[0] + size_offset, cur_scl[1] + size_offset,
         cur_scl[2] + size_offset
     ]
     pm.scale(ctr, new_scl, objectCenterPivot=True, worldSpace=True)
     pm.makeIdentity(ctr, apply=True, scale=True)
     return None
示例#3
0
 def scale_ctr_to_obj(self, **kwargs):
     obj = kwargs.get("cur_obj", None)
     ctr = kwargs.get("ctr", None)
     size_offset = kwargs.get("size_offset", 0.5)
     dup_obj = None
     attr_ip_chk = self.check_attr_input(chk_obj=obj)
     if attr_ip_chk:
         dup_obj = pm.duplicate(obj)[0]
         ch_nd = dup_obj.getChildren()
         sh_nd = dup_obj.getShape()
         for nd in ch_nd:
             if not nd == sh_nd:
                 pm.delete(nd)
         obj = dup_obj
     obj_bnd_bx = obj.getBoundingBox()
     obj_x_y_z_param = self.get_bound_parameters(bound=obj_bnd_bx)
     if obj_x_y_z_param == self.FAIL:
         pm.displayError("Bound parameters not obtained")
         return None
     ctr_bnd_bx = ctr.getBoundingBox()
     ctr_x_y_z_param = self.get_bound_parameters(bound=ctr_bnd_bx)
     if ctr_x_y_z_param == self.FAIL:
         pm.displayError("Bound parameters not obtained")
         return None
     scale_val = [1, 1, 1]
     for index in range(len(ctr_x_y_z_param)):
         if round(float(ctr_x_y_z_param[index]), 2) > 0:
             scale_val[index] = float(obj_x_y_z_param[index] /
                                      ctr_x_y_z_param[index]) + size_offset
         else:
             scale_val[index] = 1
     if dup_obj:
         pm.delete(dup_obj)
     pm.scale(ctr, scale_val, objectCenterPivot=True, worldSpace=True)
     pm.makeIdentity(ctr, apply=True, scale=True)
     return None
示例#4
0
 def flattenToXZero(self):
     pm.scale( [0,1,1], pivot=[0,0,0], scaleYZ = False )
示例#5
0
 def set_shape_size(self, size):
     for shape in self.getShapes():
         pymel.scale(shape.cv[:], (size, size, size))
示例#6
0
    def create_ctrl(self):

        if self.shape == CreateCtrl.triangle:
            ctrl = pm.curve(name=self.name,
                            d=1,
                            p=[(-1, 0, 1), (1, 0, 1), (0, 0, -1), (-1, 0, 1)],
                            k=[
                                0,
                                1,
                                2,
                                3,
                            ])

        elif self.shape == CreateCtrl.square:
            ctrl = pm.curve(name=self.name,
                            degree=1,
                            point=[(0, 2, 2), (0, 2, -2), (0, -2, -2),
                                   (0, -2, 2), (0, 2, 2)])

        elif self.shape == CreateCtrl.octagon:
            ctrl = pm.curve(name=self.name,
                            degree=1,
                            point=[(0, 3, 1), (0, 3, -1), (0, 1, -3),
                                   (0, -1, -3), (0, -3, -1), (0, -3, 1),
                                   (0, -1, 3), (0, 1, 3), (0, 3, 1)])

        elif self.shape == CreateCtrl.circle:
            ctrl = pm.circle(name=self.name,
                             normalX=1,
                             normalZ=0,
                             radius=2,
                             constructionHistory=False)[0]

        elif self.shape == CreateCtrl.cube:
            ctrl = pm.curve(name=self.name,
                            degree=1,
                            point=[(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)])

        elif self.shape == CreateCtrl.pyramid:
            ctrl = pm.curve(name=self.name,
                            degree=1,
                            point=[(1, 2, 1), (1, 2, -1), (-1, 2, -1),
                                   (-1, 2, 1), (1, 2, 1), (0, 0, 0),
                                   (1, 2, -1), (-1, 2, -1), (0, 0, 0),
                                   (-1, 2, 1)])
        elif self.shape == CreateCtrl.cone:
            ctrl = pm.curve(name=self.name,
                            d=1,
                            p=[(-0.5, 2, 0.866025), (0, 0, 0),
                               (0.5, 2, 0.866025), (-0.5, 2, 0.866025),
                               (-1, 2, -1.5885e-07), (0, 0, 0),
                               (-1, 2, -1.5885e-07), (-0.5, 2, -0.866026),
                               (0, 0, 0), (0.5, 2, -0.866025),
                               (-0.5, 2, -0.866026), (0.5, 2, -0.866025),
                               (0, 0, 0), (1, 2, 0), (0.5, 2, -0.866025),
                               (1, 2, 0), (0.5, 2, 0.866025)],
                            k=[
                                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16
                            ])

        elif self.shape == CreateCtrl.diamond:
            ctrl = pm.curve(name=self.name,
                            degree=1,
                            point=[(1, 0, 1), (1, 0, -1), (-1, 0, -1),
                                   (-1, 0, 1),
                                   (1, 0, 1), (0, -2, 0), (1, 0, -1),
                                   (-1, 0, -1), (0, -2, 0), (-1, 0, 1),
                                   (1, 0, 1), (0, 2, 0), (1, 0, -1),
                                   (-1, 0, -1), (0, 2, 0), (-1, 0, 1)])

        elif self.shape == CreateCtrl.one_arrow:
            ctrl = pm.curve(name=self.name,
                            d=1,
                            p=[(0, 1.003235, 0), (0.668823, 0, 0),
                               (0.334412, 0, 0), (0.334412, -0.167206, 0),
                               (0.334412, -0.501617, 0),
                               (0.334412, -1.003235, 0),
                               (-0.334412, -1.003235, 0),
                               (-0.334412, -0.501617, 0),
                               (-0.334412, -0.167206, 0), (-0.334412, 0, 0),
                               (-0.668823, 0, 0), (0, 1.003235, 0)],
                            k=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])

        elif self.shape == CreateCtrl.two_arrow:
            ctrl = pm.curve(name=self.name,
                            d=1,
                            p=[
                                (0, 1, 0),
                                (1, 1, 0),
                                (2, 1, 0),
                                (3, 1, 0),
                                (3, 2, 0),
                                (4, 1, 0),
                                (5, 0, 0),
                                (4, -1, 0),
                                (3, -2, 0),
                                (3, -1, 0),
                                (2, -1, 0),
                                (1, -1, 0),
                                (0, -1, 0),
                                (-1, -1, 0),
                                (-2, -1, 0),
                                (-3, -1, 0),
                                (-3, -2, 0),
                                (-4, -1, 0),
                                (-5, 0, 0),
                                (-4, 1, 0),
                                (-3, 2, 0),
                                (-3, 1, 0),
                                (-2, 1, 0),
                                (-1, 1, 0),
                                (0, 1, 0),
                            ],
                            k=[
                                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
                            ])

        elif self.shape == CreateCtrl.two_arrow_curved:
            ctrl = pm.curve(name=self.name,
                            d=1,
                            p=[(-0.251045, 0, -1.015808),
                               (-0.761834, 0, -0.979696),
                               (-0.486547, 0, -0.930468),
                               (-0.570736, 0, -0.886448),
                               (-0.72786, 0, -0.774834),
                               (-0.909301, 0, -0.550655),
                               (-1.023899, 0, -0.285854),
                               (-1.063053, 0, 9.80765e-009),
                               (-1.023899, 0, 0.285854),
                               (-0.909301, 0, 0.550655),
                               (-0.72786, 0, 0.774834),
                               (-0.570736, 0, 0.886448),
                               (-0.486547, 0, 0.930468),
                               (-0.761834, 0, 0.979696),
                               (-0.251045, 0, 1.015808),
                               (-0.498915, 0, 0.567734),
                               (-0.440202, 0, 0.841857),
                               (-0.516355, 0, 0.802034),
                               (-0.658578, 0, 0.701014),
                               (-0.822676, 0, 0.498232),
                               (-0.926399, 0, 0.258619),
                               (-0.961797, 0, 8.87346e-009),
                               (-0.926399, 0, -0.258619),
                               (-0.822676, 0, -0.498232),
                               (-0.658578, 0, -0.701014),
                               (-0.516355, 0, -0.802034),
                               (-0.440202, 0, -0.841857),
                               (-0.498915, 0, -0.567734),
                               (-0.251045, 0, -1.015808)],
                            k=[
                                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                                26, 27, 28
                            ])

        elif self.shape == CreateCtrl.four_arrow:
            ctrl = pm.curve(name=self.name,
                            d=1,
                            p=[
                                (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),
                                (-1, 0, 3),
                                (-2, 0, 3),
                                (0, 0, 5),
                                (2, 0, 3),
                                (1, 0, 3),
                                (1, 0, 1),
                            ],
                            k=[
                                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
                            ])

        elif self.shape == CreateCtrl.ring:
            ctrl = pm.curve(name=self.name,
                            d=1,
                            p=[(-0.707107, 0.0916408, 0.707107),
                               (0, 0.0916408, 1), (0, -0.0916408, 1),
                               (-0.707107, -0.0916408, 0.707107),
                               (-0.707107, 0.0916408, 0.707107),
                               (-1, 0.0916408, 0), (-1, -0.0916408, 0),
                               (-0.707107, -0.0916408, 0.707107),
                               (-1, -0.0916408, 0),
                               (-0.707107, -0.0916408, -0.707107),
                               (-0.707107, 0.0916408, -0.707107),
                               (-1, 0.0916408, 0),
                               (-0.707107, 0.0916408, -0.707107),
                               (0, 0.0916408, -1), (0, -0.0916408, -1),
                               (-0.707107, -0.0916408, -0.707107),
                               (-0.707107, 0.0916408, -0.707107),
                               (-0.707107, -0.0916408, -0.707107),
                               (0, -0.0916408, -1),
                               (0.707107, -0.0916408, -0.707107),
                               (0.707107, 0.0916408, -0.707107),
                               (0, 0.0916408, -1),
                               (0.707107, 0.0916408, -0.707107),
                               (1, 0.0916408, 0), (1, -0.0916408, 0),
                               (0.707107, -0.0916408, -0.707107),
                               (1, -0.0916408, 0),
                               (0.707107, -0.0916408, 0.707107),
                               (0.707107, 0.0916408, 0.707107),
                               (1, 0.0916408, 0),
                               (0.707107, 0.0916408, 0.707107),
                               (0, 0.0916408, 1), (0, -0.0916408, 1),
                               (0.707107, -0.0916408, 0.707107)],
                            k=[
                                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
                                14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
                                26, 27, 28, 29, 30, 31, 32, 33
                            ])

        elif self.shape == CreateCtrl.sun:
            ctrl = pm.circle(name=self.name, s=16, nr=[0, 1, 0])[0]
            pm.select((ctrl + '.cv[1]'), (ctrl + '.cv[3]'), (ctrl + '.cv[5]'),
                      (ctrl + '.cv[7]'), (ctrl + '.cv[9]'), (ctrl + '.cv[11]'),
                      (ctrl + '.cv[13]'), (ctrl + '.cv[15]'),
                      (ctrl + '.cv[17]'), (ctrl + '.cv[19]'),
                      r=True)
            pm.scale(0.3, 0.3, 0.3, p=[0, 0, 0], r=True)
            pm.makeIdentity(ctrl, apply=True, t=1, r=1, s=1, n=0)
            pm.xform(ctrl, cp=True)

        print(ctrl)
        self.obj = ctrl
        return self.obj