def exit_maya(): import sys # If we are in standalone we need to make a new file and uninitialize then the virtual machines crash # if we do not use os._exit to properly exit Maya in CIRCLECI. # https://groups.google.com/forum/#!topic/python_inside_maya/chpuSyLbryI try: import maya.standalone as ms sys.stdout.write('Anvil is exiting Standalone Maya.') mc.file(new=True, force=True) sys.stdout.write('.') sys.stdout.flush() from pymel import versions if not str(versions.current()).startswith('2016'): ms.uninitialize() sys.stdout.write('.') sys.stdout.flush() except: pass finally: sys.stdout.write('Success...exiting.\n') sys.stdout.flush() import os if os.getenv('CIRCLECI'): os._exit(0)
def main(): flg = setup_log("logging.DEBUG") search_dir = '//awexpress.westphal.drexel.edu/digm_anfx/SPRJ_cgbirds' flg.debug("Initializing Maya") # Starts interpreter mcs.initialize(name='python') flg.info("Maya Initialized") output_file_name = gen_file_name() test_file(output_file_name, search_dir) files = get_ma_files(os.path.normpath(search_dir)) results = [] flg.info("Getting List of Unwanted Nodes") bad_types = bad_types_list() flg.info("Searching Files") i = 0 j = 1 chunked = split_chunks(files, 250) for c in chunked: flg.debug("Searching Chunk {} out of {}".format(j, len(chunked))) for f in c: print("{} out of {} files".format(i, len(files))) results.append(search_file(f, bad_types)) i += 1 flg.debug("Compiling results for chunk {}".format(j)) comp_res = compile_results(results, '\r', '*' * 150, "Chunk {} out of {}".format(j, len(chunked)), '*' * 150, '\r' ) array_to_file(comp_res, output_file_name) j += 1 mcs.uninitialize() flg.info("Maya uninitialized")
def tearDownClass(cls): standalone.uninitialize()
def tearDownClass(cls): standalone.uninitialize()
from maya.standalone import initialize, uninitialize import os import sys import maya.cmds as cmds import maya.mel as mel print "imported stuff" #sys.path.append("C:\Program Files\Autodesk\Maya2016\bin\mayapy.exe") saveout = sys.stdout fsock = open("c:/Users/zeth/Desktop/zethLog3.log", "w") sys.stdout = fsock sys.stderr = fsock initialize(name="python") print "initialized python" cmds.file(force=True, new=True) cmds.sphere(n="yoSphere") print "did some maya stuff" cmds.file(rename="c:/Users/zeth/Desktop/StandaloneFile.ma") cmds.file(save=True, force=True) print "saved the scene" uninitialize() print "unitialized and out" sys.stdout = saveout fsock.close()
def tearDownClass(cls): # See comments in MayaUFEPickWalkTesting.tearDownClass cmds.file(new=True, force=True) standalone.uninitialize()
def tearDownClass(cls): cmds.file(new=True, force=True) standalone.uninitialize()
def teardown(): standalone.uninitialize()
def tearDownModule(): standalone.uninitialize()
def run_with_maya_standalone(): from maya import standalone standalone.initialize(name="python") yield standalone.uninitialize()
def buildInitialRigFiles(asset, assetFolder, *args): """initializes maya standalone and runs the code to setup the rig ws""" #set up the log file saveout = sys.stdout fsock = open("{0}/{1}_masterLog.log".format(assetFolder, asset), "w") sys.stdout = fsock sys.stderr = fsock print getpass.getuser() print datetime.datetime.now() print "-------starting build of initial rig files------" initialize("python") print "== initialized python" rigWS = "{0}/rig/workshops/{1}_rig_ws_v001.ma".format(assetFolder, asset) geoMst = "{0}/geo/{1}_geo.ma".format(assetFolder, asset) print "geoMst:", geoMst #new scene cmds.file(new=True, force=True) print "== opened new file" #ref in geoMaster cmds.file(geoMst, reference=True, renamingPrefix = "geo", deferReference = False, loadReferenceDepth="all", ignoreVersion=True) #load the refs refs = cmds.file(q=True, r=True) for ref in refs: refNode = cmds.referenceQuery(ref, rfn=True) print "ref node:", refNode if cmds.file(rfn=refNode, q=True, dr=True): cmds.file(rfn=refNode, lr=True) print "== referenced in: {0}".format(geoMst) #get reffed geo and group it reffed = cmds.ls(geometry=True) geo = [] if reffed: for r in reffed: p = cmds.listRelatives(r, p=True) if p: geo.append(p[0]) grp = cmds.group(empty=True, n="refGeo") if geo: for g in geo: try: cmds.parent(g, grp) except: print "had an issue adding {0} to the ref group".format(g) print "== parented geo into folder and dropped into 'BODY' con" #run rig setup to build sets and controls setup.rigSetup() print "== built the rig sets and controls (rigSetup)" if cmds.objExists("*RIGDATA"): dataNode = cmds.ls("*RIGDATA")[0] factor = cmds.getAttr("{0}.scaleCtrl".format(dataNode)) #scale controls cmds.select(["GOD.cv[*]", "DIRECTION.cv[*]", "BODY.cv[*]"]) cmds.scale(factor, factor, factor) cmds.select(clear=True) cmds.delete("*RIGDATA") print "== scaled and deleted control template" #parent this group under "BODY" cmds.parent(grp, "BODY") #rename the scene to asset_rig_ws_v001 cmds.file(rename=rigWS) #save scene cmds.file(save=True, type = "mayaAscii", force=True) print "== renamed and saved as rig WS" #now call master rig on this file mFuncs.masterAsset(asset, assetFolder, "rig", True) print "== mastered rig file" uninitialize() return("completed") print "== closing socket" #close out the log file sys.stdout = saveout fsock.close()