def setUpClass(cls): standalone.initialize('usd') # Stage with simple (non-nested) instancing. mayaFile = os.path.abspath('InstancedShading.ma') cmds.file(mayaFile, open=True, force=True) usdFilePath = os.path.abspath('InstancedShading.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='displayColor', exportInstances=True, materialsScopeName='Materials', exportCollectionBasedBindings=True, exportMaterialCollections=True, materialCollectionsPath="/World") cls._simpleStage = Usd.Stage.Open(usdFilePath) # Stage with nested instancing. mayaFile = os.path.abspath('NestedInstancedShading.ma') cmds.file(mayaFile, open=True, force=True) usdFilePath = os.path.abspath('NestedInstancedShading.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='displayColor', exportInstances=True, materialsScopeName='Materials', exportCollectionBasedBindings=True, exportMaterialCollections=True, materialCollectionsPath="/World") cls._nestedStage = Usd.Stage.Open(usdFilePath)
def main(): """ Main entry point. """ args = _PARSER.parse_args() if args.debug: _LOG.setLevel(logging.DEBUG) _LOG.debug("Detected debug flag, _LOG level changed to DEBUG") _, path_tmp = tempfile.mkstemp(suffix="json") path = os.path.abspath(args.path) _LOG.info("Will save schema to %r", path) _LOG.info("Initializing Maya...") standalone.initialize() cmds.loadPlugin("matrixNodes") _LOG.info("Generating schema...") schema = _generate() data = schema.to_dict() _LOG.debug("Saving schema...") with open(path_tmp, "w") as stream: json.dump(data, stream, indent=4, sort_keys=True) _LOG.debug("Applying changes...") shutil.copy2(path_tmp, path) os.remove(path_tmp) _LOG.info("Saved to %r", path) _LOG.info("Done. Closing Maya...") standalone.uninitialize()
def release(**kwargs): from maya import standalone standalone.initialize(name="python") from maya import OpenMaya maya_file = sys.argv[1] inputs = ast.literal_eval(sys.argv[2]) smaya = studioMaya.Maya() smaya.load_plugins( plugins=["pxrUsd", "pxrUsdPreviewSurface", "pxrUsdTranslators"]) smaya.open_maya(maya_file, None) current_show = inputs['show'] current_pipe = inputs['pipe'] current_application = inputs['application'] reapir = inputs['reapir'] from studio_usd_pipe.api import studioPush publish = studioPush.Push(current_show, current_pipe) valid, message = publish.validate(repair=reapir, **inputs) if not valid: returncode([valid, message]) standalone.uninitialize(name='python') return valid, message = publish.extract(repair=reapir, **inputs) if not valid: returncode([valid, message]) return extracted_data = publish.get_extracted_data() if not valid: returncode([valid, message]) return valid, message = publish.release() returncode([valid, message]) standalone.uninitialize(name='python')
def setUp(self): # Start Maya standalone.initialize(name='python') # Initial preset values self.input = {} self.input['control_options'] = { 'name': 'cnt1', 'shape': 'circle', 'color': 'red', 'control_grp': 'controls_grp', 'scale': 1 } self.input['cluster_options'] = { 'relative': True, 'resolution': 'Full', 'angle_interp': 'Closest' } self.input['parentConstraint_options'] = { 'interp_type': 'Average', 'buffer_node': 'cnt1_buffer', 'follow': 'back_jnt_2' } self.input['geo_options'] = { 'name': 'pSphere01', 'vertices': 'pSphere01Shape.vtx[0:100]', 'radius': 5 }
def openAndProcessMayaFile(file_path, asset_name, source_base_proj_dir, proj_dir, proj_dict_str, file_format_dict_str): print 'openAndProcessMayaFile start' import maya.standalone as standalone standalone.initialize(name='python') global cmds import maya.cmds as cmds proj_dict = eval(proj_dict_str) FILE_FORMAT_DICT = eval(file_format_dict_str) file_extension = file_path.rpartition('.')[2] maya_format = FILE_FORMAT_DICT['ma'] if file_extension == 'mb': maya_format = FILE_FORMAT_DICT['mb'] if file_extension in MAYA_FORMAT: cmds.file(file_path, open=True, ignoreVersion=True, prompt=False) if cmds.ls(type='file', long=True): copyTextureFiles(source_base_proj_dir, proj_dir, proj_dict) else: cmds.file(file_path, i=True, ignoreVersion=True, mergeNamespacesOnClash=False, namespace=asset_name, preserveReferences=True) scenes_dir_path = '%s/%s' % (proj_dir, proj_dict['scene']) new_file_name = '%s_v001_r001.ma' % asset_name new_scene_path = '%s/%s' % (scenes_dir_path, new_file_name) cmds.file(rename=new_scene_path) cmds.file(save=True, force=True, type=maya_format) cmds.file(new=True, force=True)
def requires_maya(func=None, gui=False): # Function as a decorator constructor. if not func: return functools.partial(requires_maya, gui=gui) # Start it up. if _has_maya and not hasattr(maya_cmds, 'about'): from maya import standalone standalone.initialize() _is_batch = _has_maya and threads.call_in_main_thread(maya_cmds.about, batch=True) if not _has_maya or (gui and _is_batch): @functools.wraps(func) def _skipper(*args, **kwargs): from nose.exc import SkipTest raise SkipTest return _skipper # Not in batch mode, so we need to run in the main thread. if not _is_batch: trampoliner = trampoline.decorate(threads.call_in_main_thread) return trampoliner(func) # Pass it through. return func
def run(self): from avalon import api, io import maya.standalone as standalone import pyblish.util standalone.initialize(name="python") # Get project root path and rig source files. jobs = dict() root = api.registered_root() for rig_version, rig_subset in self.rig_versions.items(): version_id = io.ObjectId(rig_version) latest_ver = io.find_one({"type": "version", "_id": version_id}) rig_source = latest_ver["data"]["source"].format(root=root) rig_source = rig_source.replace("\\", "/") if rig_source not in jobs: jobs[rig_source] = list() # One source scene may contains multiple rig subsets. jobs[rig_source].append(rig_subset) # Run publish process, till extraction for source, rig_subsets in jobs.items(): self._publish(source, rig_subsets) # Run final integration only if all extraction succeed for context in self.contexts: context.data["_autoPublishingSkipUnlock"] = True pyblish.util.integrate(context=context) standalone.uninitialize()
def setUpClass(cls): standalone.initialize('usd') cmds.file(os.path.abspath('UsdExportPrefTest.ma'), open=True, force=True) cmds.loadPlugin('pxrUsd', quiet=True)
def start(*args): from maya import standalone standalone.initialize(name='python') from pymel import core core.openFile(args[0], f=True) result = None if args[1].endswith('.mel'): try: core.mel.eval('source \"%s\"' % args[1]) result = True except Exception as error: warnings.warn(str(error), Warning) result = False else: code_dirname = os.path.dirname(args[1]) code_name = os.path.splitext(os.path.basename(args[1]))[0] for module_loader, name, ispkg in pkgutil.iter_modules([code_dirname]): if name != code_name: continue loader = module_loader.find_module(name) try: module = loader.load_module(name) result = True except Exception as error: warnings.warn(str(error), Warning) result = False if not result: return if args[2] != 'None': core.saveAs(args[2], f=True, iv=True, pmt=True) standalone.uninitialize(name='python')
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd') usdFile = os.path.abspath('UsdImportColorSetsTest.usda') cmds.usdImport(file=usdFile, shadingMode='none', excludePrimvar='ExcludeMe')
def setUpClass(cls): standalone.initialize('usd') testDir = os.path.join(os.path.abspath('.'), "PxrUsdPreviewSurfaceExportTest") cmds.workspace(testDir, o=True) cmds.file('PxrUsdPreviewSurfaceExportTest.ma', open=True, force=True) defaultExtSetting = cmds.file(q=True, defaultExtensions=True) cmds.file(defaultExtensions=False) # Export to USD. usdFilePath = os.path.abspath('PxrUsdPreviewSurfaceExportTest.usda') cmds.loadPlugin('mayaUsdPlugin', quiet=True) cmds.file(usdFilePath, force=True, options="shadingMode=useRegistry;mergeTransformAndShape=1", typ="USD Export", pr=True, ea=True) cmds.file(defaultExtensions=defaultExtSetting) cls.stage = Usd.Stage.Open(usdFilePath)
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd') cls._deformingCubeUsdFilePath = os.path.abspath('DeformingCube.usda') cls._deformingCubePrimPath = '/DeformingCube/Geom/Cube'
def pytest_sessionstart(session): """ before session.main() is called. """ # skips all the usersetup.py modules os.environ['MAYA_SKIP_USERSETUP_PY'] = '1' # NOTE: the QApplication has to be created before maya is initialized QtWidgets.QApplication([]) standalone.initialize()
def qt_launch_mayapy(mainInstance,**argv): from dsk.base.widgets.simpleqt import QtT """ important to keep the QApplication creation before importing standalone to get a valid Gui QtCore app """ app = QtT.QtCore.QCoreApplication.instance() if app == None: app = QtT.QtWidgets.QApplication(sys.argv) #app.setQuitOnLastWindowClosed(True) import maya.standalone as standalone standalone.initialize(os.path.basename(sys.argv[0])) import maya.cmds as cmds cmds.undoInfo(state=False) # Turn off undo cmds.autoSave(enable=False) # Turn off autosave window = mainInstance(None, **argv) if window.size().width() <= 0 or window.size().height() <= 0: window.resize(500,500) window.move(100,100) QtT.QtWidgets.QApplication.processEvents() window.show() window.raise_() try: sys.exit(app.exec_()) except: pass return window
def setUpClass(cls): standalone.initialize('usd') cmds.file(os.path.abspath('UsdExportNurbsCurveTest.ma'), open=True, force=True) cmds.loadPlugin('pxrUsd', quiet=True)
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd') if not UsdMaya.WriteUtil.WriteUVAsFloat2(): cmds.file(os.path.abspath('UsdExportUVSetsTest.ma'), open=True, force=True) else: cmds.file(os.path.abspath('UsdExportUVSetsTest_Float.ma'), open=True, force=True) # Make some live edits to the box with weird UVs for the # testExportUvVersusUvIndexFromIterator test. cmds.select("box.map[0:299]", r=True) cmds.polyEditUV(u=1.0, v=1.0) usdFilePath = os.path.abspath('UsdExportUVSetsTest.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='none', exportColorSets=False, exportDisplayColor=False, exportUVs=True) cls._stage = Usd.Stage.Open(usdFilePath)
def batch_obj(): # Start Maya in batch mode std.initialize(name='python') #load obj plugin mc.loadPlugin("objExport") fileList = [] dir = str(sys.argv[1]) for mFile in os.listdir(dir): if mFile.endswith('.mb'): fileList.append(dir + "\\" + mFile) for item in fileList: # Open the file with the file command mc.file(item, force=True, open=True) mc.select(all=1) #export obj finalExportPath = "%s.obj" % (item[:-3]) try: mc.file(finalExportPath, pr=1, typ="OBJexport", es=1, op="groups=1;ptgroups=0;materials=1;smoothing=1;normals=1") print finalExportPath sys.stdout.write(finalExportPath) except Exception, e: sys.stderr.write(str(e)) sys.exit(-1) print "Ignoring object named: '%s'. Export failed, probably not a polygonal object. " % ( item)
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd') if not UsdMaya.WriteUtil.WriteUVAsFloat2(): cmds.file(os.path.abspath('UsdExportUVSetsTest.ma'), open=True, force=True) else: cmds.file(os.path.abspath('UsdExportFloatUVSetsTest.ma'), open=True, force=True) # Make some live edits to the box with weird UVs for the # testExportUvVersusUvIndexFromIterator test. cmds.select("box.map[0:299]", r=True) cmds.polyEditUV(u=1.0, v=1.0) usdFilePath = os.path.abspath('UsdExportUVSetsTest.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='none', exportColorSets=False, exportDisplayColor=False, exportUVs=True) cls._stage = Usd.Stage.Open(usdFilePath)
def begin_work(self): """Reimplemented from BasicWorker.""" print '[worker] BEGINNING WORK', pprint.pformat(self.payload) print '[worker] STARTING MAYA STANDALONE' from maya import standalone standalone.initialize()
def setUpClass(cls): standalone.initialize('usd') cmds.file(os.path.abspath('InstancerTest.ma'), open=True, force=True) # Create nCache. This is to be on the safe side and ensure that the # particles have the same positions for all test cases. # It doesn't look like doCreateNclothCache is Python-wrapped. cmds.select("nParticle1") cacheLocation = os.path.abspath("nCache") mel.eval( 'doCreateNclothCache 5 { "2", "1", "10", "OneFile", "1", "%s","0","","0", "add", "0", "1", "1","0","1","mcx" }' % cacheLocation) # Export to USD. (Don't load the reference assembly yet; this should # work without the reference assembly.) usdFilePath = os.path.abspath('InstancerTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='none', frameRange=(cls.START_TIMECODE, cls.END_TIMECODE)) cls.stage = Usd.Stage.Open(usdFilePath) # Load the USD reference assembly so that it draws instanced. assembly = OM.MFnAssembly(cls._GetDagPath("referencePrototype")) assembly.activate("Full")
def wrapper(*args, **kwargs): if not hasattr(cmds, "about"): from maya import standalone standalone.initialize() return func(*args, **kwargs)
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin("MASH") scene = "InstancerTestMash.ma" cmds.file(os.path.abspath(scene), open=True, force=True) # Create nCache. This is to be on the safe side and ensure that the # particles have the same positions for all test cases. # It doesn't look like doCreateNclothCache is Python-wrapped. cmds.select("nParticle1") # Note: this MEL command expects paths to be in the Maya-normalized # format with the '/' dir separator; using the Windows-style separator # will cause MEL script errors because it's treated as an escape. cacheLocation = os.path.abspath("nCache").replace(os.path.sep, "/") mel.eval( 'doCreateNclothCache 5 { "2", "1", "10", "OneFile", "1", "%s","0","","0", "add", "0", "1", "1","0","1","mcx" }' % cacheLocation) # Export to USD. (Don't load the reference assembly yet; this should # work without the reference assembly.) usdFilePath = os.path.abspath('InstancerTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='none', frameRange=(cls.START_TIMECODE, cls.END_TIMECODE), kind='component') cls.stage = Usd.Stage.Open(usdFilePath) # Load the USD reference assembly so that it draws instanced. assembly = OM.MFnAssembly(cls._GetDagPath("referencePrototype")) assembly.activate("Full")
def setUpClass(cls): standalone.initialize('usd') # Stage with simple (non-nested) instancing. mayaFile = os.path.abspath('InstancedShading.ma') cmds.file(mayaFile, open=True, force=True) usdFilePath = os.path.abspath('InstancedShading.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='displayColor', exportInstances=True, exportCollectionBasedBindings=True, exportMaterialCollections=True, materialCollectionsPath="/World") cls._simpleStage = Usd.Stage.Open(usdFilePath) # Stage with nested instancing. mayaFile = os.path.abspath('NestedInstancedShading.ma') cmds.file(mayaFile, open=True, force=True) usdFilePath = os.path.abspath('NestedInstancedShading.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='displayColor', exportInstances=True, exportCollectionBasedBindings=True, exportMaterialCollections=True, materialCollectionsPath="/World") cls._nestedStage = Usd.Stage.Open(usdFilePath)
def setUpClass(cls): standalone.initialize('usd') # Deprecated since version 3.2: assertRegexpMatches and assertRaisesRegexp # have been renamed to assertRegex() and assertRaisesRegex() if sys.version_info.major < 3 or sys.version_info.minor < 2: cls.assertRegex = cls.assertRegexpMatches cls.assertRaisesRegex = cls.assertRaisesRegexp
def get_pipe_ids(**kwargs): from maya import standalone standalone.initialize(name="python") from maya import OpenMaya maya_file = sys.argv[1] data = maya_asset.get_pipe_ids() returncode(data) standalone.uninitialize(name='python')
def openPythonStandalone(filepath): try: standalone.initialize(name='python') cmds.file(filepath, open=True) cmds.loadPlugin('AbcExport') cmds.loadPlugin('mtoa') except: return
def maya_standalone(): """Fixture that initialize maya standalone""" from maya import standalone standalone.initialize() yield standalone.uninitialize()
def setUpModule(): from maya import standalone standalone.initialize(name='python') from maya import cmds from mtoatools import plugins module_namespace['standalone'] = standalone module_namespace['cmds'] = cmds module_namespace['plugins'] = plugins
def backgroundMaster(fType, variant, variantFolder, newWSFile, destination, currentMaster, *args): """ variant is var name [] variantFolder is path to variant [. . .shots/SHOT/TYPE/VARIANT] newWSFile is the most recent ws of that variant destination is the full path to the proposed latest pastVersion of the master (incremented version of master in past_versions) currentMaster is the full path to the master we'll be creating """ #set up the log file saveout = sys.stdout fsock = open("{0}/{1}_masterLog.log".format(variantFolder, variant), "w") sys.stdout = fsock sys.stderr = fsock # print getpass.getuser() # print datetime.datetime.now() print "backgroundMaster.newWSFile:", newWSFile print "backgroundMaster.destination:", destination print "backgroundMaster.currentMaster:", currentMaster print "-------starting mastering------" initialize("python") print "== initialized python" ##########################--------- fix below for mastering. . .. # get latest variant WS path (newWSFile) # get past variant master path (destination) # get variant master path (currentMaster) # open latest ws file, call clean(?), rename and save as currentMaster, DON"T INCREMENT WS AFTERWARDS. This will happen in masterFuncs cmds.file(newWSFile, open=True, force=True) mFuncs.cleanShotScene(fType, BG=False, importRefs=True) #load the refs cmds.file(rename=currentMaster) if os.path.isfile( currentMaster ): #check if there is a master file currently. If so, move it to the past versions os.rename(currentMaster, destination) print "masterFuncs.masterShot:\n------ moving: {0} \n------ to: {1}".format( currentMaster, destination) cmds.file(save=True, type="mayaAscii") # save as master cmds.file(newFile=True, force=True) print "== mastered variant file" uninitialize() return ("completed") print "== closing socket" #close out the log file sys.stdout = saveout fsock.close()
def setUpClass(cls): standalone.initialize('usd') cmds.file(new=True, force=True) # Import the USD file. usdFilePath = os.path.abspath('UsdImportCameraTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdImport(file=usdFilePath, readAnimData=True) cls._stage = Usd.Stage.Open(usdFilePath)
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd') usdFile = "" if UsdMaya.ReadUtil.ReadFloat2AsUV(): usdFile = os.path.abspath('UsdImportUVSetsTest_Float.usda') else: usdFile = os.path.abspath('UsdImportUVSetsTest.usda') cmds.usdImport(file=usdFile, shadingMode='none')
def setUp(self): # Start Maya standalone.initialize(name='python') # Initial preset values self.input = {} self.input['control_options'] = {'name':'cnt1', 'shape':'circle', 'color':'red', 'control_grp':'controls_grp', 'scale':1} self.input['cluster_options'] = {'relative':True, 'resolution':'Full','angle_interp':'Closest'} self.input['parentConstraint_options'] = {'interp_type':'Average', 'buffer_node':'cnt1_buffer', 'follow':'back_jnt_2'} self.input['geo_options'] = { 'name':'pSphere01', 'vertices':'pSphere01Shape.vtx[0:100]', 'radius':5 }
def get_pipe_ids(**kwargs): from maya import standalone standalone.initialize(name="python") from maya import OpenMaya maya_file = sys.argv[1] smaya = studioMaya.Maya() smaya.open_maya(maya_file, None) data = maya_scene.get_scene_pipe_ids() returncode(data) standalone.uninitialize(name='python')
def setUpClass(cls): standalone.initialize('usd') cmds.file(new=True, force=True) # Import from USD. usdFilePath = os.path.abspath('MarbleCube.usda') cmds.loadPlugin('pxrUsd') cmds.usdImport(file=usdFilePath, shadingMode='pxrRis') cls._stage = Usd.Stage.Open(usdFilePath)
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd') mayaFile = os.path.abspath('SingleLocator.ma') cmds.file(mayaFile, open=True, force=True) cls._singleLocatorUsdFilePathMerged = os.path.abspath( 'SingleLocator_MERGED.usda') cmds.usdExport(file=cls._singleLocatorUsdFilePathMerged, mergeTransformAndShape=True, shadingMode="none") cls._singleLocatorUsdFilePathUnmerged = os.path.abspath( 'SingleLocator_UNMERGED.usda') cmds.usdExport(file=cls._singleLocatorUsdFilePathUnmerged, mergeTransformAndShape=False, shadingMode="none") cls._singleLocatorUsdFilePathMergedRanged = os.path.abspath( 'SingleLocator_MERGED_RANGED.usda') cmds.usdExport(file=cls._singleLocatorUsdFilePathMergedRanged, mergeTransformAndShape=True, shadingMode="none", frameRange=(1, 1)) cls._singleLocatorUsdFilePathUnmergedRanged = os.path.abspath( 'SingleLocator_UNMERGED_RANGED.usda') cmds.usdExport(file=cls._singleLocatorUsdFilePathUnmergedRanged, mergeTransformAndShape=False, shadingMode="none", frameRange=(1, 1)) mayaFile = os.path.abspath('CubeUnderLocator.ma') cmds.file(mayaFile, open=True, force=True) cls._locatorParentUsdFilePathMerged = os.path.abspath( 'CubeUnderLocator_MERGED.usda') cmds.usdExport(file=cls._locatorParentUsdFilePathMerged, mergeTransformAndShape=True, shadingMode="none") cls._locatorParentUsdFilePathUnmerged = os.path.abspath( 'CubeUnderLocator_UNMERGED.usda') cmds.usdExport(file=cls._locatorParentUsdFilePathUnmerged, mergeTransformAndShape=False, shadingMode="none") cls._locatorParentUsdFilePathMergedRanged = os.path.abspath( 'CubeUnderLocator_MERGED_RANGED.usda') cmds.usdExport(file=cls._locatorParentUsdFilePathMergedRanged, mergeTransformAndShape=True, shadingMode="none", frameRange=(1, 1)) cls._locatorParentUsdFilePathUnmergedRanged = os.path.abspath( 'CubeUnderLocator_UNMERGED_RANGED.usda') cmds.usdExport(file=cls._locatorParentUsdFilePathUnmergedRanged, mergeTransformAndShape=False, shadingMode="none", frameRange=(1, 1))
def setUpClass(cls): standalone.initialize('usd') cmds.file(new=True, force=True) cmds.loadPlugin('RenderMan_for_Maya', quiet=True) # Import from USD. usdFilePath = os.path.abspath('RfMLightsTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdImport(file=usdFilePath, shadingMode='pxrRis') cls._stage = Usd.Stage.Open(usdFilePath)
def setUpClass(cls): standalone.initialize('usd') filepath = os.path.abspath('AssemblyTest.ma') cmds.file(filepath, open=True, force=True) usdFilePath = os.path.abspath('AssemblyTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='none') cls._stage = Usd.Stage.Open(usdFilePath)
def setUpClass(cls): standalone.initialize('usd') mayaFile = os.path.abspath('MarbleCube.ma') cmds.file(mayaFile, open=True, force=True) # Export to USD. usdFilePath = os.path.abspath('MarbleCube.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='pxrRis', materialsScopeName='Materials') cls._stage = Usd.Stage.Open(usdFilePath)
def setUpClass(cls): standalone.initialize('usd') cmds.file(os.path.abspath('UserExportedAttributesTest.ma'), open=True, force=True) usdFilePathFormat = 'UserExportedAttributesTest_EXPORTED_%s.usda' mergedUsdFilePath = os.path.abspath(usdFilePathFormat % 'MERGED') unmergedUsdFilePath = os.path.abspath(usdFilePathFormat % 'UNMERGED') cmds.loadPlugin('pxrUsd', quiet=True) cmds.usdExport(file=mergedUsdFilePath, mergeTransformAndShape=True) cmds.usdExport(file=unmergedUsdFilePath, mergeTransformAndShape=False)
def setUpClass(cls): standalone.initialize('usd') cmds.file(os.path.abspath('UsdExportDisplayColorTest.ma'), open=True, force=True) # Export to USD. usdFilePath = os.path.abspath('UsdExportDisplayColorTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='none', exportDisplayColor=True) cls._stage = Usd.Stage.Open(usdFilePath)
def setUpClass(cls): standalone.initialize('usd') cmds.file(os.path.abspath('PxrUsdPreviewSurfaceExportTest.ma'), open=True, force=True) # Export to USD. usdFilePath = os.path.abspath('PxrUsdPreviewSurfaceExportTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='useRegistry') cls.stage = Usd.Stage.Open(usdFilePath)
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 setUpClass(cls): standalone.initialize('usd') cmds.file(os.path.abspath('UsdExportCameraTest.ma'), open=True, force=True) # Export to USD. usdFilePath = os.path.abspath('UsdExportCameraTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='none', frameRange=(cls.START_TIMECODE, cls.END_TIMECODE)) cls.stage = Usd.Stage.Open(usdFilePath)
def preflight(package): from .worker import log import maya.standalone as maya_standalone maya_standalone.initialize() from maya import cmds filename = package.get('filename') if filename: log('opening file %r' % filename) cmds.file(filename, open=True, force=True) workspace = package.get('workspace') if workspace: log('setting workspace %r' % workspace) cmds.workspace(dir=workspace)
def setUpClass(cls): standalone.initialize('usd') # Choose the test file based on whether the MASH plugin is available. try: cmds.loadPlugin("MASH") # Even though, ie, maya2016 Ext has MASH, the node attributes / etc # changed enough to be incompatible with InstancerTestMash.ma; also, # the .ma file has a "requires maya "2018" statement cls.hasMash = cmds.about(apiVersion=1) >= 20180000 except: cls.hasMash = False scene = "InstancerTestMash.ma" if cls.hasMash else "InstancerTest.ma" cmds.file(os.path.abspath(scene), open=True, force=True) # Create nCache. This is to be on the safe side and ensure that the # particles have the same positions for all test cases. # It doesn't look like doCreateNclothCache is Python-wrapped. cmds.select("nParticle1") # Note: this MEL command expects paths to be in the Maya-normalized # format with the '/' dir separator; using the Windows-style separator # will cause MEL script errors because it's treated as an escape. cacheLocation = os.path.abspath("nCache").replace(os.path.sep, "/") mel.eval('doCreateNclothCache 5 { "2", "1", "10", "OneFile", "1", "%s","0","","0", "add", "0", "1", "1","0","1","mcx" }' % cacheLocation) # Export to USD. (Don't load the reference assembly yet; this should # work without the reference assembly.) usdFilePath = os.path.abspath('InstancerTest.usda') cmds.loadPlugin('pxrUsd') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, shadingMode='none', frameRange=(cls.START_TIMECODE, cls.END_TIMECODE), kind='component') cls.stage = Usd.Stage.Open(usdFilePath) # Load the USD reference assembly so that it draws instanced. assembly = OM.MFnAssembly(cls._GetDagPath("referencePrototype")) assembly.activate("Full")
def setUp(self): """Construct simple Maya scene""" super(ModelPublishTestCase, self).setUp() standalone.initialize(name='python') root_path = tempfile.mkdtemp() fname = 'temp.ma' self.mel = mel self.cmds = cmds self.fname = fname self.root_path = root_path self.create_workspace_definition() mel.eval('setProject "{0}"'.format( root_path.replace("\\", "/"))) self.create_scene()
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd', quiet=True) usdFile = os.path.abspath('%s.usda' % cls.SET_NAME) primPath = '/%s' % cls.SET_NAME assemblyNode = cmds.createNode('pxrUsdReferenceAssembly', name=cls.SET_NAME) cmds.setAttr("%s.filePath" % assemblyNode, usdFile, type="string") cmds.setAttr("%s.primPath" % assemblyNode, primPath, type="string") # The set layer specifies a frame range of 101-149, so when we activate # the 'Full' representation and trigger an import, we expect the # current frame range in Maya to be expanded to include that. We set # it to something inside that range now so we can make sure that that # happens. OMA.MAnimControl.setAnimationStartEndTime(OM.MTime(121), OM.MTime(130)) cmds.assembly(assemblyNode, edit=True, active='Full')
from os.path import join from maya.standalone import initialize import maya.cmds as cmds import maya.mel as mel import glob import sys import os export_path = sys.argv[1] source_path = sys.argv[2] print 'initialize maya standalone engine' initialize() print 'loadPlugin fbxmaya' cmds.loadPlugin("fbxmaya") print 'initialize done.' for f in glob.iglob(source_path + "/*.mb"): cmds.file (f, force=True, open=True) print 'open :' + f del_list = [] mat_array = cmds.ls( materials=True ) tex_array = cmds.ls( textures=True ) for fileNode in tex_array: tex_type = cmds.nodeType( fileNode ) if tex_type == 'file':
import sys import os import maya.standalone as std std.initialize(name='python') import maya.cmds as mc def runScripts(mayaFile, scripts, save = False): """docstring for runScripts""" maya.standalone.initialize(name='python') mc.file(mayaFile, force=True, open=True ) scripts = scripts.split( ',' ) for s in scripts: sys.path.append( os.path.dirname( s ) ) cmd = "import "+os.path.filename( s ) eval( cmd ) if save: mc.file(save=True, force=True) mayaFile = sys.argv[1] scripts = sys.argv[2] save = sys.argv[3] runScripts(mayaFile, scripts, save )
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd', quiet=True)
def setUpClass(cls): standalone.initialize('usd')
import unittest import sys import os import maya.cmds as cmds import maya.standalone as standalone standalone.initialize(name='python') cwd = os.path.dirname(os.path.abspath(__file__).replace('tests','')) if cwd not in sys.path: sys.path.append(cwd) import ClusterLib reload( ClusterLib ) class test_ClusterLib(unittest.TestCase): def setUp(self): cmds.file(newFile=True,f=True) self.sphere = cmds.polySphere() self.loc1 = cmds.spaceLocator()[0] self.loc2 = cmds.spaceLocator()[0] self.joint = cmds.joint() def tearDown(self): pass def test_clusterSingleObject(self): name = 'test' deform = self.sphere[0] handle = self.loc1 follow = self.loc2
def setUpClass(cls): standalone.initialize('usd') cmds.loadPlugin('pxrUsd') usdFile = os.path.abspath('UsdAttrs.usda') cmds.usdImport(file=usdFile, shadingMode='none')