Exemplo n.º 1
0
def movePivot(objects, moveto="zero"):
    for object in objects:
        if moveto == "zero":
            pm.move(0,
                    0,
                    0,
                    object + ".scalePivot",
                    object + ".rotatePivot",
                    absolute=True)
        if moveto == "minY":
            bbox = pm.exactWorldBoundingBox(object)
            currentPivot = pm.xform(object, q=1, rp=1, ws=1)
            #bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2]
            bottom = [currentPivot[0], bbox[1], currentPivot[2]]
            pm.xform(object, piv=bottom, ws=True)
        if moveto == "minX":
            bbox = pm.exactWorldBoundingBox(object)
            currentPivot = pm.xform(object, q=1, rp=1, ws=1)
            #bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2]
            bottom = [bbox[0], currentPivot[1], currentPivot[2]]
            pm.xform(object, piv=bottom, ws=True)
        if moveto == "minZ":
            bbox = pm.exactWorldBoundingBox(object)
            currentPivot = pm.xform(object, q=1, rp=1, ws=1)
            #bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2]
            bottom = [currentPivot[0], currentPivot[1], bbox[2]]
            pm.xform(object, piv=bottom, ws=True)
        if moveto == "center":
            pm.xform(object, cp=1)
Exemplo n.º 2
0
def mirror():
    selectObjs = pm.selected()
    if mirrorCoordinate.getSelect() == 2:
        selectObjs.pop(-1)
    for selectObj in selectObjs:
        # 選択オブジェクト
        prevObj = str(selectObj)  #ミラー処理前の選択オブジェクト名 引数
        sBbox = pm.exactWorldBoundingBox(selectObj)  #引数
        sBboxP = [(sBbox[0] + sBbox[3]) / 2, (sBbox[1] + sBbox[4]) / 2,
                  (sBbox[2] + sBbox[5]) / 2]  #引数

        # 軸の対象となるオブジェクト
        centerObj = pm.selected()[-1]
        cBbox = pm.exactWorldBoundingBox(centerObj)
        # オブジェクトの中心点の取得
        cBboxP = [(cBbox[0] + cBbox[3]) / 2, (cBbox[1] + cBbox[4]) / 2,
                  (cBbox[2] + cBbox[5]) / 2]

        # ピボット位置の設定(ワールド、オブジェクト)
        if mirrorCoordinate.getSelect() == 1:  #ワールド中心
            pivot = [0, 0, 0]  #引数
            mirrorInfo = getScaleAxis(sBboxP, pivot)  #引数
        else:  #オブジェクト中心
            pivot = cBboxP  #引数
            mirrorInfo = getScaleAxis(sBboxP, pivot)  #引数

        createMirror(selectObj, prevObj, sBbox, sBboxP, pivot, mirrorInfo)
    def finalize(self):
        """
        This runs after all the connections are made and the
        hierarchy is built.
        """
        children = self.border.getChildren(type="transform")
        if children:
            bbox = pm.exactWorldBoundingBox(children)
            # Update border to encapsulate the ui elements
            border_shape = self.border.getShape()
            margin = self.settings["margin"]

            cvs = [  # BL, BR, TR, TL, BL
                dt.Vector(bbox[0] - margin, bbox[1] - margin, bbox[2]),
                dt.Vector(bbox[3] + margin, bbox[1] - margin, bbox[2]),
                dt.Vector(bbox[3] + margin, bbox[4] + margin, bbox[2]),
                dt.Vector(bbox[0] - margin, bbox[4] + margin, bbox[2]),
                dt.Vector(bbox[0] - margin, bbox[1] - margin, bbox[2]),
            ]

            # Set cvs and update the shape.
            border_shape.setCVs(cvs, "world")
            border_shape.updateCurve()
        # Run default finalize logic.
        super(Component, self).finalize()
Exemplo n.º 4
0
def create_ibl(*args):
    '''
    # creates an ibl
    '''

    my_ibl = pm.shadingNode('mentalrayIblShape', asLight=True)
    pm.connectAttr('%s.message' % (my_ibl),
                   'mentalrayGlobals.imageBasedLighting',
                   force=True)
    pm.setAttr('%s.primaryVisibility' % (my_ibl), 1)
    pm.setAttr('%s.visibleInReflections' % (my_ibl), 1)
    pm.setAttr('%s.visibleInRefractions' % (my_ibl), 1)
    pm.setAttr('%s.visibleInEnvironment' % (my_ibl), 1)
    pm.setAttr('%s.visibleInFinalGather' % (my_ibl), 1)

    scene_objects = pm.ls(type=[
        'mesh', 'nurbsSurface', 'volumeLight', 'spotLight', 'directionalLight',
        'areaLight', 'pointLight', 'ambientLight'
    ])

    bounding_box = pm.exactWorldBoundingBox(scene_objects)
    bounding_box.sort()

    ibl_size = bounding_box[-1]

    pm.setAttr('%s.scaleX' % (my_ibl), ibl_size)
    pm.setAttr('%s.scaleY' % (my_ibl), ibl_size)
    pm.setAttr('%s.scaleZ' % (my_ibl), ibl_size)

    return my_ibl
Exemplo n.º 5
0
def create_ibl(* args):
    '''
    # creates an ibl
    '''
    
    my_ibl = pm.shadingNode('mentalrayIblShape', asLight= True)
    pm.connectAttr('%s.message' % (my_ibl),
                   'mentalrayGlobals.imageBasedLighting', force= True)
    pm.setAttr('%s.primaryVisibility' % (my_ibl), 1)
    pm.setAttr('%s.visibleInReflections' % (my_ibl), 1)
    pm.setAttr('%s.visibleInRefractions' % (my_ibl), 1)
    pm.setAttr('%s.visibleInEnvironment' % (my_ibl), 1)
    pm.setAttr('%s.visibleInFinalGather' % (my_ibl), 1)
    
    scene_objects = pm.ls(type= ['mesh', 'nurbsSurface', 'volumeLight',
                                'spotLight', 'directionalLight','areaLight',
                                    'pointLight', 'ambientLight'])

    bounding_box = pm.exactWorldBoundingBox(scene_objects)
    bounding_box.sort()
    
    ibl_size = bounding_box[-1]

    pm.setAttr('%s.scaleX' % (my_ibl), ibl_size)
    pm.setAttr('%s.scaleY' % (my_ibl), ibl_size)
    pm.setAttr('%s.scaleZ' % (my_ibl), ibl_size)
    
    return my_ibl
Exemplo n.º 6
0
    def buildGuide(self):
        """Building the guide lines with locators """

        self.saveData()
        self.oVariables()

        bbox = pm.exactWorldBoundingBox(self.geo)
        self.bot = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2]
        self.zmin = [(bbox[0] + bbox[3]) / 2, bbox[1], bbox[2]]
        self.zmax = [(bbox[0] + bbox[3]) / 2, bbox[1], bbox[5]]
        self.xmin = [bbox[0], bbox[1], (bbox[2] + bbox[5]) / 2]
        self.xmax = [bbox[3], bbox[1], (bbox[2] + bbox[5]) / 2]
        """ -------------------- Z AXIS -------------------- """

        if pm.checkBox(
                "myChBxZ",
                q=True,
                v=True,
        ) == 1 and pm.checkBox(
                "myChBxX",
                q=True,
                v=True,
        ) == 0:
            self.axe = 'z'
            self.tiltZ = adb_tilt.Tilt(self.geo, self.tiltctrl,
                                       self.mesh_ctrl_parent,
                                       self.mesh_ctrl_offset, self.axe)
            self.tiltZ.buildGuide()
        """ -------------------- X AXIS -------------------- """

        if pm.checkBox(
                "myChBxX",
                q=True,
                v=True,
        ) == 1 and pm.checkBox(
                "myChBxZ",
                q=True,
                v=True,
        ) == 0:
            self.axe = 'x'
            self.tiltX = adb_tilt.Tilt(self.geo, self.tiltctrl,
                                       self.mesh_ctrl_parent,
                                       self.mesh_ctrl_offset, self.axe)
            self.tiltX.buildGuide()
        """ -------------------- Z AND X AXIS -------------------- """

        if pm.checkBox(
                "myChBxZ",
                q=True,
                v=True,
        ) == 1 and pm.checkBox(
                "myChBxX",
                q=True,
                v=True,
        ) == 1:
            self.axe = 'both'
            self.tiltBoth = adb_tilt.Tilt(self.geo, self.tiltctrl,
                                          self.mesh_ctrl_parent,
                                          self.mesh_ctrl_offset, self.axe)
            self.tiltBoth.buildGuide()
Exemplo n.º 7
0
def bbox(obj):
    coords = {}
    bboxVtx = pm.exactWorldBoundingBox(obj)

    coords['minX'] = bboxVtx[0]
    coords['minY'] = bboxVtx[1]
    coords['minZ'] = bboxVtx[2]
    coords['maxX'] = bboxVtx[3]
    coords['maxY'] = bboxVtx[4]
    coords['maxZ'] = bboxVtx[5]

    if coords['minX'] == coords['maxX']:
        coords['width'] = coords['minX']
        globalPvtX = coords['minX']
    else:
        coords['width'] = coords['maxX'] - coords['minX']
        globalPvtX = coords['maxX'] - (coords['width'] / 2)

    if coords['minY'] == coords['maxY']:
        coords['height'] = coords['minY']
        globalPvtY = coords['minY']
    else:
        coords['height'] = coords['maxY'] - coords['minY']
        globalPvtY = coords['maxY'] - (coords['height'] / 2)

    if coords['minZ'] == coords['maxZ']:
        coords['deph'] = coords['minZ']
        globalPvtZ = coords['minZ']
    else:
        coords['deph'] = coords['maxZ'] - coords['minZ']
        globalPvtZ = coords['maxZ'] - (coords['deph'] / 2)

    coords['globalPvt'] = tuple([globalPvtX, globalPvtY, globalPvtZ])

    return coords
Exemplo n.º 8
0
    def get_angle_on_cam(self, n, cam_name):
        cam = pm.PyNode(cam_name)
        n = pm.PyNode(n)

        if n.nodeType() == 'assemblyReference' and n.getActiveLabel() == '':
            bbox = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
        else:
            bbox = pm.exactWorldBoundingBox(n, ignoreInvisible=True)
        trans_cam = pm.xform(cam, q=True, translation=True, ws=True)

        v0 = [
            trans_cam[0] - bbox[0], trans_cam[1] - bbox[1],
            trans_cam[2] - bbox[2]
        ]
        v1 = [
            trans_cam[0] - bbox[3], trans_cam[1] - bbox[4],
            trans_cam[2] - bbox[5]
        ]
        cos = min(1.0, self.cosVector(v0,
                                      v1))  # To prevent the precision problem
        try:
            angle = math.acos(cos) / 3.14 * 180
        except:  # when cos = -1.0, math domain error happens
            angle = 0.0
        distance = self.get_cam_bbox_dist(bbox, trans_cam)
        return angle, distance
Exemplo n.º 9
0
def create_boundingBoxCtrl(transform):
    """
	Usage:
		create_boundingBoxCtrl( pm.ls(sl=True)[0] )
	"""
    base_name = transform.name().replace("_GEO", "") + "Own"

    bbox = pm.exactWorldBoundingBox(transform, ii=True, ce=True)
    centerX = (bbox[0] + bbox[3]) / 2.0
    centerY = (bbox[1] + bbox[4]) / 2.0
    centerZ = (bbox[2] + bbox[5]) / 2.0
    center_point = (centerX, centerY, centerZ)

    p0 = (bbox[0], bbox[1], bbox[2])
    p1 = (bbox[0], bbox[1], bbox[5])
    p2 = (bbox[0], bbox[4], bbox[2])
    p3 = (bbox[0], bbox[4], bbox[5])
    p4 = (bbox[3], bbox[4], bbox[2])
    p5 = (bbox[3], bbox[4], bbox[5])
    p6 = (bbox[3], bbox[1], bbox[2])
    p7 = (bbox[3], bbox[1], bbox[5])

    points = [p0, p1, p2, p3, p4, p5, p6, p7]
    path_ids = [1, 3, 5, 7, 1, 0, 2, 3, 5, 4, 6, 7, 6, 0, 2, 4]
    path_values = []

    for path_id in path_ids:
        path_values.append(points[path_id])

    curve = pm.curve(p=path_values, n=(base_name + "_CTRL"), d=1)
    curve.rotatePivot.set(center_point)
    curve.scalePivot.set(center_point)
    pm.move(curve, [0, 0, 0], rpr=True)
    pm.makeIdentity(curve, apply=True, n=0, t=True, r=True, s=True)
    con_grp = pm.group(n=base_name + "Con_GRP", em=True)
    con_grp.setParent(curve)
    grp = pm.group(n=base_name + "Offset_GRP", em=True)
    pm.move(grp, center_point, rpr=True)
    curve.setParent(grp, a=True)
    curve.translate.set([0, 0, 0])

    short_name = pm.ls(curve.name(), sn=True)[0].name()
    color = None
    left_color = [6, 15, 29, 28, 18, 27]
    right_color = [13, 12, 31, 4, 30, 21]
    middle_color = [23, 11, 10, 25, 24, 7]
    random_color = random.randint(0, 5)

    if short_name[0] == "l":
        color = left_color[random_color]
    elif short_name[0] == "r":
        color = right_color[random_color]
    else:
        color = middle_color[random_color]
    curve.getShape().overrideEnabled.set(1)
    curve.getShape().overrideColor.set(color)

    return grp
Exemplo n.º 10
0
    def getDimensions(self, mesh):
        # [minX, minY, minZ, maxX, maxY, maxZ]
        bbox = pm.exactWorldBoundingBox(mesh)

        measureX = bbox[3] - bbox[0]
        measureY = bbox[4] - bbox[1]
        measureZ = bbox[5] - bbox[2]

        return measureX, measureY, measureZ
Exemplo n.º 11
0
def findIntersectingGeosPymel(select_overlapping=True):
    geos = pm.selected()
    i = len(geos)
    intersecting_geos = []
    for i in range(len(geos)):
        for compare_i in range((i + 1), len(geos)):
            #print 'comparing %s with %s'%(i, compare_i)
            bbox1 = pm.exactWorldBoundingBox(geos[i])
            bbox2 = pm.exactWorldBoundingBox(geos[compare_i])
            # xmin, ymin, zmin, xmax, ymax, zmax.

            xminA, yminA, zminA, xmaxA, ymaxA, zmaxA = bbox1[0], bbox1[
                1], bbox1[2], bbox1[3], bbox1[4], bbox1[5]
            xminB, yminB, zminB, xmaxB, ymaxB, zmaxB = bbox2[0], bbox2[
                1], bbox2[2], bbox2[3], bbox2[4], bbox2[5]

            intersect_true = (
                ((xminB > xminA) & (xminB < xmaxA)) & ((yminB > yminA) &
                                                       (yminB < ymaxA)) &
                ((zminB > zminA) & (zminB < zmaxA)) | ((xminB > xminA) &
                                                       (xminB < xmaxA)) &
                ((yminB > yminA) & (yminB < ymaxA)) & ((zmaxB > zminA) &
                                                       (zmaxB < zmaxA)) |
                ((xmaxB > xminA) & (xmaxB < xmaxA)) & ((yminB > yminA) &
                                                       (yminB < ymaxA)) &
                ((zminB > zminA) & (zminB < zmaxA)) | ((xmaxB > xminA) &
                                                       (xmaxB < xmaxA)) &
                ((yminB > yminA) & (yminB < ymaxA)) & ((zmaxB > zminA) &
                                                       (zmaxB < zmaxA)) |
                ((xminB > xminA) & (xminB < xmaxA)) & ((ymaxB > yminA) &
                                                       (ymaxB < ymaxA)) &
                ((zminB > zminA) & (zminB < zmaxA)) | ((xminB > xminA) &
                                                       (xminB < xmaxA)) &
                ((ymaxB > yminA) & (ymaxB < ymaxA)) & ((zmaxB > zminA) &
                                                       (zmaxB < zmaxA)) |
                ((xmaxB > xminA) & (xmaxB < xmaxA)) & ((ymaxB > yminA) &
                                                       (ymaxB < ymaxA)) &
                ((zminB > zminA) & (zminB < zmaxA)) | ((xmaxB > xminA) &
                                                       (xmaxB < xmaxA)) &
                ((ymaxB > yminA) & (ymaxB < ymaxA)) & ((zmaxB > zminA) &
                                                       (zmaxB < zmaxA)))
            if intersect_true: intersecting_geos.append(geos[i])
    if select_overlapping: pm.select(intersecting_geos)
    return intersecting_geos
Exemplo n.º 12
0
def getEdgeLoopCenter(edge):
    '''
    extend edge to loop
    return center of boundingbox
    '''
    loop = mel.polySelectSp(edge, loop=True)
    bb = pm.exactWorldBoundingBox(loop)
    xpos = (bb[0] + bb[3]) / 2.0
    ypos = (bb[1] + bb[4]) / 2.0
    zpos = (bb[2] + bb[5]) / 2.0
    return xpos, ypos, zpos
Exemplo n.º 13
0
    def makeCube(self, nameOverride = 'newProxy'):
        currentScale = self.obj.scale.get()
        currentTrans = self.obj.translate.get()
        currentRotate = self.obj.rotate.get()
        # set object transforms to init
        self.obj.scale.set((1,1,1))
        self.obj.rotate.set((0,0,0))
        self.obj.translate.set((0,0,0))

        boundingBox = pm.exactWorldBoundingBox(self.obj)

        # return object to where it was
        self.obj.scale.set(currentScale)
        self.obj.rotate.set(currentRotate)
        self.obj.translate.set(currentTrans)

        height = (boundingBox[4]-boundingBox[1])
        cube = pm.polyCube(width=(boundingBox[3]-boundingBox[0]),
                            height=height,
                            depth=(boundingBox[5]-boundingBox[2]),
                            name=nameOverride + '_box'
                            )[0]

        cube.translate.set(0,height / 2, 0)
        # freeze cube transforms
        pm.makeIdentity(cube, a=1, t=1)

        # create an arrow showing the direction of
        # front rotation
        arrow = pm.curve(
                d=1,
                p=[
                    (-2, 0, 0),
                    (-2, 0, 6),
                    (-4, 0, 6),
                    (0, 0, 10),
                    (4, 0, 6),
                    (2, 0, 6),
                    (2, 0, 0)
                ],
                k=[0,1,2,3,4,5,6],
                n=nameOverride
        )
        pm.parent(cube, arrow)
        # add the cube to display layer
        self.addToDisplayLayer(cube)

        arrow.rotate.set(currentRotate)
        arrow.scale.set(currentScale)
        arrow.translate.set(currentTrans)

        # parent the cube to the arrow

        return (arrow, arrow.name())
Exemplo n.º 14
0
def getEdgeLoopCenter(edge):
    '''
    extend edge to loop
    return center of boundingbox
    '''
    loop = mel.polySelectSp(edge, loop=True)
    bb = pm.exactWorldBoundingBox(loop)
    xpos = (bb[0] + bb[3])/2.0
    ypos = (bb[1] + bb[4])/2.0
    zpos = (bb[2] + bb[5])/2.0
    return xpos, ypos, zpos
Exemplo n.º 15
0
def changeToObj():
    selectObjs = pm.selected()
    for selectObj in selectObjs:
        #選択オジェクトの名前を文字列で取得
        prevSelectObjN = str(selectObj)
        prevSelectObjN = re.sub(r".*\|", "", str(prevSelectObjN))  #
        #選択オブジェクトのピボット(スケール、回転)の取得
        parentObj = selectObj.getParent()
        parentObjSuffix = re.search(r"[^_]*_*$", str(parentObj))
        pParentObj = parentObj.getParent()
        pPParentObj = pParentObj.getParent()
        prevSelectObjSP = pParentObj.scalePivot.get()
        prevSelectObjRP = pParentObj.rotatePivot.get()

        #親の親要素のバウンディングボックスの取得
        pPbox = pm.exactWorldBoundingBox(pParentObj)
        #親の親要素のバウンディングボックスの中心点の取得
        pPboxP = [(pPbox[0] + pPbox[3]) / 2, (pPbox[1] + pPbox[4]) / 2,
                  (pPbox[2] + pPbox[5]) / 2]
        #選択オブジェクトの複製
        newSelectObj = pm.duplicate(selectObj, n=prevSelectObjN)  #

        #親グループの作成。ミラーグループに親がいない場合はワールドにオブジェクトを作成する。
        if pPParentObj != None:
            pm.parent(newSelectObj, pPParentObj)
        else:
            pm.parent(newSelectObj, w=True)
        pm.parent(pParentObj, rm=True)

        #結合した選択オブジェクトの中心点を取る処理
        sBbox = pm.exactWorldBoundingBox(newSelectObj[0])
        sBboxP = [(sBbox[0] + sBbox[3]) / 2, (sBbox[1] + sBbox[4]) / 2,
                  (sBbox[2] + sBbox[5]) / 2]  #
        #ミラーの軸となるピボットの指定(親の親要素の中心点)
        pivot = pPboxP  #

        #ミラーに関する情報の取得
        print "sBboxP,pivotの値の確認", sBboxP, pivot
        mirrorInfo = getScaleAxisObj(sBboxP, pivot, parentObjSuffix.group())  #

        toObj(prevSelectObjN, newSelectObj, sBboxP, pivot, mirrorInfo)
Exemplo n.º 16
0
    def oVariables(self):
        """Defining the starting variables"""
        self.geo = str(pm.textFieldGrp(self.mesh, q=True, text=True))
        self.geoShape = pm.PyNode(self.geo).getShape()

        self.tiltctrl = str(pm.textFieldGrp(self.tiltCtrl, q=True, text=True))
        bbox = pm.exactWorldBoundingBox(self.geo)

        self.mesh_ctrl_parent = str(
            pm.textFieldGrp(self.target, q=True, text=True))
        self.mesh_ctrl_offset = str(
            pm.textFieldGrp(self.offset_ctrl, q=True, text=True))
Exemplo n.º 17
0
def get_boundingbox():
    _box = []
    _is_rendering = renderinggroup.nodes()
    _objs = []
    if _is_rendering:
        _objs = pm.ls(_is_rendering, dag=True, type='mesh')
    else:
        _objs = pm.ls(dag=True, type='mesh')
    if not _objs:
        return _box
    _box = pm.exactWorldBoundingBox(_objs)
    return _box
Exemplo n.º 18
0
 def trackIt(self, a, b):
     first_frame = int(cmds.playbackOptions(query=True, minTime=True))
     last_frame = int(cmds.playbackOptions(query=True, maxTime=True))
     loc = pm.spaceLocator(name="sgSuperTracker")
     for frame in range(first_frame, last_frame + 1):
         cmds.currentTime(frame, edit=True)
         self.intersections(a, b)
         sel = pm.ls(sl=True)
         bb = pm.exactWorldBoundingBox(sel)
         pos = ((bb[0] + bb[3]) / 2, (bb[1] + bb[4]) / 2,
                (bb[2] + bb[5]) / 2)
         pm.xform("sgSuperTracker", ws=True, t=pos)
         pm.setKeyframe("sgSuperTracker" + ".translate")
         pm.select(clear=True)
Exemplo n.º 19
0
    def export(self):
        output_path = self.Output_Path.text()
        if not os.path.exists(output_path):
            self.Output_Path.setText("")
            msg = u"路径不存在"
            QtWidgets.QMessageBox.warning(self, u"警告", msg)
            return

        base_name = os.path.basename(output_path)

        sel_list = pm.ls(sl=1)
        if not sel_list:
            msg = u"请选择一个物体"
            QtWidgets.QMessageBox.warning(self, u"警告", msg)
            return
        for sel in sel_list:
            pm.undoInfo(ock=1)

            pm.parent(sel, w=1)
            # NOTE 居中轴心
            pm.xform(sel, cp=1)

            pm.mel.BakeCustomPivot()
            sel.t.set(0, 0, 0)
            sel.r.set(0, 0, 0)

            x, _, z = pm.xform(sel, q=1, rp=1)
            bbox = pm.exactWorldBoundingBox(sel)
            pm.xform(sel, piv=[x, bbox[1], z])
            sel.t.set(0, -bbox[1], 0)
            pm.makeIdentity(apply=1, t=1, r=1, s=1, n=0, pn=0)

            index = 1
            path = os.path.join(output_path,
                                "%s_%s.ma" % (base_name, str(index).zfill(2)))
            while os.path.exists(path):
                index += 1
                path = os.path.join(
                    output_path, "%s_%s.ma" % (base_name, str(index).zfill(2)))

            path = path.replace('\\', '/')
            print(path)
            # commnad = 'FBXExport -f "%s.fbx" -s ' % path.replace('\\','/')
            # NOTE 导出 ma 文件
            pm.mel.file(path, f=1, options="v=0;", typ="mayaAscii", pr=1, es=1)
            pm.undoInfo(cck=1)

            pm.undo()
Exemplo n.º 20
0
    def center_model(self):
        sel_list = pm.ls(sl=1)
        sel = sel_list[0]

        pm.parent(sel, w=1)
        # NOTE 居中轴心
        pm.xform(sel, cp=1)

        pm.mel.BakeCustomPivot()
        sel.t.set(0, 0, 0)
        sel.r.set(0, 0, 0)

        x, _, z = pm.xform(sel, q=1, rp=1)
        bbox = pm.exactWorldBoundingBox(sel)
        pm.xform(sel, piv=[x, bbox[1], z])
        sel.t.set(0, -bbox[1], 0)
        pm.makeIdentity(apply=1, t=1, r=1, s=1, n=0, pn=0)
Exemplo n.º 21
0
    def makeCube(self, nameOverride='newProxy'):
        currentScale = self.obj.scale.get()
        currentTrans = self.obj.translate.get()
        currentRotate = self.obj.rotate.get()
        # set object transforms to init
        self.obj.scale.set((1, 1, 1))
        self.obj.rotate.set((0, 0, 0))
        self.obj.translate.set((0, 0, 0))

        boundingBox = pm.exactWorldBoundingBox(self.obj)

        # return object to where it was
        self.obj.scale.set(currentScale)
        self.obj.rotate.set(currentRotate)
        self.obj.translate.set(currentTrans)

        height = (boundingBox[4] - boundingBox[1])
        cube = pm.polyCube(width=(boundingBox[3] - boundingBox[0]),
                           height=height,
                           depth=(boundingBox[5] - boundingBox[2]),
                           name=nameOverride + '_box')[0]

        cube.translate.set(0, height / 2, 0)
        # freeze cube transforms
        pm.makeIdentity(cube, a=1, t=1)

        # create an arrow showing the direction of
        # front rotation
        arrow = pm.curve(d=1,
                         p=[(-2, 0, 0), (-2, 0, 6), (-4, 0, 6), (0, 0, 10),
                            (4, 0, 6), (2, 0, 6), (2, 0, 0)],
                         k=[0, 1, 2, 3, 4, 5, 6],
                         n=nameOverride)
        pm.parent(cube, arrow)
        # add the cube to display layer
        self.addToDisplayLayer(cube)

        arrow.rotate.set(currentRotate)
        arrow.scale.set(currentScale)
        arrow.translate.set(currentTrans)

        # parent the cube to the arrow

        return (arrow, arrow.name())
Exemplo n.º 22
0
def calculateSize(joint, scale=1, use_skins=True):
    """
    Calculates the size a control should be based on verts affected bounds or joint radius.

    Args:
        joint (pm.nodetypes.Transform): Uses it's affecting verts or radius to calculate size.

        scale (float): Number to scale result by.

        use_skins (boolean): If True, will try to use the bounding box of influencing skins to calculate size.

    Returns:
        (list): X, Y, Z Scale.
    """
    skin_clusters = joint.future(type='skinCluster')
    if use_skins and skin_clusters:
        distance_sum = 0
        pm.select(cl=True)

        # select the verts joint is affecting and get the bounds all those verts make
        [pm.skinCluster(skin, selectInfluenceVerts=joint, edit=True, ats=True) for skin in skin_clusters]
        selected = pm.selected()
        selected = list(filter(lambda x: not isinstance(x, pm.nodetypes.Mesh), selected))

        # if mesh is selected, its because joint is not influencing any verts, so call itself without doing skins calc
        if not selected:
            return calculateSize(joint, scale, use_skins=False)

        bounds = pm.exactWorldBoundingBox(calculateExactly=True, ii=False)
        pm.select(cl=True)

        # calculate the average distance of the bounds in each axis and use that as the size
        for i in range(3):
            distance_sum += abs(bounds[i] - bounds[i + 3])

        average_distance = (distance_sum / 3.0) * scale * 0.9  # scaling down slightly
        return average_distance, average_distance, average_distance

    elif joint.hasAttr('radius'):
        radius = joint.radius.get() * scale
        return radius, radius, radius

    else:
        return scale, scale, scale
Exemplo n.º 23
0
def main(thersold = 0.01):
        
    # NOTE 选择模型
    pm.pickWalk(d="down")
    for sel in pm.ls(sl=1,type="mesh"):
        bbox = pm.exactWorldBoundingBox(sel)
        x = (bbox[0] + bbox[3])/2
        y = (bbox[1] + bbox[4])/2
        z = (bbox[2] + bbox[5])/2
        pt = OpenMaya.MPoint(x, y, z)
        
        node = sel.node()
        itr = OpenMaya.MItMeshVertex(node.__apimdagpath__())

        l_dict = {}
        c_dict = {}
        r_dict = {}
        while not itr.isDone():
            pt_pos = itr.position(OpenMaya.MSpace.kWorld)
            pt_idx = itr.index()
            pt_x = pt_pos.x
            if pt_x - x > 0 :
                l_dict[pt_idx] = pt_pos
            elif abs(pt_x - x) < thersold:
                c_dict[pt_idx] = pt_pos
            else:
                r_dict[pt_idx] = pt_pos
            itr.next()
        
        match_dict = {}
        for l_idx,l_pos in l_dict.items():
            l_len = (pt - l_pos).length()
            l_len_x = abs(l_pos.x - x)
            for r_idx,r_pos in r_dict.items():
                r_len = (pt - r_pos).length()
                r_len_x = abs(r_pos.x - x)
                if abs(l_len - r_len) < thersold and abs(l_len_x - r_len_x) < thersold :
                    match_dict[l_idx] = r_idx
                    break
        
        for l,r in match_dict.items():
            l_pos = sel.vtx[l].getPosition()
            sel.vtx[r].setPosition(dt.Point(-l_pos.x , l_pos.y , l_pos.z))
Exemplo n.º 24
0
def main():
    
    sel_list = pm.ls(sl=1)
    if not sel_list:
        return
    sel = sel_list[0]
    
    pm.undoInfo(ock=1)

    pm.parent(sel,w=1)
    # NOTE 居中轴心
    pm.xform(sel,cp=1)
    
    pm.mel.BakeCustomPivot()
    
    sel.t.set(0,0,0)
    sel.r.set(0,0,0)
    x,_,z = pm.xform(sel,q=1,rp=1)
    bbox = pm.exactWorldBoundingBox(sel)
    pm.xform(sel,piv=[x,bbox[1],z])
    
    pm.mel.BakeCustomPivot()
    pm.xform(sel,ws=1,t=[0,0,0])
    index = 1
    path = os.path.join(output_path,"%s_%s.ma" % (base_name,str(index).zfill(2)))
    while os.path.exists(path):
        index += 1
        path = os.path.join(output_path,"%s_%s.ma" % (base_name,str(index).zfill(2)))

    path = path.replace('\\','/')
    print(path)
    # commnad = 'FBXExport -f "%s.fbx" -s ' % path.replace('\\','/')
    # NOTE 导出 ma 文件
    pm.mel.file(path,f=1,options="v=0;",typ="mayaAscii",pr=1,es=1)
    pm.undoInfo(cck=1)
    
    pm.undo()
Exemplo n.º 25
0
    def createFootCtrl(self):
        """
		Create foot nurbs curve and place in the feel of the character.
		The control will have the size from the heel helper to the end foot helper
		"""

        footCtrl = rigUtils.createRigControl('foot')
        pm.rename(footCtrl, self.side + footCtrl)
        footCtrl = self.side + footCtrl

        # mirror ctrl if we are doing the right side
        if self.side == 'R':
            pm.scale(footCtrl, (-1, 1, 1))
            pm.makeIdentity(footCtrl, a=True, s=True)

        # place the foot ctrl in the 3rd rig helper (heel)
        pm.delete(pm.pointConstraint(self.side + '_leg_3_rigHelper', footCtrl))
        pm.makeIdentity(footCtrl, a=True, t=True)

        endFootHelper = pm.PyNode(self.side + '_leg_5_rigHelper')
        endFootCtrl = pm.PyNode(self.side + '_foot_ctrl')

        # gets the heel helper world position and the bounding box of the foot controller
        endFootHelperPos = endFootHelper.getTranslation('world')
        bbox = pm.exactWorldBoundingBox(footCtrl)

        # gets the correct scale to feet the helpers
        scaleFactor = (endFootHelperPos[2] - bbox[5]) + 1
        pm.scale(footCtrl, scaleFactor, scaleFactor, scaleFactor)

        pm.makeIdentity(footCtrl, a=True, s=True)

        # parent the control to the new created foot chain
        rigUtils.setControlColor(footCtrl)
        pm.parent(self.footJnt, self.side + '_foot_ctrl')

        return footCtrl
Exemplo n.º 26
0
def aw_deleteHalf():
    '''Takes the current selection and deletes the negative X faces
    Args: none
    Returns: (pm.PyNode)
    '''
    #Get current selection
    curSel=pm.ls(sl=1)[0]

    #Create list of all faces in object
    faceIndex=pm.polyEvaluate(curSel,face=1)

    #Empty list
    negativeFaces=[]

    #loop through faces
    for i in xrange(faceIndex):
         curFace = curSel + '.f[%d]' % i
         #If the exactWorldBoundingBox is negative in X append that face to the empty list
         if pm.exactWorldBoundingBox (curSel + ".f [%d]" %i)[0] < -.0001 :
              negativeFaces.append(curFace)
    #Delete the faces that were put into the empty list + history
    pm.delete(negativeFaces)
    pm.delete(curSel, ch=1)
    return curSel
Exemplo n.º 27
0
def generateCurve(currentSel):
    curvelist = []
    d_outline_char = mc.curve(p=[[-1.244, 1.613, 0.0], [-1.195, 1.613, 0.0],
                                 [-1.195, 2.011, 0.0], [-1.244, 2.011, 0.0],
                                 [-1.244, 1.856, 0.0], [-1.261, 1.872, 0.0],
                                 [-1.271, 1.878, 0.0], [-1.281, 1.884, 0.0],
                                 [-1.291, 1.888, 0.0], [-1.302, 1.891, 0.0],
                                 [-1.313, 1.892, 0.0], [-1.325, 1.893, 0.0],
                                 [-1.338, 1.892, 0.0], [-1.35, 1.89, 0.0],
                                 [-1.362, 1.887, 0.0], [-1.373, 1.883, 0.0],
                                 [-1.383, 1.877, 0.0], [-1.393, 1.87, 0.0],
                                 [-1.402, 1.861, 0.0], [-1.41, 1.851, 0.0],
                                 [-1.418, 1.84, 0.0], [-1.424, 1.829, 0.0],
                                 [-1.43, 1.816, 0.0], [-1.434, 1.803, 0.0],
                                 [-1.438, 1.789, 0.0], [-1.44, 1.774, 0.0],
                                 [-1.442, 1.758, 0.0], [-1.442, 1.741, 0.0],
                                 [-1.441, 1.712, 0.0], [-1.435, 1.685, 0.0],
                                 [-1.426, 1.662, 0.0], [-1.414, 1.642, 0.0],
                                 [-1.398, 1.627, 0.0], [-1.39, 1.62, 0.0],
                                 [-1.38, 1.615, 0.0], [-1.37, 1.611, 0.0],
                                 [-1.359, 1.609, 0.0], [-1.348, 1.607, 0.0],
                                 [-1.336, 1.606, 0.0], [-1.321, 1.607, 0.0],
                                 [-1.307, 1.61, 0.0], [-1.294, 1.614, 0.0],
                                 [-1.282, 1.621, 0.0], [-1.271, 1.629, 0.0],
                                 [-1.261, 1.639, 0.0], [-1.252, 1.651, 0.0],
                                 [-1.244, 1.664, 0.0], [-1.244, 1.613, 0.0]],
                              d=1)
    d_inline_char = mc.curve(p=[[-1.244, 1.821, 0.0], [-1.244, 1.695, 0.0],
                                [-1.264, 1.675, 0.0], [-1.285, 1.661, 0.0],
                                [-1.295, 1.656, 0.0], [-1.305, 1.653, 0.0],
                                [-1.315, 1.651, 0.0], [-1.326, 1.65, 0.0],
                                [-1.341, 1.651, 0.0], [-1.353, 1.656, 0.0],
                                [-1.364, 1.664, 0.0], [-1.373, 1.674, 0.0],
                                [-1.38, 1.688, 0.0], [-1.385, 1.704, 0.0],
                                [-1.388, 1.724, 0.0], [-1.389, 1.746, 0.0],
                                [-1.388, 1.771, 0.0], [-1.385, 1.793, 0.0],
                                [-1.379, 1.811, 0.0], [-1.371, 1.827, 0.0],
                                [-1.36, 1.84, 0.0], [-1.348, 1.848, 0.0],
                                [-1.334, 1.854, 0.0], [-1.318, 1.856, 0.0],
                                [-1.309, 1.855, 0.0], [-1.3, 1.853, 0.0],
                                [-1.282, 1.847, 0.0], [-1.263, 1.836, 0.0],
                                [-1.244, 1.821, 0.0]],
                             d=1)
    i_top_char = mc.curve(p=[[-1.095, 1.937, 0.0], [-1.045, 1.937, 0.0],
                             [-1.045, 1.986, 0.0], [-1.095, 1.986, 0.0],
                             [-1.095, 1.937, 0.0]],
                          d=1)
    i_bottom_char = mc.curve(p=[[-1.095, 1.613, 0.0], [-1.045, 1.613, 0.0],
                                [-1.045, 1.887, 0.0], [-1.095, 1.887, 0.0],
                                [-1.095, 1.613, 0.0]],
                             d=1)
    v_char = mc.curve(p=[[-0.888, 1.613, 0.0], [-0.838, 1.613, 0.0],
                         [-0.73, 1.887, 0.0], [-0.776, 1.887, 0.0],
                         [-0.86, 1.674, 0.0], [-0.94, 1.887, 0.0],
                         [-0.99, 1.887, 0.0], [-0.888, 1.613, 0.0]],
                      d=1)
    sliderFIeld = mc.curve(p=[[-1.428, 1.546, 0.047], [-1.428, 0.998, 0.047],
                              [0.133, 0.998, 0.047], [0.133, 1.546, 0.047],
                              [-1.428, 1.546, 0.047]],
                           d=1)
    slider = mc.curve(p=[[-1.39, 1.5, 0.047], [-1.39, 1.043, 0.047],
                         [-1.133, 1.043, 0.047], [-1.133, 1.5, 0.047],
                         [-1.39, 1.5, 0.047]],
                      d=1)
    line = mc.curve(p=[[0.0, 0.998, 0.0], [0.0, -0.0, 0.0]], d=1)

    curvelist.append(d_outline_char)
    curvelist.append(d_inline_char)
    curvelist.append(i_top_char)
    curvelist.append(i_bottom_char)
    curvelist.append(v_char)
    curvelist.append(sliderFIeld)
    curvelist.append(slider)
    curvelist.append(line)

    sBbox = pm.exactWorldBoundingBox(currentSel)
    sBboxP = [(sBbox[0] + sBbox[3]) / 2, sBbox[4], (sBbox[2] + sBbox[5]) / 2]
    pm.xform(slider, cp=True)
    smoothParentGroup = pm.group(curvelist, n=currentSel + '_smooth_Ctrl')
    smoothParentGroup.scalePivot.set([0, 0, 0])
    smoothParentGroup.rotatePivot.set([0, 0, 0])
    pm.xform(smoothParentGroup, t=sBboxP)
    pm.pointConstraint(currentSel, smoothParentGroup, mo=True)
    return [slider, sliderFIeld, smoothParentGroup]
Exemplo n.º 28
0
    def create_system01(self):
        step = 0
        index = 0
        values = []
        lights_list = []
        for item in self.menu_item_list:
            value = item.get_value()
            values.append(value)
            
        for value in values:
            light_node = pm.shadingNode('%s' % (self.light_types[value]),
                                                    asLight= True)
            light_node.translate.set(step,15,0)
            step += 2
            light_node.rotate.set(-90,0,0)
            node_type = pm.nodeType(light_node.getShape())
            light = pm.rename(light_node, 'fog_%s' % (node_type))
            lights_list.append(light)
            
        if self.checkBox.getValue() == 1:
            
            
            for light in lights_list:
                
                phys_light = pm.mel.eval('mrCreateCustomNode -asUtility "" physical_light;')
            
                pm.connectAttr('%s.message' % (phys_light),
                     '%s.mentalRayControls.miLightShader' % (light.getShape()))
                
        scene_objects = pm.ls(type= ['mesh', 'nurbsSurface', 'volumeLight',
                                'spotLight', 'directionalLight','areaLight',
                                    'pointLight', 'ambientLight'])

        bounding_box = pm.exactWorldBoundingBox(scene_objects)
        bounding_box.sort()
    
        volume_size = bounding_box[-1] * 2.5
        print volume_size, bounding_box[-1], bounding_box
                
        shader = pm.shadingNode('transmat', asShader= True)
        volume = pm.polyCube(name= 'fog_volume', width=volume_size,
                                        height=volume_size, depth=volume_size)[0]
        
        
        pm.hyperShade(volume, assign= shader)
        
        parti_volume = pm.mel.eval('mrCreateCustomNode -asShader "" parti_volume;')
        pm.setAttr('%s.scatter' % (parti_volume), 1,1,1, type= 'double3' )
        
        pm.setAttr('%s.min_step_len' % (parti_volume), .03)
        pm.setAttr('%s.max_step_len' % (parti_volume), .2)
        
        pm.connectAttr('%s.outValue' % (parti_volume),
                       '%sSG.miVolumeShader' % (shader), force= True)
        
        
        for light in lights_list:
            
            pm.connectAttr('%s.message' % (light.getShape()),
                    '%s.lights[%s]' % (parti_volume, str(index)), force= True)
            
            index += 1
Exemplo n.º 29
0
def sink_pivot():
    for obj in pm.ls(sl=True):
        bbox = pm.exactWorldBoundingBox(obj)
        bottom = [(bbox[0] + bbox[3]) / 2, bbox[1], (bbox[2] + bbox[5]) / 2]
        pm.xform(obj, piv=bottom, ws=True)
Exemplo n.º 30
0
def createRigControl(ctrlType, size=1):
    """
	create rig control curves

	:param ctrlType: string
	:return: string - name of the control
	"""

    if ctrlType == 'COG':
        ctrlCrv = mel.eval(
            'string $cog=`curve -d 3 -p 7.06316e-009 0 -1 -p 0.104714 0 -0.990425 -p 0.314142 0 -0.971274 '
            '-p 0.597534 0 -0.821244 -p 0.822435 0 -0.597853 -p 0.96683 0 -0.314057 -p 1.016585 0 -2.28604e-005 '
            '-p 0.96683 0 0.314148 -p 0.822435 0 0.597532 -p 0.597534 0 0.822435 -p 0.314142 0 0.96683 '
            '-p 1.22886e-008 0 1.016585 -p -0.314142 0 0.96683 -p -0.597534 0 0.822435 -p -0.822435 0 0.597532 '
            '-p -0.96683 0 0.314148 -p -1.016585 0 -2.29279e-005 -p -0.96683 0 -0.314057 -p -0.822435 0 -0.597853 '
            '-p -0.597534 0 -0.821244 -p -0.314142 0 -0.971274 -p -0.104714 0 -0.990425 -p 7.06316e-009 0 -1 -k 0 '
            '-k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17'
            ' -k 18 -k 19 -k 20 -k 20 -k 20 -n helperCog`;')
        mel.eval(
            'select -r $cog.ep[1] $cog.ep[3] $cog.ep[5] $cog.ep[7] $cog.ep[9] $cog.ep[11] $cog.ep[13] $cog.ep[15] '
            '$cog.ep[17] $cog.ep[19];')
        mel.eval('scale -r -p 0cm 0cm 0cm 0.732056 0.732056 0.732056 ;')
        mel.eval('select -cl;')
        mel.eval('select $cog')
        mel.eval('scale 0.5 0.5 0.5')
        pm.makeIdentity(a=True, s=True)

        return ctrlCrv

    elif ctrlType == 'cube':
        ctrlCrv = mel.eval(
            'curve -d 1 -p 0.5 0.5 0.5 -p 0.5 0.5 -0.5 -p -0.5 0.5 -0.5 -p -0.5 -0.5 -0.5 '
            '-p 0.5 -0.5 -0.5 -p 0.5 0.5 -0.5 -p -0.5 0.5 -0.5 -p -0.5 0.5 0.5 -p 0.5 0.5 0.5 '
            '-p 0.5 -0.5 0.5 -p 0.5 -0.5 -0.5 -p -0.5 -0.5 -0.5 -p -0.5 -0.5 0.5 -p 0.5 -0.5 0.5 '
            '-p -0.5 -0.5 0.5 -p -0.5 0.5 0.5 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10'
            '-k 11 -k 12 -k 13 -k 14 -k 15 -n "controller_ik" ;')
        return ctrlCrv

    elif ctrlType == 'circle':
        ctrlCrv = pm.circle(name='ctrl', nr=(1, 0, 0), r=0.18)

        return ctrlCrv

    elif ctrlType == 'sphere':
        ctrlCrv = mel.eval(
            'curve -d 1 -p 0 0 1 -p 0 0.5 0.866025 -p 0 0.866025 0.5 -p 0 1 0 -p 0 0.866025 -0.5 '
            '-p 0 0.5 -0.866025 -p 0 0 -1 -p 0 -0.5 -0.866025 -p 0 -0.866025 -0.5 -p 0 -1 0 '
            '-p 0 -0.866025 0.5 -p 0 -0.5 0.866025 -p 0 0 1 -p 0.707107 0 0.707107 -p 1 0 0 '
            '-p 0.707107 0 -0.707107 -p 0 0 -1 -p -0.707107 0 -0.707107 -p -1 0 0 -p -0.866025 0.5 0 '
            '-p -0.5 0.866025 0 -p 0 1 0 -p 0.5 0.866025 0 -p 0.866025 0.5 0 -p 1 0 0 '
            '-p 0.866025 -0.5 0 -p 0.5 -0.866025 0 -p 0 -1 0 -p -0.5 -0.866025 0 -p -0.866025 -0.5 0 '
            '-p -1 0 0 -p -0.707107 0 0.707107 -p 0 0 1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 '
            '-k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23'
            '-k 24 -k 25 -k 26 -k 27 -k 28 -k 29 -k 30 -k 31 -k 32 -n "ctrl" ;'
        )
        return ctrlCrv

    elif ctrlType == 'poleVector':
        ctrlCrv = mel.eval(
            'curve -d 1 -p 0.5 -1 0.866025 -p -0.5 -1 0.866025 -p 0 1 0 -p 0.5 -1 0.866025 -p 1 -1 0 '
            '-p 0 1 0 -p 0.5 -1 -0.866025 -p 1 -1 0 -p 0 1 0 -p -0.5 -1 -0.866026 -p 0.5 -1 -0.866025'
            '-p 0 1 0 -p -1 -1 -1.5885e-007 -p -0.5 -1 -0.866026 -p 0 1 0 -p -0.5 -1 0.866025 '
            '-p -1 -1 -1.5885e-007 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 '
            '-k 12 -k 13 -k 14 -k 15 -k 16 -n poleVector_ctrl;')
        pm.scale(ctrlCrv, (0.05, 0.05, 0.05))
        pm.rotate(ctrlCrv, (90, 0, 0))
        pm.makeIdentity(a=True, r=True, s=True)

        return ctrlCrv

    elif ctrlType == 'cross':
        ctrlCrv = mel.eval(
            'curve -d 1 -p 2 0 1 -p 2 0 -1 -p 1 0 -1 -p 1 0 -2 -p -1 0 -2 -p -1 0 -1 -p -2 0 -1 -p -2 0 1 '
            '-p -1 0 1 -p -1 0 2 -p 1 0 2 -p 1 0 1 -p 2 0 1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 '
            '-k 10 -k 11 -k 12 -n "controller_ik" ;')

        pm.scale(ctrlCrv, (0.5, 0.5, 0.5))
        pm.makeIdentity(a=True, s=True)

        return ctrlCrv

    elif ctrlType == 'foot':
        ctrlCrv = mel.eval(
            'curve -d 1 -p -0.081122 0 -1.11758 -p 0.390719 0 -0.921584 -p 0.514124 0 -0.616704 '
            '-p 0.412496 0 0.0293557 -p 0.86256 0 0.552008 -p 0.920632 0 1.161772 -p 0.775452 0 1.669908 '
            '-p 0.38346 0 2.011088 -p -0.131936 0 2.330484 -p -0.552964 0 2.308708 -p -0.654588 0 1.691688 '
            '-p -0.57474 0 0.63912 -p -0.364226 0 0.109206 -p -0.531184 0 -0.39893 -p -0.465852 0 -0.841736 '
            '-p -0.081122 0 -1.11758 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 '
            '-k 14 -k 15 -n "_foot_ctrl" ;')
        pm.scale(ctrlCrv, (0.25, 0.25, 0.25))
        pm.makeIdentity(ctrlCrv, a=True, s=True)

        # place the pivot at the back
        bbox = pm.exactWorldBoundingBox(ctrlCrv)
        bottom = [(bbox[0] / 8.0), bbox[1], bbox[2]]
        pm.xform(ctrlCrv, piv=bottom, ws=True)

        # move the ctrl to 0,0,0 and freeze transfroms
        pm.move(ctrlCrv, (0.02, 0, 0.279))
        pm.makeIdentity(ctrlCrv, a=True, t=True)

        return ctrlCrv

    elif ctrlType == 'pin':
        ctrlCrv = mel.eval(
            'curve -d 1 -p 0 0 0 -p -2 0 0 -p -2.292893 0 0.707107 -p -3 0 1 -p -3.707107 0 0.707107 '
            '-p -4 0 0 -p -3.707107 0 -0.707107 -p -3 0 -1 -p -2.292893 0 -0.707107 -p -2 0 0 '
            '-p -2.292893 0 0.707107 -p -3.707107 0 -0.707107 -p -4 0 0 -p -3.707107 0 0.707107 '
            '-p -2.292893 0 -0.707107 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12'
            '-k 13 -k 14 -n "pinCtrl";')
        pm.scale(ctrlCrv, (0.1, 0.1, 0.1))
        pm.makeIdentity(a=True, s=True)

        return ctrlCrv

    else:
        print('---> Debug: Cannot create ctrl based on the given name: %s' %
              ctrlType)
        print(
            '---> Debug: accepted types: foot, cross, poleVector, pin, sphere, circle, cube'
        )
        #pm.warning(m='cannot create ctrl based on the given name')

    pm.scale(ctrlCrv, (size, size, size))
    pm.makeIdentity(a=True, s=True)
Exemplo n.º 31
0
    def makeLocators(self,
                     num=None,
                     nameOfSurface=None,
                     scaleOfItems=None,
                     randomScale=None,
                     minRandomScale=None,
                     maxRandomScale=None,
                     setToNormals=None,
                     randomRotation=None,
                     randomX=None,
                     randomY=None,
                     randomZ=None,
                     minRandomRotation=None,
                     maxRandomRotation=None):
        """ Populates a given surface with objects.
            @param num: fl, percentage of geometry to be covered
            @param nameOfsurface: str, name given by user to determine the surface
            @param scaleOfItems: int, scale of items being duplicated
            @param randomScale: bool, randomizes scale between a range of minimum and maximum values
            @param minRandomScale: int, minimum scale of object
            @param maxRandomScale: int, maximum scale of object
            @param randomRotation: bool, randomizes rotation between a range of minimum and maximum values
            @param randomX: bool, randomizes the X rotation between a range of minimum and maximum values
            @param randomY: bool, randomizes the Y rotation between a range of minimum and maximum values
            @param randomZ: bool, randomizes the Z rotation between a range of minimum and maximum values
            @param minRandomRotation: int, minimum rotation of object
            @param maxRandomRotation: int, maximum rotation of object
        """

        selectedObject = pm.ls(sl=True)
        sizeOfSelectedObject = int(pm.getAttr(selectedObject[0] + '.scaleY'))
        boundingBox = pm.exactWorldBoundingBox(selectedObject)
        bottom = [(boundingBox[0] + boundingBox[3]) / 2, boundingBox[1],
                  (boundingBox[2] + boundingBox[5]) / 2]
        pm.xform(selectedObject, piv=bottom, ws=True)
        pm.select(nameOfSurface)
        pm.select(selectedObject, add=True)
        pm.parentConstraint(nameOfSurface, selectedObject, mo=False)
        pm.delete(selectedObject, cn=True)

        def vertLocators():
            """ Iterates through vertices on surface, attaches locators and objects
            """

            # Selects all vertices, puts all vertice coordinates in a list
            pm.select(nameOfSurface)
            vs = pm.polyEvaluate(v=True)
            verts = []
            vertLocCount = 0
            for i in range(0, vs):
                verts += (pm.pointPosition(nameOfSurface + '.vtx[' + str(i) +
                                           ']'), )

            # Creates locators
            for v in verts:
                numGen = r.random()
                if (numGen <= num):
                    pm.spaceLocator(n="vertexLoc{0}".format(1),
                                    p=(v[0], v[1], v[2]))
                    duplicatedObject = pm.instance(selectedObject, leaf=True)
                    pm.setAttr(duplicatedObject[0] + '.translate',
                               (v[0], v[1], v[2]))
                    randomScaleNumber = r.randrange(minRandomScale,
                                                    maxRandomScale)
                    randomRotationNumber = r.randrange(minRandomRotation,
                                                       maxRandomRotation)

                    if randomScale is True:
                        pm.setAttr(duplicatedObject[0] + '.scale',
                                   randomScaleNumber, randomScaleNumber,
                                   randomScaleNumber)

                    if setToNormals is True:
                        print(v)
                        rotOrder = mc.getAttr(nameOfSurface + '.rotateOrder')
                        pointOrigin = 0
                        originalPosition = om.MVector(v)
                        print(originalPosition)
                        # poly = PyNode(nameOfSurface)
                        # pos = [v[0], v[1], v[2]]
                        # count = 0
                        # for point in poly.getPoints('world'):
                        #     if dt.Vector(point) == dt.Vector(pos):
                        #         poly = PyNode(nameOfSurface + '.vtx[' + str(count) + ']')
                        #         normalVector = poly.getNormal()
                        #         print("normals: {0}".format(normalVector))
                        #     count += 1

                    if randomRotation is True:
                        pm.setAttr(duplicatedObject[0] + '.rotate',
                                   randomRotationNumber, randomRotationNumber,
                                   randomRotationNumber)

                    if randomX is True:
                        pm.setAttr(duplicatedObject[0] + '.rotateX',
                                   randomRotationNumber)

                    if randomY is True:
                        pm.setAttr(duplicatedObject[0] + '.rotateY',
                                   randomRotationNumber)

                    if randomZ is True:
                        pm.setAttr(duplicatedObject[0] + '.rotateZ',
                                   randomRotationNumber)

                    vertLocCount += 1

            totalVerts = round(float(vertLocCount) / vs * 100.0, 2)
            _logger.debug("Generated " + str(vertLocCount) +
                          " locators at vertices for " + str(vs) +
                          " possible vertices. (" + str(totalVerts) + "%) ")

        def faceLocators():
            """ Iterates through faces on surface, attaches locators and objects
            """

            # Selects all faces, puts average center coordinates in a list
            pm.select(nameOfSurface)
            fc = pm.polyEvaluate(face=True)
            faceLocCount = 0
            for x in range(0, fc):
                numGen = r.random()
                bBox = pm.xform(nameOfSurface + '.f[' + str(x) + ']',
                                ws=True,
                                q=True,
                                bb=True)
                transX = (bBox[0] + bBox[3]) / 2
                transY = (bBox[1] + bBox[4]) / 2
                transZ = (bBox[2] + bBox[5]) / 2

                # Creates locators
                if (numGen <= num):
                    pm.spaceLocator(n="faceLoc{0}".format(1),
                                    p=(transX, transY, transZ))
                    duplicatedObject = pm.instance(selectedObject, leaf=True)
                    pm.setAttr(duplicatedObject[0] + '.translate', transX,
                               transY, transZ)
                    randomScaleNumber = r.randrange(minRandomScale,
                                                    maxRandomScale)
                    randomRotationNumber = r.randrange(minRandomRotation,
                                                       maxRandomRotation)

                    if randomScale is True:
                        pm.setAttr(duplicatedObject[0] + '.scale',
                                   randomScaleNumber, randomScaleNumber,
                                   randomScaleNumber)

                    if setToNormals is True:
                        poly = PyNode(nameOfSurface + '.f[' + str(x) + ']')
                        normalVector = poly.getNormal()

                    if randomRotation is True:
                        pm.setAttr(duplicatedObject[0] + '.rotate',
                                   randomRotationNumber, randomRotationNumber,
                                   randomRotationNumber)

                    if randomX is True:
                        pm.setAttr(duplicatedObject[0] + '.rotateX',
                                   randomRotationNumber)

                    if randomY is True:
                        pm.setAttr(duplicatedObject[0] + '.rotateY',
                                   randomRotationNumber)

                    if randomZ is True:
                        pm.setAttr(duplicatedObject[0] + '.rotateZ',
                                   randomRotationNumber)

                    faceLocCount += 1

            totalFace = round(float(faceLocCount) / fc * 100.0, 2)
            _logger.debug("Generated " + str(faceLocCount) +
                          " locators at faces for " + str(fc) +
                          " possible surfaces.(" + str(totalFace) + "%) ")

        if (num < 0.01 or num > 10.0):
            _logger.error("Error. Please input a number between 1 and 100")
        elif (pm.objExists(nameOfSurface) is False):
            _logger.error(
                "Error. Enter a name of a plane that exists in your project.")
        else:
            vertLocators()
            faceLocators()
Exemplo n.º 32
0
#moveToOrigin.py

import pymel.core as pm

obj = pm.selected()

box = pm.exactWorldBoundingBox(obj)
bottom = [(box[0] + box[3]) / 2, box[1], (box[2] + box[5]) / 2]
pm.xform(obj, piv=bottom, ws=True)
pm.move(0, 0, 0, obj, rpr=True, ws=True)
pm.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
Exemplo n.º 33
0
def calculateSize(joint, scale=1, use_skins=True, try_root=True):
    """
    Calculates the size a control should be based on verts affected bounds or joint radius.

    Args:
        joint (pm.nodetypes.Transform): Uses it's affecting verts or radius to calculate size.

        scale (float): Number to scale result by.

        use_skins (boolean): If True, will try to use the bounding box of influencing skins to calculate size.

        try_root (boolean): If True, will try to get the average length of the vertex positions of the meshes

    Returns:
        (list): X, Y, Z Scale.
    """
    skin_clusters = joint.future(type='skinCluster')
    joint_name = joint.name(stripNamespace=True)

    if try_root and joint_name == pcfg.root_joint_name:
        skins = {
            skin
            for bone in joint.getChildren(ad=True)
            for skin in bone.future(type='skinCluster')
        }
        meshes = {
            geo.getParent()
            for skin in skins for geo in skin.getGeometry()
        }

        # no mesh is not bound
        if not meshes:
            return calculateSize(joint, scale, use_skins=False, try_root=False)

        length = 0
        positions = []

        for mesh in meshes:
            positions += myu.getVertexPositions(mesh)

        for position in positions:
            projection = [position[0], 0, position[2]]  # project onto XZ plane
            length += pipermath.magnitude(projection)

        average_length = length / len(positions)
        return average_length, average_length, average_length

    elif use_skins and skin_clusters:
        distance_sum = 0
        pm.select(cl=True)

        # select the verts joint is affecting and get the bounds all those verts make
        [
            pm.skinCluster(skin,
                           selectInfluenceVerts=joint,
                           edit=True,
                           ats=True) for skin in skin_clusters
        ]
        selected = pm.selected()
        selected = list(
            filter(lambda x: not isinstance(x, pm.nodetypes.Mesh), selected))

        # if mesh is selected, its because joint is not influencing any verts, so call itself without doing skins calc
        if not selected:
            return calculateSize(joint, scale, use_skins=False)

        bounds = pm.exactWorldBoundingBox(calculateExactly=True, ii=False)
        pm.select(cl=True)

        # calculate the average distance of the bounds in each axis and use that as the size
        for i in range(3):
            distance_sum += abs(bounds[i] - bounds[i + 3])

        average_distance = (distance_sum /
                            3.0) * scale * 0.9  # scaling down slightly
        return average_distance, average_distance, average_distance

    elif joint.hasAttr('radius'):
        radius = joint.radius.get() * scale
        return radius, radius, radius

    else:
        return scale, scale, scale
Exemplo n.º 34
0
    def create_system01(self):
        step = 0
        index = 0
        values = []
        lights_list = []
        for item in self.menu_item_list:
            value = item.get_value()
            values.append(value)

        for value in values:
            light_node = pm.shadingNode('%s' % (self.light_types[value]),
                                        asLight=True)
            light_node.translate.set(step, 15, 0)
            step += 2
            light_node.rotate.set(-90, 0, 0)
            node_type = pm.nodeType(light_node.getShape())
            light = pm.rename(light_node, 'fog_%s' % (node_type))
            lights_list.append(light)

        if self.checkBox.getValue() == 1:

            for light in lights_list:

                phys_light = pm.mel.eval(
                    'mrCreateCustomNode -asUtility "" physical_light;')

                pm.connectAttr(
                    '%s.message' % (phys_light),
                    '%s.mentalRayControls.miLightShader' % (light.getShape()))

        scene_objects = pm.ls(type=[
            'mesh', 'nurbsSurface', 'volumeLight', 'spotLight',
            'directionalLight', 'areaLight', 'pointLight', 'ambientLight'
        ])

        bounding_box = pm.exactWorldBoundingBox(scene_objects)
        bounding_box.sort()

        volume_size = bounding_box[-1] * 2.5
        print volume_size, bounding_box[-1], bounding_box

        shader = pm.shadingNode('transmat', asShader=True)
        volume = pm.polyCube(name='fog_volume',
                             width=volume_size,
                             height=volume_size,
                             depth=volume_size)[0]

        pm.hyperShade(volume, assign=shader)

        parti_volume = pm.mel.eval(
            'mrCreateCustomNode -asShader "" parti_volume;')
        pm.setAttr('%s.scatter' % (parti_volume), 1, 1, 1, type='double3')

        pm.setAttr('%s.min_step_len' % (parti_volume), .03)
        pm.setAttr('%s.max_step_len' % (parti_volume), .2)

        pm.connectAttr('%s.outValue' % (parti_volume),
                       '%sSG.miVolumeShader' % (shader),
                       force=True)

        for light in lights_list:

            pm.connectAttr('%s.message' % (light.getShape()),
                           '%s.lights[%s]' % (parti_volume, str(index)),
                           force=True)

            index += 1
Exemplo n.º 35
0
    def makeLocators(self,
                     num=None,
                     nameOfSurface=None,
                     scaleOfItems=None,
                     randomScale=None):
        """ Function to place random locators on a given name

        makeLocators() takes 2 arguments-
            num = a percentage between 0.0 and 1 for
            relative density of locators
            nameOfSurface = name of surface in the open Project,
            input as a String
        Example Usage: makeLocators(0.1, "geo") <-- places
            locator over surface "geo", with a 10% density
        """

        # Puts all geometry in the scene into a list
        selectedObject = pm.ls(sl=True)
        sizeOfSelectedObject = int(pm.getAttr(selectedObject[0] + '.scaleY'))
        boundingBox = pm.exactWorldBoundingBox(selectedObject)
        bottom = [(boundingBox[0] + boundingBox[3]) / 2, boundingBox[1],
                  (boundingBox[2] + boundingBox[5]) / 2]
        pm.xform(selectedObject, piv=bottom, ws=True)
        pm.select(nameOfSurface)
        pm.select(selectedObject, add=True)
        pm.parentConstraint(nameOfSurface, selectedObject, mo=False)
        pm.delete(selectedObject, cn=True)

        def vertLocators():
            """ Iterates through vertices on surface, attaches Locators """

            # Selects all vertices, puts all vertice coordinates in a list
            pm.select(nameOfSurface)
            vs = pm.polyEvaluate(v=True)
            verts = []
            vertLocCount = 0
            for i in range(0, vs):
                verts += (pm.pointPosition(nameOfSurface + '.vtx[' + str(i) +
                                           ']',
                                           world=True), )

            # Creates locators
            for v in verts:
                numGen = r.random() * 10.0
                if (numGen <= num):
                    pm.spaceLocator(n="vertexLoc{0}".format(1),
                                    p=(v[0], v[1], v[2]))
                    duplicatedObject = pm.instance(selectedObject, leaf=True)
                    pm.setAttr(duplicatedObject[0] + '.translate', v[0],
                               v[1] + scaleOfItems, v[2])

                    vertRotations = calculateRotations(node=nameOfSurface,
                                                       vertPositions=v)

                    if (randomScale is True):
                        pm.setAttr(duplicatedObject[0] + '.scale',
                                   (scaleOfItems * numGen),
                                   (scaleOfItems * numGen),
                                   (scaleOfItems * numGen))
                    else:
                        pm.setAttr(duplicatedObject[0] + '.scale',
                                   scaleOfItems, scaleOfItems, scaleOfItems)

                    vertLocCount += 1

            totalVerts = round(float(vertLocCount) / vs * 100.0, 2)
            print("Generated " + str(vertLocCount) +
                  " locators at vertices for " + str(vs) +
                  " possible vertices. (" + str(totalVerts) + "%)")

        def calculateRotations(node=None, vertPositions=None):
            rotateOrder = pm.getAttr(node + '.rotateOrder')
            worldOrigin = om.MVector(0, 0, 0)

            # mTransformMtx = om.MTransformationMatrix(matrix)

            # eulerRot = mTransformMtx.eulerRotation()

            # eulerRot.reorderIt(rotateOrder)

            # rotAngle = [
            #     math.degrees(angle) for angle in (
            #         eulerRot.x, eulerRot.y, eulerRot.z)]

            # print('Angles: {0}'.format(rotAngle))

            # return rotAngle

        def faceLocators():
            """ Iterates through faces on surface, attaches Locators """

            # Selects all faces, puts average center coordinates in a list
            pm.select(nameOfSurface)
            fc = pm.polyEvaluate(face=True)
            faces = []
            faceLocCount = 0
            for x in range(0, fc):
                numGen = r.random() * 10.0
                bBox = pm.xform(nameOfSurface + '.f[' + str(x) + ']',
                                ws=True,
                                q=True,
                                bb=True)
                transX = (bBox[0] + bBox[3]) / 2
                transY = (bBox[1] + bBox[4]) / 2
                transZ = (bBox[2] + bBox[5]) / 2

                # Creates locators
                if (numGen <= num):
                    faceLocsNames = pm.spaceLocator(n="faceLoc{0}".format(1),
                                                    p=(transX, transY, transZ))
                    duplicatedObject = pm.instance(selectedObject, leaf=True)
                    pm.setAttr(duplicatedObject[0] + '.translate', transX,
                               transY + scaleOfItems, transZ)

                    if (randomScale is True):
                        pm.setAttr(duplicatedObject[0] + '.scale',
                                   (scaleOfItems * numGen),
                                   (scaleOfItems * numGen),
                                   (scaleOfItems * numGen))
                    else:
                        pm.setAttr(duplicatedObject[0] + '.scale',
                                   scaleOfItems, scaleOfItems, scaleOfItems)

                    faceLocCount += 1

            totalFace = round(float(faceLocCount) / fc * 100.0, 2)
            print("Generated " + str(faceLocCount) +
                  " locators at faces for " + str(fc) +
                  " possible surfaces.(" + str(totalFace) + "%)")

        if (num < 1 or num > 10):
            print("Error. Please input a number between 1 and 10")
        elif (pm.objExists(nameOfSurface) is False):
            print(
                "Error. Enter a name of a plane that exists in your project.")
        else:
            vertLocators()
            faceLocators()
Exemplo n.º 36
0
def generateChildCurve(currentSel):
    curvelist = []
    d_outline_char = mc.curve(p=[[-0.384, 1.094, 0.0], [-0.335, 1.094, 0.0],
                                 [-0.335, 1.492, 0.0], [-0.384, 1.492, 0.0],
                                 [-0.384, 1.337, 0.0], [-0.401, 1.353, 0.0],
                                 [-0.411, 1.359, 0.0], [-0.421, 1.365, 0.0],
                                 [-0.431, 1.369, 0.0], [-0.442, 1.372, 0.0],
                                 [-0.453, 1.373, 0.0], [-0.465, 1.374, 0.0],
                                 [-0.478, 1.373, 0.0], [-0.49, 1.371, 0.0],
                                 [-0.502, 1.368, 0.0], [-0.513, 1.364, 0.0],
                                 [-0.523, 1.358, 0.0], [-0.533, 1.351, 0.0],
                                 [-0.542, 1.342, 0.0], [-0.55, 1.332, 0.0],
                                 [-0.558, 1.321, 0.0], [-0.564, 1.31, 0.0],
                                 [-0.57, 1.297, 0.0], [-0.574, 1.284, 0.0],
                                 [-0.578, 1.27, 0.0], [-0.58, 1.255, 0.0],
                                 [-0.582, 1.239, 0.0], [-0.582, 1.222, 0.0],
                                 [-0.581, 1.193, 0.0], [-0.575, 1.166, 0.0],
                                 [-0.566, 1.143, 0.0], [-0.554, 1.123, 0.0],
                                 [-0.538, 1.108, 0.0], [-0.53, 1.101, 0.0],
                                 [-0.52, 1.096, 0.0], [-0.51, 1.092, 0.0],
                                 [-0.499, 1.09, 0.0], [-0.488, 1.088, 0.0],
                                 [-0.476, 1.087, 0.0], [-0.461, 1.088, 0.0],
                                 [-0.447, 1.091, 0.0], [-0.434, 1.095, 0.0],
                                 [-0.422, 1.102, 0.0], [-0.411, 1.11, 0.0],
                                 [-0.401, 1.12, 0.0], [-0.392, 1.132, 0.0],
                                 [-0.384, 1.145, 0.0], [-0.384, 1.094, 0.0]],
                              d=1)
    d_inline_char = mc.curve(p=[[-0.384, 1.302, 0.0], [-0.384, 1.176, 0.0],
                                [-0.404, 1.156, 0.0], [-0.425, 1.142, 0.0],
                                [-0.435, 1.137, 0.0], [-0.445, 1.134, 0.0],
                                [-0.455, 1.132, 0.0], [-0.466, 1.131, 0.0],
                                [-0.481, 1.132, 0.0], [-0.493, 1.137, 0.0],
                                [-0.504, 1.145, 0.0], [-0.513, 1.155, 0.0],
                                [-0.52, 1.169, 0.0], [-0.525, 1.185, 0.0],
                                [-0.528, 1.205, 0.0], [-0.529, 1.227, 0.0],
                                [-0.528, 1.252, 0.0], [-0.525, 1.274, 0.0],
                                [-0.519, 1.292, 0.0], [-0.511, 1.308, 0.0],
                                [-0.5, 1.321, 0.0], [-0.488, 1.329, 0.0],
                                [-0.474, 1.335, 0.0], [-0.458, 1.337, 0.0],
                                [-0.449, 1.336, 0.0], [-0.44, 1.334, 0.0],
                                [-0.422, 1.328, 0.0], [-0.403, 1.317, 0.0],
                                [-0.384, 1.302, 0.0]],
                             d=1)
    i_top_char = mc.curve(p=[[-0.235, 1.418, 0.0], [-0.185, 1.418, 0.0],
                             [-0.185, 1.467, 0.0], [-0.235, 1.467, 0.0],
                             [-0.235, 1.418, 0.0]],
                          d=1)
    i_bottom_char = mc.curve(p=[[-0.235, 1.094, 0.0], [-0.185, 1.094, 0.0],
                                [-0.185, 1.368, 0.0], [-0.235, 1.368, 0.0],
                                [-0.235, 1.094, 0.0]],
                             d=1)
    v_char = mc.curve(p=[[-0.028, 1.094, 0.0], [0.022, 1.094, 0.0],
                         [0.13, 1.368, 0.0], [0.084, 1.368, 0.0],
                         [0.0, 1.155, 0.0], [-0.08, 1.368, 0.0],
                         [-0.13, 1.368, 0.0], [-0.028, 1.094, 0.0]],
                      d=1)
    line = mc.curve(p=[[0.0, 0.998, 0.0], [0.0, -0.0, 0.0]], d=1)

    curvelist.append(d_outline_char)
    curvelist.append(d_inline_char)
    curvelist.append(i_top_char)
    curvelist.append(i_bottom_char)
    curvelist.append(v_char)
    curvelist.append(line)

    sBbox = pm.exactWorldBoundingBox(currentSel)
    sBboxP = [(sBbox[0] + sBbox[3]) / 2, sBbox[4], (sBbox[2] + sBbox[5]) / 2]
    smoothParentGroup = pm.group(curvelist, n=currentSel + '_smooth')
    smoothParentGroup.scalePivot.set([0, 0, 0])
    smoothParentGroup.rotatePivot.set([0, 0, 0])
    pm.xform(smoothParentGroup, t=sBboxP)
    pm.pointConstraint(currentSel, smoothParentGroup, mo=True)
    return smoothParentGroup