本文整理汇总了Python中maya.cmds.usdExport函数的典型用法代码示例。如果您正苦于以下问题:Python usdExport函数的具体用法?Python usdExport怎么用?Python usdExport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了usdExport函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testReexport
def testReexport(self):
cmds.usdImport(file=self.USD_FILE, primPath='/')
cmds.usdExport(file=self.USD_FILE_OUT)
stage = Usd.Stage.Open(self.USD_FILE_OUT)
self.assertTrue(stage)
self.assertTrue(stage.GetPrimAtPath('/A'))
self.assertEqual(stage.GetPrimAtPath('/A').GetTypeName(), 'Xform')
self.assertTrue(stage.GetPrimAtPath('/A/A_1'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1').GetTypeName(), '')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_I'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_I').GetTypeName(),
'')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_II'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_II').GetTypeName(),
'') # Originally Cube, but not on re-export!
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_III'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_III').GetTypeName(),
'Scope')
self.assertTrue(stage.GetPrimAtPath('/A/A_2'))
self.assertEqual(stage.GetPrimAtPath('/A/A_2').GetTypeName(), 'Scope')
self.assertTrue(stage.GetPrimAtPath('/B'))
self.assertEqual(stage.GetPrimAtPath('/B').GetTypeName(), '')
self.assertTrue(stage.GetPrimAtPath('/B/B_1'))
self.assertEqual(stage.GetPrimAtPath('/B/B_1').GetTypeName(), 'Xform')
示例2: setUpClass
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)
示例3: setUpClass
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)
示例4: testReexportScope
def testReexportScope(self):
cmds.usdImport(file=self.USD_FILE, primPath='/')
cmds.usdExport(file=self.USD_FILE_OUT)
stage = Usd.Stage.Open(self.USD_FILE_OUT)
self.assertTrue(stage)
self.assertTrue(stage.GetPrimAtPath('/A'))
self.assertEqual(stage.GetPrimAtPath('/A').GetTypeName(), 'Xform')
self.assertTrue(stage.GetPrimAtPath('/A/A_1'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1').GetTypeName(), 'Scope')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_I'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_I').GetTypeName(),
'Mesh')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_II'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_II').GetTypeName(),
'Camera')
self.assertTrue(stage.GetPrimAtPath('/A/A_1/A_1_III'))
self.assertEqual(stage.GetPrimAtPath('/A/A_1/A_1_III').GetTypeName(),
'Scope')
self.assertTrue(stage.GetPrimAtPath('/A/A_2'))
self.assertEqual(stage.GetPrimAtPath('/A/A_2').GetTypeName(), 'Scope')
self.assertTrue(stage.GetPrimAtPath('/B'))
self.assertEqual(stage.GetPrimAtPath('/B').GetTypeName(), 'Scope')
self.assertTrue(stage.GetPrimAtPath('/B/B_1'))
self.assertEqual(stage.GetPrimAtPath('/B/B_1').GetTypeName(), 'Xform')
示例5: testArKitCompatibility
def testArKitCompatibility(self):
'''Tests usdz package export with ARKit compatibility profile.'''
usdFile = os.path.abspath('MyAwesomeArKitCompatibleFile.usdz')
usdFileNoExt = os.path.abspath('MyAwesomeArKitCompatibleFile')
# The usdExport command should automatically add "usdz" extension since
# we're requestion appleArKit compatibility.
cmds.usdExport(
file=usdFileNoExt,
mergeTransformAndShape=True,
shadingMode='none',
compatibility='appleArKit')
# Lets make sure that the root layer is the first file and that all
# the references were localized ok.
# Note that the path of "card.png" in the usdz archive may have changed
# because of the flattening step.
zipFile = Usd.ZipFile.Open(usdFile)
fileNames = zipFile.GetFileNames()
self.assertEqual(len(fileNames), 2)
self.assertEqual(fileNames[0], "MyAwesomeArKitCompatibleFile.usdc")
self.assertTrue(fileNames[1].endswith("card.png"))
# Open the usdz file up to verify that everything exported properly.
stage = Usd.Stage.Open(usdFile)
self._AssertExpectedStage(stage, fileNames[-1])
# Make sure there's no weird temp files sitting around.
self._AssertNoTempFiles(usdFile)
示例6: testExportInstances
def testExportInstances(self):
usdFile = os.path.abspath('UsdExportPref_nopref.usda')
cmds.usdExport(mergeTransformAndShape=True, exportReferenceObjects=False,
shadingMode='none', file=usdFile)
stage = Usd.Stage.Open(usdFile)
plane1Path = '/pPlane1'
plane2Path = '/pPlane2'
plane1 = UsdGeom.Mesh.Get(stage, plane1Path)
self.assertTrue(plane1.GetPrim().IsValid())
plane2 = UsdGeom.Mesh.Get(stage, plane2Path)
self.assertTrue(plane2.GetPrim().IsValid())
self.assertFalse(plane1.GetPrimvar(UsdUtils.GetPrefName()).IsDefined())
usdFile = os.path.abspath('UsdExportPref_pref.usda')
cmds.usdExport(mergeTransformAndShape=True, exportReferenceObjects=True,
shadingMode='none', file=usdFile)
stage = Usd.Stage.Open(usdFile)
plane1 = UsdGeom.Mesh.Get(stage, plane1Path)
self.assertTrue(plane1.GetPrim().IsValid())
plane2 = UsdGeom.Mesh.Get(stage, plane2Path)
self.assertTrue(plane2.GetPrim().IsValid())
self.assertTrue(plane1.GetPrimvar(UsdUtils.GetPrefName()).IsDefined())
self.assertEqual(plane1.GetPrimvar(UsdUtils.GetPrefName()).Get(), plane2.GetPointsAttr().Get())
示例7: testExportAsPoly
def testExportAsPoly(self):
usdFile = os.path.abspath('UsdExportMesh_none.usda')
cmds.usdExport(mergeTransformAndShape=True, file=usdFile,
shadingMode='none', defaultMeshScheme='none')
stage = Usd.Stage.Open(usdFile)
m = UsdGeom.Mesh.Get(stage, '/UsdExportMeshTest/unspecified')
self.assertEqual(m.GetSubdivisionSchemeAttr().Get(), UsdGeom.Tokens.none)
self.assertTrue(len(m.GetNormalsAttr().Get()) > 0)
# XXX: For some reason, when the mesh export used the getNormal()
# method on MItMeshFaceVertex, we would sometimes get incorrect normal
# values. Instead, we had to get all of the normals off of the MFnMesh
# and then use the iterator's normalId() method to do a lookup into the
# normals.
# This test ensures that we're getting correct normals. The mesh should
# only have normals in the x or z direction.
m = UsdGeom.Mesh.Get(stage, '/UsdExportMeshTest/TestNormalsMesh')
normals = m.GetNormalsAttr().Get()
self.assertTrue(normals)
for n in normals:
# we don't expect the normals to be pointed in the y-axis at all.
self.assertAlmostEqual(n[1], 0.0, delta=1e-4)
# make sure the other 2 values aren't both 0.
self.assertNotAlmostEqual(abs(n[0]) + abs(n[2]), 0.0, delta=1e-4)
示例8: testExportWithStripAndMerge
def testExportWithStripAndMerge(self):
mayaFilePath = os.path.abspath('UsdExportStripNamespaces.ma')
cmds.file(mayaFilePath, new=True, force=True)
cmds.namespace(add=":foo")
cmds.namespace(add=":bar")
node1 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(set=":foo");
node2 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube2" )
cmds.namespace(set=":bar");
node3 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube3" )
cmds.namespace(set=":");
usdFilePath = os.path.abspath('UsdExportStripNamespaces_EXPORTED.usda')
cmds.usdExport(mergeTransformAndShape=True,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
expectedPrims = ("/cube1", "/cube2", "/cube3")
for primPath in expectedPrims:
prim = stage.GetPrimAtPath(primPath)
self.assertTrue(prim.IsValid(), "Expect " + primPath)
示例9: testExportWithKindFlag
def testExportWithKindFlag(self):
"""
Tests exporting a Maya file with no USD_kind custom attributes
and using the usdExport -kind flag.
"""
cmds.file(os.path.abspath('KindTest.ma'), open=True, force=True)
cmds.loadPlugin('pxrUsd')
usdFilePath = os.path.abspath('KindTest.usda')
# Check the error mark; this ensures that we actually got a Tf error
# (that was eventually converted into a Maya error, which Maya raises
# in Python as a RuntimeError).
mark = Tf.Error.Mark()
mark.SetMark()
with self.assertRaises(RuntimeError):
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='assembly')
errors = mark.GetErrors()
self.assertEqual(len(errors), 1)
self.assertIn(
"</KindTest> has kind 'assembly', which is derived from 'assembly'",
str(errors[0]))
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='fakeKind')
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
rootPrim = stage.GetPrimAtPath('/KindTest')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
'fakeKind'))
示例10: testExportWithAssemblyAndMesh
def testExportWithAssemblyAndMesh(self):
"""
Tests exporting a Maya file with a root prim containing an assembly
and a mesh.
"""
cmds.file(os.path.abspath('KindTestAssemblyAndMesh.ma'), open=True,
force=True)
cmds.loadPlugin('pxrUsd')
# Should fail due to the mesh.
usdFilePath = os.path.abspath('KindTestAssemblyAndMesh.usda')
with self.assertRaises(RuntimeError):
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='assembly')
# Should be 'component' because of the mesh
usdFilePath = os.path.abspath('KindTestAssemblyAndMesh.usda')
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath)
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
rootPrim = stage.GetPrimAtPath('/KindTest')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
'component'))
示例11: testExportWithClashStripping
def testExportWithClashStripping(self):
mayaFilePath = os.path.abspath('UsdExportStripNamespaces.ma')
cmds.file(mayaFilePath, new=True, force=True)
node1 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(add="foo")
cmds.namespace(set="foo");
node2 = cmds.polyCube( sx=5, sy=5, sz=5, name="cube1" )
cmds.namespace(set=":");
usdFilePath = os.path.abspath('UsdExportStripNamespaces_EXPORTED.usda')
errorRegexp = "Multiple dag nodes map to the same prim path" \
".+|cube1 - |foo:cube1.*"
with self.assertRaisesRegexp(RuntimeError, errorRegexp) as cm:
cmds.usdExport(mergeTransformAndShape=True,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
with self.assertRaisesRegexp(RuntimeError,errorRegexp) as cm:
cmds.usdExport(mergeTransformAndShape=False,
selection=False,
stripNamespaces=True,
file=usdFilePath,
shadingMode='none')
示例12: testExportWithKindAttrAndKindFlag
def testExportWithKindAttrAndKindFlag(self):
"""
Tests exporting a Maya file with both USD_kind custom attributes and
using the usdExport -kind flag; there should be an error if the USD_kind
is not derived from the kind specified in the -kind flag.
"""
cmds.file(os.path.abspath('KindTestUsdKindAttr.ma'), open=True, force=True)
cmds.loadPlugin('pxrUsd')
usdFilePath = os.path.abspath('KindTestUsdKindAttr.usda')
with self.assertRaises(RuntimeError):
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='assembly')
cmds.usdExport(mergeTransformAndShape=True,
file=usdFilePath,
kind='model')
stage = Usd.Stage.Open(usdFilePath)
self.assertTrue(stage)
rootPrim = stage.GetPrimAtPath('/KindTest')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim).GetKind(),
'component'))
rootPrim2 = stage.GetPrimAtPath('/KindTest2')
self.assertTrue(Kind.Registry().IsA(Usd.ModelAPI(rootPrim2).GetKind(),
'assembly'))
示例13: testExport
def testExport(self):
'''Tests standard usdz package export.'''
usdFile = os.path.abspath('MyAwesomePackage.usdz')
cmds.usdExport(
file=usdFile,
mergeTransformAndShape=True,
shadingMode='none')
# Lets make sure that the root layer is the first file and that all
# the references were localized ok.
zipFile = Usd.ZipFile.Open(usdFile)
fileNames = zipFile.GetFileNames()
self.assertEqual(fileNames, [
"MyAwesomePackage.usd",
"ReferenceModel.usda",
"BaseModel.usda",
"card.png"
])
# Open the usdz file up to verify that everything exported properly.
stage = Usd.Stage.Open(usdFile)
self._AssertExpectedStage(stage, "./card.png")
# Make sure there's no weird temp files sitting around.
self._AssertNoTempFiles(usdFile)
示例14: testExport
def testExport(self):
"""
Tests that the adaptor mechanism can export
USD_hidden, USD_instanceable, and USD_kind attributes by setting
the correct metadata in the output USD file.
"""
cmds.file(new=True, force=True)
usdFile = os.path.abspath('UsdAttrs.usda')
cmds.usdImport(file=usdFile, shadingMode='none')
newUsdFilePath = os.path.abspath('UsdAttrsNew.usda')
cmds.usdExport(file=newUsdFilePath, shadingMode='none')
newUsdStage = Usd.Stage.Open(newUsdFilePath)
# pCube1 and pCube2 have USD_kind.
prim1 = newUsdStage.GetPrimAtPath('/World/pCube1')
self.assertEqual(Usd.ModelAPI(prim1).GetKind(), 'potato')
prim2 = newUsdStage.GetPrimAtPath('/World/pCube2')
self.assertEqual(Usd.ModelAPI(prim2).GetKind(), 'bakedpotato')
# pCube2, pCube4, and pCube5 have USD_hidden. pCube1 and pCube3 do not.
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube2').HasAuthoredHidden())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube4').HasAuthoredHidden())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube5').HasAuthoredHidden())
self.assertFalse(newUsdStage.GetPrimAtPath('/World/pCube1').HasAuthoredHidden())
self.assertFalse(newUsdStage.GetPrimAtPath('/World/pCube3').HasAuthoredHidden())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube2').IsHidden())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube4').IsHidden())
self.assertFalse(newUsdStage.GetPrimAtPath('/World/pCube5').IsHidden())
# pCube3 and pCube4 have USD_instanceable.
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube3').IsInstanceable())
self.assertTrue(newUsdStage.GetPrimAtPath('/World/pCube4').IsInstanceable())
示例15: testExportToAnonymousLayer
def testExportToAnonymousLayer(self):
"""
Tests exporting to an existing anonymous layer. In normal (non-append)
mode, this should completely overwrite the contents of the anonymous
layer.
"""
cmds.file(new=True, force=True)
cmds.polyCube(name='TestCube')
stage = Usd.Stage.CreateInMemory()
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.usdExport(
file=stage.GetRootLayer().identifier,
mergeTransformAndShape=True,
shadingMode='none')
self.assertTrue(stage.GetPrimAtPath('/TestCube').IsValid())
cmds.rename('TestCube', 'TestThing')
cmds.usdExport(
file=stage.GetRootLayer().identifier,
mergeTransformAndShape=True,
shadingMode='none')
self.assertFalse(stage.GetPrimAtPath('/TestCube').IsValid())
self.assertTrue(stage.GetPrimAtPath('/TestThing').IsValid())