Esempio n. 1
0
    def testDirectionalLight_TranslateRoundTrip(self):
        # setup scene with directional light

        # Create directional light in Maya and export a .usda file
        mel.eval('defaultDirectionalLight(3, 1,1,0, "0", 0,0,0, 0)')
        mc.setAttr('directionalLightShape1.lightAngle', 0.25)
        mc.setAttr('directionalLightShape1.pw', 6, 7, 8)
        tempFile = tempfile.NamedTemporaryFile(
            suffix=".usda",
            prefix="test_DirectionalLightTranslator_",
            delete=False)
        tempFile.close()

        mc.AL_usdmaya_ExportCommand(file=tempFile.name)

        # clear scene
        mc.file(f=True, new=True)

        # import file back
        mc.AL_usdmaya_ProxyShapeImport(file=tempFile.name)
        self.assertEqual(0.25, mc.getAttr('directionalLightShape1.lightAngle'))
        self.assertEqual((1.0, 1.0, 0),
                         mc.getAttr('directionalLightShape1.color')[0])
        self.assertEqual(3, mc.getAttr('directionalLightShape1.intensity'))
        self.assertEqual((6.0, 7.0, 8.0),
                         mc.getAttr('directionalLightShape1.pointWorld')[0])

        os.remove(tempFile.name)
Esempio n. 2
0
    def testNurbsCurve_curve_width_float_export(self):
        expectedWidths = 1.
        mc.CreateNURBSCircle()
        mc.select("nurbsCircleShape1")
        mc.addAttr(longName="width", at="float")
        mc.setAttr("nurbsCircleShape1.width", expectedWidths)
        self.assertEqual(mc.getAttr("nurbsCircleShape1.width"), expectedWidths)

        tempFile = tempfile.NamedTemporaryFile(
            suffix=".usda",
            prefix="testNurbsCurve_curve_width_float_export",
            delete=False)
        tempFile.close()

        mc.AL_usdmaya_ExportCommand(file=tempFile.name)
        stage = Usd.Stage.Open(tempFile.name)
        prim = stage.GetPrimAtPath("/nurbsCircle1")
        nurbPrim = UsdGeom.NurbsCurves(prim)

        assert (nurbPrim.GetWidthsAttr())
        actualWidths = nurbPrim.GetWidthsAttr().Get()
        self.assertTrue(actualWidths)
        sure = any([a == b for a, b in zip([expectedWidths], actualWidths)])
        self.assertTrue(sure)

        os.remove(tempFile.name)