1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

python maya mod userSetup (mtoa)

Last updated at Posted at 2023-05-22

maya_2022.bat
@echo off

:: set Maya env
set MAYA_VERSION=2022

set MAYA_UI_LANGUAGE=en_US

set MAYA_APP_DIR=%userprofile%\Documents\projects\%PROJNAME%\Documents\maya
if not exist %MAYA_APP_DIR% mkdir %MAYA_APP_DIR%

set MODULE_FOLDER=%MAYA_APP_DIR%\modules
if not exist %MODULE_FOLDER% mkdir %MODULE_FOLDER%

set SCRIPT_FOLDER=%MAYA_APP_DIR%\%MAYA_VERSION%\scripts
if not exist %SCRIPT_FOLDER% mkdir %SCRIPT_FOLDER%

robocopy I:\script\bin\td\bin\project\%PROJNAME%\mod %MODULE_FOLDER%\ /it /E /IS /IT
robocopy I:\script\bin\td\bin\project\%PROJNAME%\userSetup %SCRIPT_FOLDER%\ /it /E /IS /IT
set MAYA_SHELF_PATH=J:/%PROJNAME%/work/project_tools/shelves

set OCIO=J:\%PROJNAME%\proj\%PROJNAME%\tool\settings\ocio\v5\config.ocio

call %MAYA_EXE% %* -pythonver 2
userSetup.py
import os
import maya.OpenMaya as om
import maya.cmds as cmds

import os
import sys
import pymel.core as pm
import maya.cmds as cmds
from maya.OpenMaya import MSceneMessage, MScriptUtil
import maya.mel as mel
import imp
import maya.utils
import maya.cmds as mc
from datetime import datetime
import getpass

sys.path.append(r"I:/script/bin/td/maya/tools/maya_2018_x64")
import nmaMayaMenu
import nmaToolPackage

userName = getpass.getuser()
# -----------------------------------------------------------
def delayedStartup(*args, **kwargs):
    print '*'*50
    print '*'*50
    print 'using maya.utils.executeDeferred()'
    #print 'set colorManagementPrefs'
    #cmds.colorManagementPrefs(e=True,cmEnabled=False)
    # cmds.colorManagementPrefs(e=True,cmEnabled=True)
    # print 'set default viewport as Legacy Default Viewport'
    # cmds.modelEditor('modelPanel4', e=True, rnm='base_OpenGL_Renderer' )
    # cmds.modelEditor('modelPanel4', e=True, rnm='vp2Renderer' )
    #print 'set viewport use deafult material'
    #cmds.modelEditor ('modelPanel4', e=True,  udm= True)
    print 'set default fps as 25(pal)'
    cmds.currentUnit( time='pal')
    # print 'set preferred render as arnold'
    # cmds.optionVar(sv =('preferredRenderer' ,'arnold'))
    cmds.playbackOptions(min = 1, ast =1, max =120, aet = 120)
    cmds.currentTime(1)
    # print 'render setup off'
    # cmds.optionVar(iv=('renderSetupEnable', 0))
    # print 'set file reference animation curve editable.'
    # cmds.optionVar(iv=('refAnimCurvesEditable', 1))
    print 'set resolution 1920*1080'
    cmds.setAttr('defaultResolution.w', 1920)
    cmds.setAttr('defaultResolution.h', 1080)


def killVaccineNodes(clientData):
    scriptNodes = cmds.ls('breed_gene', typ='script')
    if scriptNodes:
        cmds.delete(scriptNodes)
    scriptNodes = cmds.ls('vaccine_gene', typ='script')
    if scriptNodes:
        cmds.delete(scriptNodes)

file_path = cmds.internalVar(userAppDir=True) + '/scripts/vaccine.py'
if os.path.exists(file_path):
    os.remove(file_path)

om.MSceneMessage.addCallback(om.MSceneMessage.kAfterSceneReadAndRecordEdits, killVaccineNodes)

os.path.join(os.environ['MAYA_APP_DIR'], 'modules', 'mtoa.mod')
cmds.evalDeferred('cmds.loadPlugin("mtoa")')

mel.eval('source "\\isilon-x\General\script\bin\td\tools\deadline\userSetup.mel";')
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?