Exemplo n.º 1
0
def gtu_delete_keyframes():
    '''Deletes all nodes of the type "animCurveTA" (keyframes)'''
    function_name = 'GTU Delete All Keyframes'
    cmds.undoInfo(openChunk=True, chunkName=function_name)
    try:
        keys_ta = cmds.ls(type='animCurveTA')
        keys_tl = cmds.ls(type='animCurveTL')
        keys_tt = cmds.ls(type='animCurveTT')
        keys_tu = cmds.ls(type='animCurveTU')
        #keys_ul = cmds.ls(type='animCurveUL') # Use optionVar to determine if driven keys should be deleted
        #keys_ua = cmds.ls(type='animCurveUA')
        #keys_ut = cmds.ls(type='animCurveUT')
        #keys_uu = cmds.ls(type='animCurveUU')
        deleted_counter = 0
        all_keyframes = keys_ta + keys_tl + keys_tt + keys_tu
        for obj in all_keyframes:
            try:
                cmds.delete(obj)
                deleted_counter += 1
            except:
                pass
        message = '<span style=\"color:#FF0000;text-decoration:underline;\">' + str(
            deleted_counter) + ' </span>'
        is_plural = 'keyframe nodes were'
        if deleted_counter == 1:
            is_plural = 'keyframe node was'
        message += is_plural + ' deleted.'

        cmds.inViewMessage(amg=message, pos='botLeft', fade=True, alpha=.9)
    except Exception as e:
        cmds.warning(str(e))
    finally:
        cmds.undoInfo(closeChunk=True, chunkName=function_name)
Exemplo n.º 2
0
        def import_geo(self):
            print "importing geo"
            mari_geo_path = self.sd['geo path']
            geo_list = cmds.ls(tr=True)
            for geo in geo_list:
                if self.geo_name == geo:
                    self.geo = geo

            if not self.geo:
                try:
                    # self.geo = cmds.file(mari_geo_path, i=True, f=True, options='mo=0')
                    self.geo = cmds.file(mari_geo_path,
                                         i=True,
                                         f=True,
                                         rnn=True,
                                         namespace="",
                                         options='mo=0')
                    # self.geo = cmds.rename(file_name + "_obj:polySurface1", geoName)
                    print "geo imported"
                    cmds.inViewMessage(amg='Object imported',
                                       pos='botCenter',
                                       fade=True,
                                       fadeOutTime=500)
                except:
                    self.geo = None
                    print "GEO IMPORT FAILED - (geo has likely been moved from the original mari import location)"
                    print "Mari Geo path: " + mari_geo_path
Exemplo n.º 3
0
def inViewMessage(header, message, type_=INFO, fadeStayTime=1000):
    """Smaller wrapper function for nicely formatting maya inview message, INFO,WARNING,ERROR message types supported.
    Each message type will have a set color.

    :param header: The main header title for the message , ideally one word
    :type header: str
    :param message: The message to display
    :type message: str
    :param type_: gui.INFO,gui.WARNING, gui.ERROR
    :type type_: int
    :param fadeStayTime: the fade time
    :type fadeStayTime: int
    """
    useInViewMsg = cmds.optionVar(q='inViewMessageEnable')
    if not useInViewMsg:
        return
    if type_ == "info":
        msg = " <span style=\"color:#82C99A;\">{}:</span> {}"
        position = 'topCenter'
    elif type_ == "Warning":
        msg = "<span style=\"color:#F4FA58;\">{}:</span> {}"
        position = 'midCenterTop'
    elif type_ == "Error":
        msg = "<span style=\"color:#F05A5A;\">{}:</span> {}"
        position = 'midCenter'
    else:
        return
    cmds.inViewMessage(assistMessage=msg.format(header, message), fadeStayTime=fadeStayTime, dragKill=True,
                       position=position, fade=True)
Exemplo n.º 4
0
def publishSetDressGPU(*args):
    scenePath = cmds.workspace(sn=True, q=True)
    scenePath = scenePath.replace(os.sep, '/')

    abcPublishPath = scenePath + '/abc'
    abcPublishFile = 'setDressGPU'

    # 1. Check if setdress group exists :
    if not cmds.objExists('setDress_grp'):
        cmds.warning('setDress_grp does not exist.')
        return

    # 2. Export
    sel = cmds.select('setDress_grp', r=True)

    # alembic publish
    cmds.gpuCache('setDress_grp', \
     startTime=1, \
     endTime=1, \
     optimize=True, \
     optimizationThreshold=100, \
     writeMaterials=False, \
     dataFormat='ogawa', \
     useBaseTessellation=True, \
     directory=abcPublishPath, \
     fileName=abcPublishFile)

    # 4. inview message
    print('// Result : ' + abcPublishPath + abcPublishFile)
    cmds.inViewMessage( \
     amg='Set Dress GPU publish successful', \
     pos='midCenter', \
     fade=True)
def UIButton_Smaller(iHeight, *args):
    oUI.Height = iHeight
    UIReBuild()


    aPrint = UIColourControl.inViewMessageColourPreset('Blue', 'SMALLER!!')
    cmds.inViewMessage(amg = '<text style="color:#%s";>%s</text>'%(aPrint[0], aPrint[1]), pos = 'botCenter', fade = True, fts = 7, ft = 'arial',bkc = aPrint[2] )
Exemplo n.º 6
0
def match_transform(mode='', child_comp=False):
    from . import sisidebar_sub
    pre_sel = cmds.ls(sl=True, l=True)
    selection = cmds.ls(sl=True, l=True, type='transform')
    if not selection:
        return
    cmds.undoInfo(openChunk=True)
    set_maching(nodes=selection, mode=mode ,pre_sel=pre_sel, child_comp=child_comp)
    
    msg = lang.Lang(en=u"<hl>Select Matching Object</hl>",
                            ja=u"<hl>一致対象オブジェクトを選択してください</hl>")
    cmds.inViewMessage( amg=msg.output(), pos='midCenterTop', fade=True )
    #cmds.select(cl=True)
    maching_tool = cmds.scriptCtx( title='Much Transform',
                        totalSelectionSets=3,
                        cumulativeLists=True,
                        expandSelectionList=True,
                        toolCursorType="edit",
                        setNoSelectionPrompt='Select the object you want to matching transform.'
                        )
    #カスタムカーソルを設定
    image_path = os.path.join(os.path.dirname(__file__), 'icon/')
    my_cursor = QCursor(QPixmap(image_path+'picker.png'))
    QApplication.setOverrideCursor(my_cursor)
    #cmds.hudButton('HUDHelloButton', e=True, s=7, b=5, vis=1, l='Button', bw=80, bsh='roundRectangle', rc=match_cancel )
    global hud_but
    if maya_ver != 2017:
        try:
            hud_but = cmds.hudButton('HUD_match_cancel', s=7, b=5, vis=1, l='Cancel', bw=80, bsh='roundRectangle', rc=finish_matching)
            #print 'create'
        except:
            #print 'change'
            hud_but = cmds.hudButton('HUD_match_cancel',e=True, s=7, b=5, vis=1, l='Cancel', bw=80, bsh='roundRectangle', rc=finish_matching)
    jobNum = cmds.scriptJob(ro=True, e=('SelectionChanged', qt.Callback(trs_matching)), protected=True)
    sisidebar_sub.get_matrix()
Exemplo n.º 7
0
    def editPivotHandle(self):

        qt_maya_window.installEventFilter(self.keypressFilter)

        #create transform
        self.pivotHandle = mc.group(em=True, name='Adjust_Pivot')
        mc.setAttr(self.pivotHandle+'.rotate', lock=True)
        mc.setAttr(self.pivotHandle+'.rx', keyable=False)
        mc.setAttr(self.pivotHandle+'.ry', keyable=False)
        mc.setAttr(self.pivotHandle+'.rz', keyable=False)
        mc.setAttr(self.pivotHandle+'.scale', lock=True)
        mc.setAttr(self.pivotHandle+'.sx', keyable=False)
        mc.setAttr(self.pivotHandle+'.sy', keyable=False)
        mc.setAttr(self.pivotHandle+'.sz', keyable=False)
        mc.setAttr(self.pivotHandle+'.visibility', lock=True, keyable=False)
        mc.setAttr(self.pivotHandle+'.displayHandle', True)

        self.pivotHandle = mc.parent(self.pivotHandle, self.node)[0]

        mc.addAttr(self.pivotHandle, ln='ml_pivot_handle', at='bool', keyable=False)

        #set initial position
        mc.setAttr(self.pivotHandle+'.translate', *mc.getAttr(self.node+'.rotatePivot')[0])

        #lock it so you don't delete it or something.
        mc.lockNode(self.pivotHandle, lock=True)

        self.scriptJob = mc.scriptJob(event=['SelectionChanged', self.cleanup], runOnce=True)

        mc.setToolTo('Move')

        mc.inViewMessage( amg='After moving the pivot, press <hl>Return</hl> to bake or <hl>Esc</hl> to cancel.', pos='midCenterTop', fade=True, fadeStayTime=4000, dragKill=True)
Exemplo n.º 8
0
def HotKey_AxisSwitcher():
	# AxisSwitcher v2.1.0

	oPanel = cmds.getPanel(wf = True)
	if 'modelPanel' in oPanel: # if a viewport is acitve (Not graphEditor1/etc)
		oCamera = cmds.modelPanel(oPanel, query=True, camera=True).replace('Shape', '')


		iVal = cmds.manipMoveContext('Move', q = True, mode = True)

	if iVal == 1:
		cmds.manipMoveContext('Move', e = True, mode = 2)
		cmds.manipRotateContext('Rotate', e = True, mode = 1)
		aPrint = ['6bad64', 'WORLD', 0x6c756b] # Green
	elif iVal == 2:
		cmds.manipMoveContext('Move', e = True, mode = 0)
		cmds.manipRotateContext('Rotate', e = True, mode = 0)
		aPrint = ['d8766c', 'OBJECT', 0x756b6b] # Red
	elif iVal == 0:
		# Camera space Manipultor
		aCoordinate = cmds.xform(oCamera, q = True, a = True, ws = True, t = True)

		cmds.manipMoveContext('Move', e = True, mode = 6, activeHandle = 0, orientTowards = aCoordinate)
		cmds.manipRotateContext('Rotate', e = True, mode = 3)
		aPrint = ['9bbcf2', 'CAMERA', 0x485872] # Blue
	else:
		cmds.manipMoveContext('Move', e = True, mode = 1)
		cmds.manipRotateContext('Rotate', e = True, mode = 2)
		aPrint = ['a7a8af', 'LOCAL ', 0x6b6c75] # Gray

	cmds.inViewMessage(amg = '<text style="color:#%s";>%s</text>'%(aPrint[0], aPrint[1]), pos = 'botCenter', fade = True, fts = 7, ft = 'arial',bkc = aPrint[2] )
Exemplo n.º 9
0
def ATT_INCREMENT(iAmount):
	# Attribute Increment v4.0.0
	oChannel = [str(c+'.'+cmds.attributeName(c+'.'+b, l=True)) for a in 'msho' for b in cmds.channelBox('mainChannelBox', **{'q':True, 's%sa'%a:True}) or [] for c in cmds.channelBox('mainChannelBox', q = True, **{'%sol'%a:True})]

	iNewValue = None

	if oChannel:
		for c in oChannel:
			iVal = cmds.getAttr(c) + iAmount

			if cmds.attributeQuery(c.split('.')[-1], node = c.split('.')[0], minExists = True):
				if cmds.attributeQuery(c.split('.')[-1], node = c.split('.')[0], min = True)[0] >= iVal :
					iNewValue = cmds.attributeQuery(c.split('.')[-1], node = c.split('.')[0], min = True)[0]

			if cmds.attributeQuery(c.split('.')[-1], node = c.split('.')[0], maxExists = True):
				if cmds.attributeQuery(c.split('.')[-1], node = c.split('.')[0], max = True)[0] <= iVal:
					iNewValue = cmds.attributeQuery(c.split('.')[-1], node = c.split('.')[0], max = True)[0]

			if not iNewValue == None:
				cmds.setAttr(c, iNewValue)
			else:
				cmds.setAttr(c, iVal)

	else:
		aPrint = ['d8766c', 'No Attr Selected', 0x756b6b, 'midCenterBot']
		cmds.inViewMessage(amg = '<text style="color:#%s";>%s</text>'%(aPrint[0], aPrint[1]), pos = aPrint[3], fade = True, fts = 10, ft = 'arial',bkc = aPrint[2] )

	DisplayFaceValues()
Exemplo n.º 10
0
def show_message(message):
    print(message)
    cmds.inViewMessage(assistMessage=message,
                        position='midCenter',
                        fade=True,
                        # fadeStayTime=3000,
                        )
Exemplo n.º 11
0
def bind_mesh():
    #メッセージ
    cmds.inViewMessage(
        amg='ウエイト調整後、<hl>「アニメーションをインポート」</hl>を押し、animデータを選択して下さい。',
        pos='midCenter',
        fade=True,
        fit=1,
        fst=4000,
        fts=20)

    cmds.select('Root_M', add=True, hi=True)

    #正規表現、_controllerのジョイントを省く
    deselectObj = cmds.ls(sl=True)

    count = 0
    matchTxtEnd = re.compile("(_)(.*?)(controller)(.*)")

    for n in deselectObj:
        matchTrueEnd = matchTxtEnd.search(deselectObj[count])

        if matchTrueEnd != None:
            cmds.select(deselectObj[count], deselect=True)

        count += 1

    cmds.select('Mesh', add=True, hi=True)
    cmds.select('Mesh', deselect=True)

    cmds.skinCluster(maximumInfluences=3, dropoffRate=4, tsb=True)
Exemplo n.º 12
0
    def export_cameras(self, assets_path, project):
        valid_cameras = None
        selected_cameras = cmds.ls(sl=True, dag=True, ca=True)

        for cam in selected_cameras:
            if cam != "perspShape" and cam != "topShape" and cam != "frontShape" and cam != "sideShape":
                valid_cameras = True

        if not valid_cameras:
            cmds.inViewMessage(
                amg="No valid cameras selected (default 'persp' camera not supported in FBX export)",
                pos='botCenter', fade=True, fadeOutTime=500)
            return

        start_frame = str(cmds.playbackOptions(query=True, minTime=True))
        end_frame = str(cmds.playbackOptions(query=True, maxTime=True))

        if not os.path.exists(assets_path + "/" + project):
            os.makedirs(assets_path + "/" + project)

        output_file = assets_path + "/" + project + "/" + project + "_cameras.fbx"

        print "Camera file name: " + output_file

        # save the cameras to assets folder
        maya.mel.eval('FBXExportFileVersion "FBX201200"')
        maya.mel.eval('FBXExportInAscii -v true')
        maya.mel.eval("FBXExportCameras -v true")
        cmds.file(output_file, force=True, options='v=0', type='FBX export', pr=True, es=True)

        return [output_file, start_frame, end_frame]
Exemplo n.º 13
0
def msg(msg="Heads Up!"):
    global PM_startTime
    global PM_timeAdder
    PM_offset = 0
    PM_time = cmds.timerX(startTime=PM_startTime)
    PM_startTime = cmds.timerX()
    if PM_time < 1.5:
        PM_offset = 10 + 20 * (PM_timeAdder)
        PM_timeAdder = PM_timeAdder + 1
    else:
        PM_offset = 10
        PM_timeAdder = 0
    if MAYA_version_float >= 2014:
        cmds.inViewMessage(amg="<span style=\"color:#ffffff\">" + msg +
                           "</span>",
                           fade=1,
                           fit=150,
                           fst=800,
                           fot=150,
                           fof=PM_offset,
                           bkc=0x2288ff,
                           pos="topCenter",
                           fontSize=10,
                           a=0,
                           ta=0.68)
    print(msg)
def disable_editing(node=None):
    """
    Disable editing an inverted blend shape.
    """
    if node is not None:
        nodes = [node]
    else:
        nodes = cmds.ls(sl=True, l=True)
        
    if not nodes:
        OpenMaya.MGlobal.displayError('Select an inverted blend shape')
        return

    cmds.undoInfo(openChunk=True)
    try:
        for node in nodes:
            # We can select a deformer or an inverted shape node.  We can't select the
            # final output shape, since we won't know which blend shape to enable.
            deformer = _find_deformer(node)
            if deformer is None:
                OpenMaya.MGlobal.displayError('Couldn\'t find a zInvertedBlendShape for: %s' % node)
                continue

            if _disable_editing_for_deformer(deformer):
                msg = 'Editing <hl>disabled</hl> for: %s' % node
                cmds.inViewMessage(smg=msg, pos='botCenter', fade=1)
    finally:
        cmds.undoInfo(closeChunk=True)
Exemplo n.º 15
0
def maya_export():
    selection = cmds.ls(sl=True)
    long_names = cmds.ls(sl=True, l=True)
    if selection:
        cmds.inViewMessage( amg='<hl>Go Maya</hl> : Export Selected Objects', pos='midCenterTop', fade=True, ta=0.75, a=0.5)
        temp = __name__.split('.')#nameは自分自身のモジュール名。splitでピリオドごとに3分割。
        folderPath = os.path.join(
            os.getenv('MAYA_APP_DIR'),#Mayaのディレクトリ環境変数を取得
            'Scripting_Files',
            temp[-1]
            )
        if not os.path.exists(folderPath):
            os.makedirs(os.path.dirname(folderPath+os.sep))  # 末尾\\が必要なので注意
        print(folderPath)
        files = os.listdir(folderPath)
        sel_dict = dict()
        if files is not None:
            for file in files:
                os.remove(folderPath + os.sep + file)
        for sel, long_name in zip(selection, long_names):
            cmds.select(sel, r=True)
            name = sel.replace('|', '__Pipe__')
            cmds.file(folderPath+os.sep+name+'.ma', force=True, options="v=0", typ="mayaAscii", pr=True, es=True)
            sel_dict[name+'.ma'] = long_name
        cmds.select(selection, r=True)
        #選択ノード名を保存
        fine_name = folderPath+os.sep +'go_maya_selection_node.json'
        with open(fine_name, 'w') as f:
            json.dump(sel_dict, f)
Exemplo n.º 16
0
    def applyFacify(self, upperVertsSetText, lowerVertsSetText,
                    parentJointText, namingPrefixText, smartCloseChkbox,
                    finalizeRigBtn, *args):

        upperVertsSet = cmds.textFieldGrp(upperVertsSetText, q=1, text=1)
        lowerVertsSet = cmds.textFieldGrp(lowerVertsSetText, q=1, text=1)
        parentJoint = cmds.textFieldGrp(parentJointText, q=1, text=1)
        namingPrefix = cmds.textFieldGrp(namingPrefixText, q=1, text=1)
        smartClose = cmds.checkBoxGrp(smartCloseChkbox, q=1, value1=1)

        if upperVertsSet == '' or lowerVertsSet == '' or parentJoint == '' or namingPrefix == '':
            cmds.confirmDialog(title='Error',
                               message="Please fill in all text fields.")
            return

        if upperVertsSet == lowerVertsSet:
            cmds.confirmDialog(title='Error',
                               message="Vertex sets are identical.")
            return

        self.faceRig = wy_facify.FaceRig(parentJoint, namingPrefix, smartClose)
        self.faceRig.facify(upperVertsSet, lowerVertsSet)

        cmds.inViewMessage(
            amg=
            'Adjust the <hl>low-density curves</hl> to match the high-density curves.',
            pos='topCenter',
            fade=True)

        cmds.button(finalizeRigBtn, edit=1, enable=1)

        self.faceRig.isolateSelectCurves()
Exemplo n.º 17
0
def check_open():
    current_project = cmds.workspace(q=True, rootDirectory=True)
    scene_path = cmds.file(q=True, sceneName=True)
    scene_name = cmds.file(q=True, shortName=True, sceneName=True)
    msg01 = lang.Lang(en="Workspace not found", ja="ワークスペースがみつかりません")
    dir_list = scene_path.split("/")
    for i in range(len(dir_list)):
        dir_list = dir_list[:-1]
        root_dir = "/".join(dir_list) + "/"
        try:
            all_files = os.listdir(root_dir)
        except:
            cmds.inViewMessage(
                amg=msg01.output(),
                pos="midCenterTop",
                fade=True,
                ta=0.75,
                a=0.5,
            )
            return
        for file in all_files:
            if file == "workspace.mel":
                set_work_space(root_dir)
                return
    cmds.inViewMessage(amg=msg01.output(),
                       pos="midCenterTop",
                       fade=True,
                       ta=0.75,
                       a=0.5)
Exemplo n.º 18
0
def disable_editing(node=None):
    """
    Disable editing an inverted blend shape.
    """
    if node is not None:
        nodes = [node]
    else:
        nodes = cmds.ls(sl=True, l=True)

    if not nodes:
        OpenMaya.MGlobal.displayError('Select an inverted blend shape')
        return

    cmds.undoInfo(openChunk=True)
    try:
        for node in nodes:
            # We can select a deformer or an inverted shape node.  We can't select the
            # final output shape, since we won't know which blend shape to enable.
            deformer = _find_deformer(node)
            if deformer is None:
                OpenMaya.MGlobal.displayError(
                    'Couldn\'t find a zInvertedBlendShape for: %s' % node)
                continue

            if _disable_editing_for_deformer(deformer):
                msg = 'Editing <hl>disabled</hl> for: %s' % node
                cmds.inViewMessage(smg=msg, pos='botCenter', fade=1)
    finally:
        cmds.undoInfo(closeChunk=True)
Exemplo n.º 19
0
    def _message(self, msg):
        """Display the given message as a status in-view message.

        :param msg: The message string to display.
        :type msg: str
        """
        cmds.inViewMessage(statusMessage=msg, position="topCenter")
Exemplo n.º 20
0
def bind_mesh():
    # メッセージ
    cmds.inViewMessage(
        amg="ウエイト調整後、<hl>「アニメーションをインポート」</hl>を押し、animデータを選択して下さい。", pos="midCenter", fade=True, fit=1, fst=4000, fts=20
    )

    cmds.select("Root_M", add=True, hi=True)

    # 正規表現、_controllerのジョイントを省く
    deselectObj = cmds.ls(sl=True)

    count = 0
    matchTxtEnd = re.compile("(_)(.*?)(controller)(.*)")

    for n in deselectObj:
        matchTrueEnd = matchTxtEnd.search(deselectObj[count])

        if matchTrueEnd != None:
            cmds.select(deselectObj[count], deselect=True)

        count += 1

    cmds.select("Mesh", add=True, hi=True)
    cmds.select("Mesh", deselect=True)

    cmds.skinCluster(maximumInfluences=3, dropoffRate=4, tsb=True)
Exemplo n.º 21
0
def ATT_INCREMENT(iAmount):
    # Attribute Increment v3.0.0
    oChannel = [
        str(c + '.' + cmds.attributeName(c + '.' + b, l=True)) for a in 'msho'
        for b in cmds.channelBox('mainChannelBox', **{
            'q': True,
            's%sa' % a: True
        }) or [] for c in cmds.channelBox(
            'mainChannelBox', q=True, **{'%sol' % a: True})
    ]

    if oChannel:
        for c in oChannel:
            iVal = cmds.getAttr(c)
            cmds.setAttr(c, iVal + iAmount)

        if iAmount >= 0.01:
            aPrint = ['a7a8af', '+' + str(iAmount), 0x6b6c75, 'botCenter']
        else:
            aPrint = ['d8766c', '+' + str(iAmount), 0x756b6b, 'botCenter']
    else:
        aPrint = ['d8766c', 'No Attr Selected', 0x756b6b, 'topCenter']

    cmds.inViewMessage(amg='<text style="color:#%s";>%s</text>' %
                       (aPrint[0], aPrint[1]),
                       pos=aPrint[3],
                       fade=True,
                       fts=10,
                       ft='arial',
                       bkc=aPrint[2])
Exemplo n.º 22
0
    def customOpenFile(self, path, v):
        # ダイアログ:No なら処理しない
        result = cmds.confirmDialog(t=u'確認',
                                    m=u'開きますか?',
                                    button=[u'Yes', u'No'],
                                    defaultButton=u'Yes',
                                    cancelButton=u'No',
                                    dismissString=u'No')
        if not result == 'Yes':
            return

        cmds.file(path, f=True, iv=True, o=True)

        # プロジェクト設定
        parent_dir = os.path.basename(os.path.dirname(path))
        if parent_dir == "scenes":
            project_dir = os.path.dirname(os.path.dirname(path))
            mel.eval('setProject "' + project_dir + '";')
            print u'プロジェクトをセットしました! --> %s\n' % project_dir,
            msg = u'プロジェクトをセットしました!\n%s\n' % project_dir
            cmds.inViewMessage(amg=msg, pos='botCenter', fade=True, fst=5000)
        else:
            cmds.inViewMessage(amg=u'プロジェクトフォルダが親フォルダに見つかりません!',
                               pos='botCenter',
                               fade=True,
                               fst=5000)
Exemplo n.º 23
0
def pastePos():
    global RELOFFSET

    if RELOFFSET == None:
        cmds.inViewMessage(message='No previous copy data')
    else:
        RELOFFSET.pasteLocation()
Exemplo n.º 24
0
    def initializeCallback(self):

        #get current model panel
        self.currentModelPanel = cmds.getPanel(wf = 1)
        if "modelPanel" not in self.currentModelPanel:
            self.currentModelPanel = cmds.getPanel(vis = 1)
            for i in self.currentModelPanel:
                if "modelPanel" in i:
                    self.currentModelPanel = i


        #try removing old callbacks from memory
        try:
            OpenMayaUI.MUiMessage.removeCallback(self.callBack)
        except:
            pass

        #create a callback that is registered after a frame is drawn with a 3D content but before 2D content
        self.callback = OpenMayaUI.MUiMessage.add3dViewPostRenderMsgCallback(self.currentModelPanel, self.update)
        self.view3D.refresh(True, True)

        #create QT maya window event filter
        main_window_ptr = OpenMayaUI.MQtUtil.mainWindow()
        self.qt_Maya_Window = wrapInstance(long(main_window_ptr), QtCore.QObject)
        self.qt_Maya_Window.installEventFilter(self.userKeyboardEvents) 

        #create viewport event filter
        active_view_ptr = self.view3D.widget()
        self.qt_Active_View = wrapInstance(long(active_view_ptr), QtCore.QObject)
        self.qt_Active_View.installEventFilter(self.userMouseEvents)

        cmds.inViewMessage( amg='<hl>Tool:</hl> Use <hl>"Esc"</hl> to cancel the tool', pos='botLeft', fade=True )

        print "Initialized..."
Exemplo n.º 25
0
def set_knee_IK():
    # メッセージ
    cmds.inViewMessage(amg="<hl>「指のコントローラー設置」</hl>を押してください。", pos="midCenter", fade=True, fit=1, fst=4000, fts=20)
    # 座標取得
    positionR = cmds.xform("Knee_R", q=True, ws=True, t=True)
    locatorNameR = "Knee_R_Locator"
    # ロケーター設置
    cmds.spaceLocator(p=(positionR[0], positionR[1], positionR[2] + 3.8), n=locatorNameR)
    knee_ik_add("Hip_R", "Ankle_R", "Knee_R_Effector", positionR, locatorNameR)

    # 座標取得
    positionL = cmds.xform("Knee_L", q=True, ws=True, t=True)
    locatorNameL = "Knee_L_Locator"
    # ロケーター設置
    cmds.spaceLocator(p=(positionL[0], positionL[1], positionL[2] + 3.8), n=locatorNameL)
    knee_ik_add("Hip_L", "Ankle_L", "Knee_L_Effector", positionL, locatorNameL)

    # つま先のIK実行
    toe_ik_add("Ankle_R", "MiddleToe2_R", "Ankle_R_Effector")
    toe_ik_add("Ankle_L", "MiddleToe2_L", "Ankle_L_Effector")

    # 足のコントローラー、 座標取得
    toePositionR = cmds.xform("MiddleToe1_R", q=True, ws=True, t=True)
    toePositionL = cmds.xform("MiddleToe1_L", q=True, ws=True, t=True)
    foot_controller("foot_R_controller", toePositionR[0])
    foot_controller("foot_L_controller", toePositionL[0])

    # コントローラー内にエフェクター移動
    cmds.parent("Ankle_L_Effector", "foot_L_controller")
    cmds.parent("Knee_L_Effector", "foot_L_controller")
    cmds.parent("Ankle_R_Effector", "foot_R_controller")
    cmds.parent("Knee_R_Effector", "foot_R_controller")

    # 親子関係移動
    cmds.parent("Knee_R_Locator", "Knee_L_Locator", "foot_R_controller", "foot_L_controller", "main_controller")
Exemplo n.º 26
0
def MirrorBojs():

    slc = cmds.ls(sl=True)

    if (len(slc) == 0):
        cmds.inViewMessage(amg='Please select something to <hl>Mirror</hl>.',
                           pos='botCenter',
                           fade=True)

    else:

        newObj = cmds.duplicate(slc, n=('Mirrored_' + str(slc[0])))
        newobjgrp = cmds.group(newObj, n=(str(slc[0]) + '_MirrorGrp'))
        mel.eval("xform -os -piv 0 0 0;")
        cmds.scale(-1, 1, 1)
        cmds.ungroup(newobjgrp)
        cmds.makeIdentity(newObj, apply=True, t=1, r=1, s=1)
        cmds.select(newObj)
        a = cmds.promptDialog(title='Mirror',
                              message='If LT suffix exists type 1',
                              button=['Rename', "Don't Rename"],
                              defaultButton='Rename',
                              cancelButton="Don't Rename",
                              dismissString='Not Renaming')
        if a == 'Rename':

            text = cmds.promptDialog(query=True, text=True)
            g = int(text)

            try:
                mel.eval('searchReplaceNames"_LT" "_RT" "selected"')
            except:
                pass
            try:
                mel.eval('searchReplaceNames"_lt" "_rt" "selected"')

            except:
                pass

            try:
                mel.eval('searchReplaceNames"_L" "_R" "selected"')

            except:
                pass
            try:
                mel.eval('searchReplaceNames"_Left" "_Right" "selected"')

            except:
                pass

            if g == 1:
                mel.eval('searchReplaceNames"Mirrored_" "" "selected"')
                print 'removed mirrored names'

            else:
                pass

        else:
            pass
Exemplo n.º 27
0
def loadRenderSettings(context,*args): # Argument must be json file name
	import maya.app.renderSetup.views.renderSetupPreferences as prefs
	try :
		prefs.loadGlobalPreset(context)
		cmds.inViewMessage(amg='Render settings preset <hl>'+context+'</hl> successfuly loaded.',pos='midCenter',fade=True)
	except EnvironmentError:
		commonTools.areeeeett()
		cmds.warning('File '+context+'.json does not exist')
Exemplo n.º 28
0
def RfMsubdivScheme(onOff,*args): # Argument must be boolean
	sel = cmds.ls(selection=True)
	for i in sel:
		cmds.setAttr(i+'.rman_subdivScheme',onOff)
	if onOff == 0:
		cmds.inViewMessage( amg='Detached subdiv scheme from %s objects' % (len(sel)),pos='midCenter',fade=True )
	else:
		cmds.inViewMessage( amg='Attached subdiv scheme to %s objects' % (len(sel)),pos='midCenter',fade=True )
Exemplo n.º 29
0
def PrintOnScreen(aPrint):
    cmds.inViewMessage(amg='<text style="color:#%s";>%s</text>' %
                       (aPrint[0], aPrint[1]),
                       pos='topCenter',
                       fade=True,
                       fts=10,
                       ft='arial',
                       bkc=aPrint[2])
Exemplo n.º 30
0
    def importAnimation(self):
        shotPath = getShotData.getShotFolder(self.gui.shotListView)
        shotNumber = self.gui.shotListView.currentItem().text()
        assetName = mc.ls(sl=True)[0].split(":")[0]

        importAnim.importAnim(shotPath, assetName)

        mc.inViewMessage( amg='Animation was imported from <hl>%s</hl>.' %shotNumber, pos='midCenter', fade=True )
Exemplo n.º 31
0
def set_work_space(root_dir):
    cmds.workspace(root_dir, o=True)
    current_project = cmds.workspace(q=True, rootDirectory=True)
    print 'Set Current Work Space :', current_project
    msg00 = lang.Lang(
                en='Set Current Work Space :<hl>'+current_project+'<hl>',
                ja=u'現在のプロジェクトを<hl>' +current_project+u'</hl>に設定しました')
    cmds.inViewMessage( amg=msg00.output(), pos='midCenterTop', fade=True, ta=0.75, a=0.5)
Exemplo n.º 32
0
def wrong_spelling(*args):
    cmds.inViewMessage(amg='You spelled the SUFFIX wrong!',
                       pos='midCenter',
                       fade=True,
                       fts=35,
                       fst=3000,
                       bkc=0x00990000,
                       a=1,
                       ta=1)
Exemplo n.º 33
0
	def buildRig (self, *args):
		'''Build eyelids rig.
		
		Called by 'UI' function.
		Call functions: 'vtxToJnt', 'placeRigLoc', 'createEyelidsCrv', 'connectLocToCrv', 
						'createDriverCrv', 'createJntCtrls', 'createCrvCtrls', 'addSmartBlink' '''
		
		if self.eyeLoc == None or self.eyeName == None or self.upperLidVtx == None or self.lowerLidVtx == None :
			cmds.error ("Please define eye center and eyelids vertices.")
		else : # Call functions to build rig #
			# Step 1: places one joint per eyelid vertex
			self.vtxToJnt (self.eyeLoc, self.eyeName, self.upperLidVtx, self.lowerLidVtx, self.parentJnt)
			# Step 2: places one locator per eyelid vertex and constrain-aim each joint to it (so as it acts like an IK)
			self.placeRigLoc (self.eyeName, self.upLidJntList, self.lowLidJntList)
			# Step 3: creates a "high-res" curve for each lid (each vertex is a point of the curve)
			self.createEyelidsCrv (self.eyeName, self.upperLidVtx, self.lowerLidVtx, self.grpTheseEyelidsRig)
			# Step 4: connects each locator to the curve with a pointOnCurve node, so when the CVs of the curve move, the corresponding locator follows (and so does the joint)
			self.connectLocToCrv (self.upLidLocList, self.upLidCrv, self.lowLidLocList, self.lowLidCrv)
			# Step 5: creates a "low-res" curve with only 5 control points and makes it drive the high-res curve with a wire deformer
			self.createDriverCrv (self.upLidCrv, self.hierarchyUpCrvGrp, self.lowLidCrv, self.hierarchyLowCrvGrp)
			# Step 6: creates controller joints to drive the 'driver curve'
			self.createJntCtrls (self.eyeName, self.cornerAPos, self.cornerBPos, self.upLidDriverCrv, self.lowLidDriverCrv, self.grpTheseEyelidsRig)
			# Step 7: creates curve controllers, and attached the corresponding joints to them
			self.createCrvCtrls (self.eyeName, self.parentCtrl, self.ctrlJnts)
			# Step 8: if smart blink check box is checked, add smart blink feature
			if cmds.checkBox (self.isSmartBlink, q = 1, v = 1) == 1 :
				self.addSmartBlink (self.eyeName, self.upLidCrv, self.upLidDriverCrv, self.lowLidCrv, self.lowLidDriverCrv, self.ctrlList, self.hierarchyCrvGrp, self.hierarchyUpCrvGrp, self.hierarchyLowCrvGrp)
			
			# Clear scene & script variables #
			cmds.delete (self.eyeLoc)
			cmds.select (cl = 1)
			
			self.parentJnt = None
			self.parentCtrl = None
			self.eyeLoc = None
			self.eyeName = None
			self.upperLidVtx = None
			self.lowerLidVtx = None
			
			# Update UI #
			cmds.textField (self.txtfEye, e = 1, tx = "")
			cmds.textField (self.txtfJnt, e = 1, tx ="")
			cmds.textField (self.txtfCtrl, e = 1, tx ="")
			cmds.textField (self.txtfLoc, e = 1, tx = "")
			cmds.button (self.btnPlaceCenter, e = 1, en = 1)
			cmds.button (self.btnUndoPlaceCenter, e = 1, en = 0)
			cmds.scrollField (self.scrollfUpLid, e = 1, cl = 1)
			cmds.scrollField (self.scrollfLowLid, e = 1, cl = 1)
			cmds.checkBox (self.isSmartBlink, e = 1, v = 1)
			
			# End message
			if cmds.about (q = 1, version = 1) >= 2014 : # If Maya version is 2014 or more
				cmds.inViewMessage(amg = "<hl>Eyelids have been successfully rigged.</hl> —UKDP", pos = "midCenterTop", fade = True)
				print "Eyelids have been successfully rigged."
			else:
				print "Eyelids have been successfully rigged.\n",
Exemplo n.º 34
0
 def _showMessage(self):
     index = self._messageCount if self._messageCount < len(
         self._messages) else -1
     message = "Pick {} Position (Right Click to End)".format(
         self._messages[index])
     cmds.inViewMessage(statusMessage=message,
                        position="topRight",
                        backColor=0x00000000,
                        fade=True)
     self._messageCount += 1
Exemplo n.º 35
0
def create_platonic_sphere_b():
    mel.eval(
        'polyPlatonic -primitive 2 -subdivisionMode 0 -subdivisions 2 -radius 1 -sphericalInflation 1;'
    )
    message = 'Create > Polygon Primitives > <span style=\"color:#FF0000;text-decoration:underline;\">Platonic Solid</span>'
    cmds.inViewMessage(amg=message, pos='botLeft', fade=True, alpha=.9)
    cmds.inViewMessage(amg='(Settings: Octaheadron, Quads, 2, 1, 1)',
                       pos='botLeft',
                       fade=True,
                       alpha=.9)
Exemplo n.º 36
0
    def wrapper_function(*args, **kwars):
        # runs decorated function
        function_exec = function(*args, **kwars)

        cmds.inViewMessage(message="Flex Finished running...", fade=True,
                           position="midCenter", fontSize=30, fadeStayTime=500,
                           fadeOutTime=100, dragKill=True, bkc=0x00154060,
                           alpha=0.7)

        return function_exec
Exemplo n.º 37
0
def NOT():
    print 'Hotkey Not Assigned.'
    aPrint = ['d8766c', 'HotKey Not Assigned', 0x756b6b, 'topCenter']
    cmds.inViewMessage(amg='<text style="color:#%s";>%s</text>' %
                       (aPrint[0], aPrint[1]),
                       pos=aPrint[3],
                       fade=True,
                       fts=7,
                       ft='arial',
                       bkc=aPrint[2])
Exemplo n.º 38
0
def joint_UI():
    # メッセージ
    cmds.inViewMessage(amg="<hl>「ジョイント設置」</hl>を押してください。", pos="midCenter", fade=True, fit=1, fst=4000, fts=20)

    windowName = cmds.window(title="LightSkeleton")

    form = cmds.formLayout()
    cmds.columnLayout()
    cmds.setParent("..")
    addJointButton = cmds.button(label="ジョイント設置", command="joint_add()")
    copyJointButton = cmds.button(label="左側にジョイントコピー", command="joint_left_add()")
    footIKButton = cmds.button(label="足のIK設置", command="set_knee_IK()")
    fingerButton = cmds.button(label="指のコントローラー設置", command="set_finger_controller()")
    closeButton = cmds.button(label="バインド", command=("bind_mesh()"))
    animImportButton = cmds.button(label="アニメーションをインポート", command=("import_anim()"))
    bakeButton = cmds.button(label="モーションをベイク", command=("motion_bake()"))

    cmds.formLayout(
        form,
        edit=True,
        attachForm=[
            (addJointButton, "top", 10),
            (addJointButton, "left", 10),
            (addJointButton, "bottom", 190),
            (addJointButton, "right", 10),
            (copyJointButton, "top", 40),
            (copyJointButton, "left", 10),
            (copyJointButton, "bottom", 160),
            (copyJointButton, "right", 10),
            (footIKButton, "top", 70),
            (footIKButton, "left", 10),
            (footIKButton, "bottom", 130),
            (footIKButton, "right", 10),
            (fingerButton, "top", 100),
            (fingerButton, "left", 10),
            (fingerButton, "bottom", 100),
            (fingerButton, "right", 10),
            (closeButton, "top", 130),
            (closeButton, "left", 10),
            (closeButton, "bottom", 70),
            (closeButton, "right", 10),
            (animImportButton, "top", 160),
            (animImportButton, "left", 10),
            (animImportButton, "bottom", 40),
            (animImportButton, "right", 10),
            (bakeButton, "top", 190),
            (bakeButton, "left", 10),
            (bakeButton, "bottom", 10),
            (bakeButton, "right", 10),
        ],
    )

    # cmds.formLayout( form, edit=True, attachForm=[(b1, 'top', 5), (b1, 'left', 5), (b2, 'left', 5), (b2, 'bottom', 5), (b2, 'right', 5), (column, 'top', 5), (column, 'right', 5) ], attachControl=[(b1, 'bottom', 5, b2), (column, 'bottom', 5, b2)], attachPosition=[(b1, 'right', 5, 75), (column, 'left', 0, 75)], attachNone=(b2, 'top') )

    cmds.showWindow()
Exemplo n.º 39
0
        def export_geo_main(self):
            if self.export_hierarchy or self.is_animated:
                file_extension = '.abc'
                selected_geo = []
                geo_list = cmds.ls(selection=True, typ='mesh', dag=True)
                for geo in geo_list:
                    root = cmds.ls(geo, l=True)[0].split("|")[1]
                    selected_geo.append(root)
            else:
                file_extension = '.obj'
                selected_geo = cmds.ls(selection=True, typ='mesh', o=True, dag=True, l=True)

            if not selected_geo:
                cmds.inViewMessage(amg='Please select geometry for export', pos='botCenter', fade=True,
                                   fadeOutTime=500)
                return

            if self.is_animated:
                start_anim = cmds.playbackOptions(query=True, minTime=True)
                end_anim = cmds.playbackOptions(query=True, maxTime=True)
            else:
                start_anim = 1
                end_anim = 1

            if not os.path.exists(self.assets_path + "/" + self.project):
                os.makedirs(self.assets_path + "/" + self.project)

            if file_extension == '.abc':
                for geo in selected_geo:
                    version = 01
                    output_path = self.assets_path + "/" + self.project + "/" + geo + "_v1" + file_extension
                    if self.send_mode == 'version':
                        while os.path.exists(output_path):
                            version += 1
                            output_path = self.assets_path + "/" + self.project + "/" + geo + "_v" + str(version) + file_extension

                    self.output_paths.append(output_path)
                    maya.mel.eval('AbcExport -j "-frameRange %s %s -uvWrite -root %s -file %s"' % (start_anim, end_anim, geo, output_path))

            else:
                for geo in selected_geo:
                    version = 01
                    cmds.select(geo)
                    geo_name = cmds.listRelatives(geo, parent=True, f=True)[0].replace('|', '_').split('_', 1)[1]
                    output_path = self.assets_path + "/" + self.project + "/" + geo_name + "_v1" + file_extension
                    if self.send_mode == 'version':
                        while os.path.exists(output_path):
                            version += 1
                            output_path = self.assets_path + "/" + self.project + "/" + geo_name + "_v" + str(version) + file_extension

                    self.output_paths.append(output_path)
                    maya.mel.eval('file -force -options "groups=0;ptgroups=0;materials=0;smoothing=0;normals=0" -type "OBJexport" -pr -es "%s";' % (output_path))
Exemplo n.º 40
0
 def editPivot(self, *args):
     sel = mc.ls(sl=True)
     
     if not sel:
         om.MGlobal.displayWarning('Nothing selected.')
         return
     
     if len(sel) > 1:
         om.MGlobal.displayWarning('Only works on one node at a time.')
         return
     
     if mc.attributeQuery('ml_pivot_handle', exists=True, node=sel[0]):
         #we have a pivot handle selected
         return
     
     if is_pivot_connected(sel[0]):
         return
     
     self.node = sel[0]
     
     qt_maya_window.installEventFilter(self.keypressFilter)        
     
     
     #create transform
     self.pivotHandle = mc.group(em=True, name='Adjust_Pivot')
     mc.setAttr(self.pivotHandle+'.rotate', lock=True)
     mc.setAttr(self.pivotHandle+'.rx', keyable=False)
     mc.setAttr(self.pivotHandle+'.ry', keyable=False)
     mc.setAttr(self.pivotHandle+'.rz', keyable=False)
     mc.setAttr(self.pivotHandle+'.scale', lock=True)
     mc.setAttr(self.pivotHandle+'.sx', keyable=False)
     mc.setAttr(self.pivotHandle+'.sy', keyable=False)
     mc.setAttr(self.pivotHandle+'.sz', keyable=False)
     mc.setAttr(self.pivotHandle+'.visibility', lock=True, keyable=False)
     mc.setAttr(self.pivotHandle+'.displayHandle', True)
     
     self.pivotHandle = mc.parent(self.pivotHandle, self.node)[0]
     
     mc.addAttr(self.pivotHandle, ln='ml_pivot_handle', at='bool', keyable=False)
     
     #set initial position
     mc.setAttr(self.pivotHandle+'.translate', *mc.getAttr(self.node+'.rotatePivot')[0])
     
     #lock it so you don't delete it or something.
     mc.lockNode(self.pivotHandle, lock=True)
     
     self.scriptJob = mc.scriptJob(event=['SelectionChanged', self.cleanup], runOnce=True)
     
     mc.setToolTo('Move')
     
     mc.inViewMessage( amg='After moving the pivot, press <hl>Return</hl> to bake or <hl>Esc</hl> to cancel.', pos='midCenterTop', fade=True, fadeStayTime=4000, dragKill=True)
Exemplo n.º 41
0
 def initSetup(self):
     ''' 
     Initialize all data relative to IShatter Context.
     '''
     iMinTime = cmds.playbackOptions(query = True, minTime = True)
     cmds.currentTime(iMinTime, edit = True)
     
     self.setFractureFX()
     self.getHardEdges()
     self.setObjectToDisplay()        
     self.createImpactHelper()        
     self._mView.getCamera(self._mCamera)
     
     if self._mInViewMessage:
         cmds.inViewMessage(amg = 'Estimated Fragments : <hl>' + str(self._mVoroPoints.length()) + '</hl>', dragKill = True, pos = 'topCenter')
     else:                     
         cmds.headsUpMessage('Estimated Fragments : ' + str(self._mVoroPoints.length()), verticalOffset = (cmds.control('modelPanel4', q = True, h = True) / 2.5))    
Exemplo n.º 42
0
def setMode(context="moveSuperContext", mode=0, value=None):
    """set mode. 0 - no snap, 1 - relative, 2 - absolute."""

    context, name = contexts[context]
    if mode == 0:
        context(name, e=True, s=False)
    elif mode == 1:
        context(name, e=True, s=True, sr=True)
    else:
        context(name, e=True, s=True, sr=False)

    if value is not None:
        context(name, e=True, sv=value)

    if not context(name, q=True, s=True):
        cmds.inViewMessage(smg="%s OFF" % name, pos="topCenter", f=True)
    else:
        cmds.inViewMessage(smg="%s %s %.1f" % (name, modes[mode], context(name, q=True, sv=True)),
                           pos="topCenter", f=True)
Exemplo n.º 43
0
        def import_geo(self):
            print "importing geo"
            mari_geo_path = self.sd['geo path']
            geo_list = cmds.ls(tr=True)
            for geo in geo_list:
                if self.geo_name == geo:
                    self.geo = geo

            if not self.geo:
                try:
                    # self.geo = cmds.file(mari_geo_path, i=True, f=True, options='mo=0')
                    self.geo = cmds.file(mari_geo_path, i=True, f=True, rnn=True, namespace="", options='mo=0')
                    # self.geo = cmds.rename(file_name + "_obj:polySurface1", geoName)
                    print "geo imported"
                    cmds.inViewMessage(amg='Object imported', pos='botCenter', fade=True, fadeOutTime=500)
                except:
                    self.geo = None
                    print "GEO IMPORT FAILED - (geo has likely been moved from the original mari import location)"
                    print "Mari Geo path: " + mari_geo_path
Exemplo n.º 44
0
def set_finger_controller():
    # メッセージ
    cmds.inViewMessage(
        amg="「Mesh」グループを作成してメッシュをその中に入れてください。続いて<hl>「バインド」</hl>を押してください。",
        pos="midCenter",
        fade=True,
        fit=1,
        fst=4000,
        fts=20,
    )

    # 4本指のコントローラー、 座標取得
    fingerPositionR = cmds.xform("Finger2_R", q=True, ws=True, t=True)
    fingerPositionL = cmds.xform("Finger2_L", q=True, ws=True, t=True)
    controllerSize = 2
    finger_controller("finger_R_controller", fingerPositionR, controllerSize)
    finger_controller("finger_L_controller", fingerPositionL, controllerSize)

    # 4本指のコントローラー移動
    cmds.parent("finger_R_controller", "Wrist_R")
    cmds.parent("finger_L_controller", "Wrist_L")

    # 4本指のセットドリブン R
    for n in range(0, 3):
        finger_first_driven_add("Finger" + str(n + 1) + "_R", "finger_R_controller", "Z")

    cmds.setAttr("finger_R_controller.finger_action", 10)

    for n in range(0, 3):
        finger_second_driven_add("Finger" + str(n + 1) + "_R", "finger_R_controller", "Z", 70)

    # 4本指L
    for n in range(0, 3):
        finger_first_driven_add("Finger" + str(n + 1) + "_L", "finger_L_controller", "Z")

    cmds.setAttr("finger_L_controller.finger_action", 10)

    for n in range(0, 3):
        finger_second_driven_add("Finger" + str(n + 1) + "_L", "finger_L_controller", "Z", 70)

    """
Exemplo n.º 45
0
    def export_shaders_to_presets_dir(self, presets_path):
        shaders = cmds.selectedNodes()
        if not shaders:
            cmds.inViewMessage(amg='Please select Shaders for Export', pos='midCenter', fade=True, fadeOutTime=500)
            return

        for shader in shaders:
            shader_type = cmds.nodeType(shader)
            if shader_type not in self.accepted_shaders:
                cmds.inViewMessage(amg='Please select from the following shader types: %s ' % self.accepted_shaders,
                                   pos='midCenter', fade=True, fadeOutTime=500)
                return

        directory = str(QtGui.QFileDialog.getExistingDirectory(dir=presets_path,
                                                               caption="Choose Shader Preset Directory"))
        if directory:
            directory = directory.replace('\\', '/')

            for shader in shaders:
                data = self.get_shader_data(shader)
                output_path = directory + "/" + data['shader name'] + ".pre"

                with open(output_path, 'w') as outfile:
                    json.dump(data, outfile, sort_keys=True, indent=4, separators=(',', ': '))

        cmds.inViewMessage(amg='Export finished', pos='midCenter', fade=True, fadeOutTime=500)
Exemplo n.º 46
0
    def mousePressEvent(self, e):

        modifiers = QApplication.keyboardModifiers()

        if "?" in self.gui.searchLineEdit.text():
            self.gui.close()
            if modifiers == Qt.ControlModifier:
                if os.path.isfile('{0}/commands/{1}-advanced.py'.format(self.gui.cur_path, self.frame_name)):
                    subprocess.call(['notepad.exe', '{0}/commands/{1}-advanced.py'.format(self.gui.cur_path, self.frame_name)])
                else:
                    mc.inViewMessage(message="Script {0}-advanced.py doesn't exist".format(self.frame_name), pos='topCenter', fade=True, fadeStayTime=1500, fadeInTime=250, fadeOutTime=250)
        
            else:
                if os.path.isfile('{0}/commands/{1}.py'.format(self.gui.cur_path, self.frame_name)):
                    subprocess.call(['notepad.exe', '{0}/commands/{1}.py'.format(self.gui.cur_path, self.frame_name)])
                else:
                    mc.inViewMessage(message="Script {0}.py doesn't exist".format(self.frame_name), pos='topCenter', fade=True, fadeStayTime=1500, fadeInTime=250, fadeOutTime=250)
        

        else:

            if modifiers == Qt.ControlModifier:
                try:
                    exec(compile(open('{0}/commands/{1}-advanced.py'.format(self.gui.cur_path, self.frame_name)).read(), '{0}/commands/{1}-advanced.py'.format(self.gui.cur_path, self.frame_name), 'exec'))
                except Exception, e:
                    try:
                        errorLog = open(self.gui.cur_path + "/commands/errorLog.txt", "w")
                        errorLog.write(str(e))
                    except:
                        pass
                    print(str(e))
                    mc.inViewMessage(message="Errors occured while executing '{0}'".format(self.frame_name), pos='topCenter', fade=True, fadeStayTime=750, fadeInTime=250, fadeOutTime=250)
            else:
Exemplo n.º 47
0
    def finalizeCtx(self):
        '''
        called when we exit the context
        '''
        if cmds.objExists(self._mVoroImpactTrs):
            cmds.delete(self._mVoroImpactTrs) ; self._mVoroImpactTrs = None
        
        if cmds.objExists(self._mVoroDisplay[0]):
            cmds.delete(self._mVoroDisplay) ; self._mVoroDisplay = None
        
        if cmds.objExists(self._mVoroObject):
            cmds.setAttr(self._mVoroObject + '.visibility', True)
            mBreakNode = cmds.listConnections(self._mVoroObject, sh = True, type = 'fxBreakGeometry')
            if len(mBreakNode) > 0:
                if self._mVoroPoints.length() > 0:
                    cmds.setAttr(mBreakNode[0] + '.numPoints', self._mVoroPoints.length())       
        
        if len(self._mObjectsToHide):
            cmds.showHidden(self._mObjectsToHide)
        
        self._mVoroPoints.clear() ; self._mVoroPoints = None
        self._mObjectsToHide = None            
            
        cmds.select(clear = True)
        mel.eval('hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes")')
        cmds.scriptEditorInfo (clearHistory = True)
            
        if self._mInViewMessage:
            cmds.inViewMessage(amg = '<hl> IShatter Completed </hl>', dragKill = True, fade = True, pos = 'topCenter')
        else:                     
            cmds.headsUpMessage('IShatter Completed', verticalOffset = (cmds.control('modelPanel4', q = True, h = True) / 2.5))        
        
        cmds.scriptJob(event = ("idle", self.deleteIShatterCtx), runOnce = True)                        

#****************************************************************************************************************************************************************************************#
#****************************************************************************************************************************************************************************************#
# 													    	                     CLASS END DEFINITION                                                                                    #
#****************************************************************************************************************************************************************************************#
#****************************************************************************************************************************************************************************************#
Exemplo n.º 48
0
def joint_add():
    # メッセージ
    cmds.inViewMessage(
        amg="ジョイント位置を調整後、<hl>「左側にジョイントコピー」</hl>を押してください。", pos="midCenter", fade=True, fit=1, fst=4000, fts=20
    )

    # メインと腰コントローラー設置
    cmds.circle(c=(0, 0, 0), nr=(0, 1, 0), r=6, n="main_controller")

    # ジョイント生成
    cmds.joint("main_controller", n="Root_M", p=(0, 11, 0))
    cmds.joint("Root_M", n="BackA_M", r=True, p=(0, 2, 0))
    cmds.joint("BackA_M", n="Chest_M", r=True, p=(0, 2, 0))

    cmds.joint("Chest_M", n="Scapula_R", r=True, p=(-1.0, 1.7, -1.0), ay=-2.0, az=3.0)
    cmds.joint("Scapula_R", n="Shoulder_R", r=True, p=(-2.0, 0, 0), ay=2.0, az=2.0)
    cmds.joint("Shoulder_R", n="Elbow_R", r=True, p=(-3.0, 0, 0), ay=1.0)
    cmds.joint("Elbow_R", n="Wrist_R", r=True, p=(-3.5, 0, 0), az=-1.0)
    cmds.joint("Wrist_R", n="Finger1_R", r=True, p=(-2.0, 0, 0), az=1.5)
    cmds.joint("Finger1_R", n="Finger2_R", r=True, p=(-1.0, 0, 0), az=2.0)
    cmds.joint("Finger2_R", n="Finger3_R", r=True, p=(-1.0, 0, 0), az=2.0)
    cmds.joint("Finger3_R", n="Finger4_R", r=True, p=(-1.0, 0, 0))
    """
    cmds.joint('Wrist_R', n='ThumbFinger1_R', r=True, p=(-.8, -.8, .8), ay=2.0, az=4.5 )
    cmds.joint('ThumbFinger1_R', n='ThumbFinger2_R', r=True, p=(-.8, 0, 0), ay=-1.0 )
    cmds.joint('ThumbFinger2_R', n='ThumbFinger3_R', r=True, p=(-.8, 0, 0) )
    cmds.joint('ThumbFinger3_R', n='ThumbFinger4_R', r=True, p=(-.8, 0, 0) )
    """

    cmds.joint("Root_M", n="Hip_R", r=True, p=(-1.5, -1.0, 0))
    cmds.joint("Hip_R", n="Knee_R", r=True, p=(0, -4.0, 0.5))
    cmds.joint("Knee_R", n="Ankle_R", r=True, p=(0, -4.0, -1.7))
    cmds.joint("Ankle_R", n="MiddleToe1_R", r=True, p=(0, -1.0, 0.8))
    cmds.joint("MiddleToe1_R", n="MiddleToe2_R", r=True, p=(0, -0.7, 3.0))

    cmds.joint("Chest_M", n="Neck_M", r=True, p=(0, 2.0, -0.5), ax=2.0)
    cmds.joint("Neck_M", n="Head_M", r=True, p=(0, 1.5, 0), ax=-2.0)
    cmds.joint("Head_M", n="Chin_M", r=True, p=(0, -1.0, 1.0))
Exemplo n.º 49
0
def saveAnimation(shotListView, cameraAnim=False):
    try:
        animRootFolder = getShotData.getShotFolder(shotListView) + "_anim"
    except:
        mc.warning("Select a shot!")
        return

    # get selected asset name
    if not cameraAnim:
        try:
            assetName = mc.ls(sl=True)[0].split(":")[0]
        except:
            mc.warning("Which character you want to save anim for?? hint: Select a controller...")
            return

        # create animation folders for the asset if not exists
        folderPath = animRootFolder + "/" + assetName + "/"

        # collect controls
        controls = getControls(assetName)

        # get anim layers
        # animLayers = getAnimLayers(controls)

        # save animation
        createFolder(folderPath)
        exportAnim(folderPath, controls, assetName)
    else:
        folderPath = animRootFolder + "/camera/"
        createFolder(folderPath)
        camName = "shot_" + shotListView.currentItem().text()
        exportCameraAnim(folderPath, camName)

    if cameraAnim:
        assetName = "Camera"

    mc.inViewMessage( amg='Animation was saved for <hl>%s</hl>.' %assetName, pos='midCenter', fade=True )
Exemplo n.º 50
0
 def releaseCtx(self):
     '''
     called when we release the mouse inside viewport
     '''
     if self._mOriginPt:
         
         modifier = cmds.draggerContext(self._mContext, query = True, modifier = True)
         if modifier == 'shift':
             self.removeVoroPoints()
             self.setObjectToDisplay()
         else:
             if self._mVoroMethod == 1: 
                 self.uniformVoroPoints()
                 self.setObjectToDisplay()
             else:
                 self.radialVoroPoints()
                 self.setObjectToDisplay()                        
         
         self._mOriginPt = None
         
         if self._mInViewMessage:
             cmds.inViewMessage(amg = 'Estimated Fragments : <hl>' + str(self._mVoroPoints.length()) + '</hl>', dragKill = True, pos = 'topCenter')
         else:
             cmds.headsUpMessage('Estimated Fragments : ' + str(self._mVoroPoints.length()), verticalOffset = (cmds.control('modelPanel4', q = True, h = True) / 2.5))   
Exemplo n.º 51
0
        def hdri_render_main(self):
            if self.current_renderer not in self.accepted_renderers:
                cmds.inViewMessage(amg="This feature currently supports Vray, Arnold or Redshift renderers only",
                                   pos="botCenter", fade=True)
                return

            if self.render_position == "object":    # will render from object(s) centre
                if not self.render_geo:
                    cmds.inViewMessage(amg="Please Select an Object from which to render HDRI View",
                                       pos="botCenter", fade=True)
                    return

                else:
                    # get averaged centre of selected objects
                    x, y, z = 0, 0, 0
                    for geo in self.render_geo:
                        xyz = cmds.objectCenter(geo)
                        x += xyz[0]
                        y += xyz[1]
                        z += xyz[2]

                    objs_centre = x / len(self.render_geo), y / len(self.render_geo), z / len(self.render_geo)
                    cmds.hide(self.render_geo)  # hide objects while rendering

            # zero out any camera rotations and reposition to objects centre if needed
            cmds.setAttr("%s.rotate" % self.render_camera, 0, 0, 0)

            if self.render_position == "object":
                cmds.setAttr("%s.translate" % self.render_camera, objs_centre[0], objs_centre[1], objs_centre[2])

            if self.current_renderer == "vray":
                self.vray_render()
            if self.current_renderer == "redshift":
                self.redshift_render()
            if self.current_renderer == "arnold":
                self.arnold_render()
Exemplo n.º 52
0
def success(header="Success", message="", color="#00CC00"):
    msg = '<center><span style="color: %s ;">%s</span></center><left>\n%s</left>' % (color, header, message)
    # msg = '<center><span style=\"color: %s ;\">%s</span>\n%s</center>' % (color, header, message)
    cmds.inViewMessage(amg=msg, pos="midCenter", fade=True, fst=FST, fot=FOT)
Exemplo n.º 53
0
                        errorLog.write(str(e))
                    except:
                        pass
                    print(str(e))
                    mc.inViewMessage(message="Errors occured while executing '{0}'".format(self.frame_name), pos='topCenter', fade=True, fadeStayTime=750, fadeInTime=250, fadeOutTime=250)
            else:
                try:
                    exec(compile(open('{0}/commands/{1}.py'.format(self.gui.cur_path, self.frame_name)).read(), '{0}/commands/{1}.py'.format(self.gui.cur_path, self.frame_name), 'exec'))
                except Exception, e:
                    try:
                        errorLog = open(self.gui.cur_path + "/commands/errorLog.txt", "w")
                        errorLog.write(str(e))
                    except:
                        pass
                    print(str(e))
                    mc.inViewMessage(message="Errors occured while executing '{0}'".format(self.frame_name), pos='topCenter', fade=True, fadeStayTime=750, fadeInTime=250, fadeOutTime=250)
            
            last_command_file = open(self.gui.cur_path + "/commands/_last_used_command.ini", "w")
            last_command_file.write(self.frame_name)
            last_command_file.close()

            try:
                self.gui.commands_use_frequency[self.frame_name] = self.gui.commands_use_frequency[self.frame_name] + 1
            except:
                self.gui.commands_use_frequency[self.frame_name] = 1

            afile = open(self.gui.cur_path + "/commands/_commands_use_frequency.pkl", 'wb')
            pickle.dump(self.gui.commands_use_frequency, afile)
            afile.close()

        self.gui.close()
Exemplo n.º 54
0
def getAssets(shotList, assetList, shotState):
    # get shot data
    shotNumber = shotList.currentItem().text()

    shotRootFolder = config.rootFolder + shotNumber + "/"
    shotDataFile = shotRootFolder + "_shotData/shotData.json"
    shotData = jsonReader.jsonRead(shotDataFile)
    assets = shotData["assets"]

    selectedAssets = getSelectedAsset(assetList)
    if selectedAssets:
        assets = selectedAssets

    # get assets from constraintFile
    constrainedAssets = []
    constrainDataFiles = []
    for i in assets:
        assetsForConstraint = getAssetsForConstraints(shotRootFolder, i)
        if assetsForConstraint:
            for i in assetsForConstraint[0]:
                constrainedAssets.append(i)

            constrainDataFiles.append(assetsForConstraint[1])

    for i in assets:
        # handle duplicated reference
        duplicatedAsset = None
        if "{" in i:
            duplicatedAsset = i.replace("{", "").replace("}", "")
            i = i.split("{")[0]

        assetGroup = findAssetCategory.findCategory(i)
        filePath = getAssetpath(i)

        # handle shot versions
        assetLevel = False
        if not shotState == "WIP":
            assetState = filePath.replace("_MASTER", "_MASTER_" + shotState)

            # handle .mb to .ma conversion
            if not os.path.isfile(assetState):
                assetState = assetState.replace(".mb", ".ma")

            if os.path.isfile(assetState):
                assetLevel = True
                filePath = assetState

        # reference asset
        if duplicatedAsset:
            namespace = duplicatedAsset
            mc.file( filePath, r=True, namespace=namespace, ignoreVersion=True)
        else:
            namespace = filePath.split("/")[-1].split(".")[0]
            namespace = namespace.replace("_MASTER", "")
            if assetLevel:
                namespace = namespace.replace("_" + shotState, "")

            mc.file(filePath, r=True, namespace=namespace, ignoreVersion=True)

        rootGroup = namespace + ":root"
        mc.parent(rootGroup, assetGroup)

    # place static assets
    assetsDataFile = getAssetsData(shotRootFolder, assets)
    if assetsDataFile:
        assetsData = jsonReader.jsonRead(assetsDataFile)
        transformSets(assetsData)

    # setup constraints
    if constrainedAssets:
        setupConstraints(constrainDataFiles)

    # import animation
    for i in assets:
        importAnim.importAnim(shotRootFolder, i)

    mc.inViewMessage( amg='Shot: <hl>%s</hl>.' %shotNumber, pos='midCenter', fade=True )
Exemplo n.º 55
0
def stdError(header, message, color="#B00000"):
    # msg = '<center><span style=\"color: %s ;\">%s</span>\n%s</center>' % (color, header, message)
    msg = '<center><span style="color: %s ;">%s</span></center><left>\n%s</left>' % (color, header, message)
    cmds.inViewMessage(amg=msg, pos="midCenter", fade=True, fst=FST, fot=FOT)
    logger.warning("%s %s" % (header, message))
Exemplo n.º 56
0
 def hover_message(self, message):
     cmds.inViewMessage(amg='%s' % message, pos='botCenter', fade=True, fadeOutTime=500)
Exemplo n.º 57
0
def exceptionError(header, message, color = "#B00000", FOT = FOT):
    msg = '<center><span style=\"color: %s ;\">%s</span></center><left>\n%s</left>' % (color, header, message)
    cmds.inViewMessage(amg = msg, pos = 'midCenter', fade = True, fst = FST, fot = FOT)
    raise Exception, '{header} {message}'.format(**locals())
Exemplo n.º 58
0
def success(header = 'Success', message = '', color = "#00CC00", FOT = FOT):
    msg = '<center><span style=\"color: %s ;\">%s</span></center><left>\n%s</left>' % (color, header, message)
    cmds.inViewMessage(amg = msg, pos = 'midCenter', fade = True, fst = FST, fot = FOT)
Exemplo n.º 59
0
def joint_left_add():
    # メッセージ
    cmds.inViewMessage(amg="<hl>「足のIK設置」</hl>を押してください。", pos="midCenter", fade=True, fit=1, fst=4000, fts=20)
    cmds.mirrorJoint("Hip_R", myz=True, mb=True, sr=("_R", "_L"))
    cmds.mirrorJoint("Scapula_R", myz=True, mb=True, sr=("_R", "_L"))
Exemplo n.º 60
0
def stdError(header, message, color = "#B00000", FOT = FOT):
    msg = '<center><span style=\"color: %s ;\">%s</span></center><left>\n%s</left>' % (color, header, message)
    cmds.inViewMessage(amg = msg, pos = 'midCenter', fade = True, fst = FST, fot = FOT)