def testMesh_testTranslateOn(self): """ Test that by default that the the mesh is imported """ # setup scene with sphere translatortestutils.importStageWithSphere() # force the import mc.AL_usdmaya_TranslatePrim(ip="/pSphere1", fi=True, proxy="AL_usdmaya_Proxy") self.assertTrue(len(mc.ls('pSphere1'))) self.assertEqual(len(mc.ls(type='mesh')), 1)
def testMeshTranslator_multipleTranslations(self): path = tempfile.NamedTemporaryFile(suffix=".usda", prefix="test_MeshTranslator_multipleTranslations_", delete=True) d = translatortestutils.importStageWithSphere('AL_usdmaya_Proxy') sessionLayer = d.stage.GetSessionLayer() d.stage.SetEditTarget(sessionLayer) spherePrimPath = "/"+d.sphereXformName offsetAmount = Gf.Vec3f(0,0.25,0) vertPoint = '{}.vtx[0]'.format(d.sphereXformName) spherePrimMesh = UsdGeom.Mesh.Get(d.stage, spherePrimPath) # Test import,modify,teardown a bunch of times for i in xrange(3): # Determine expected result expectedPoint = spherePrimMesh.GetPointsAttr().Get()[0] + offsetAmount # Translate the prim into maya for editing mc.AL_usdmaya_TranslatePrim(forceImport=True, importPaths=spherePrimPath, proxy='AL_usdmaya_Proxy') # Move the point items = ['pSphere1.vtx[0]'] mc.move(offsetAmount[0], offsetAmount[1], offsetAmount[2], items, relative=True) # just affect the Y mc.AL_usdmaya_TranslatePrim(teardownPaths=spherePrimPath, proxy='AL_usdmaya_Proxy') actualPoint = spherePrimMesh.GetPointsAttr().Get()[0] # Confirm that the edit has come back as expected self.assertAlmostEqual(actualPoint[0], expectedPoint[0]) self.assertAlmostEqual(actualPoint[1], expectedPoint[1]) self.assertAlmostEqual(actualPoint[2], expectedPoint[2])
def testMesh_PretearDownEditTargetWrite(self): """ Simple test to determine if the edit target gets written to preteardown """ # force the import d = translatortestutils.importStageWithSphere() stage = d.stage mc.AL_usdmaya_TranslatePrim(ip="/pSphere1", fi=True, proxy="AL_usdmaya_Proxy") stage.SetEditTarget(stage.GetSessionLayer()) # Delete some faces mc.select("pSphere1.f[0:399]", r=True) mc.select("pSphere1.f[0]", d=True) mc.delete() preSession = stage.GetEditTarget().GetLayer().ExportToString(); mc.AL_usdmaya_TranslatePrim(tp="/pSphere1", proxy="AL_usdmaya_Proxy") postSession = stage.GetEditTarget().GetLayer().ExportToString() # Ensure data has been written sessionStage = Usd.Stage.Open(stage.GetEditTarget().GetLayer()) sessionSphere = sessionStage.GetPrimAtPath("/pSphere1") self.assertTrue(sessionSphere.IsValid()) self.assertTrue(sessionSphere.GetAttribute("faceVertexCounts"))