Esempio n. 1
0
    def testAnimWFGSimpleNurbsCurveRW(self):

        # create the Nurbs Curve
        name = MayaCmds.curve(d=3, p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9), (12, 10, 2)], k=[0, 0, 0, 1, 2, 2, 2])

        MayaCmds.select(name + ".cv[0:4]")
        # frame 1
        MayaCmds.currentTime(1, update=True)
        MayaCmds.setKeyframe()
        # frame 24
        MayaCmds.currentTime(24, update=True)
        MayaCmds.setKeyframe()
        # frame 12
        MayaCmds.currentTime(12, update=True)
        MayaCmds.move(3, 0, 0, r=True)
        MayaCmds.setKeyframe()

        self.__files.append(util.expandFileName("testAnimWFGNurbsSingleCurve.abc"))

        MayaCmds.AbcExport(j="-fr 1 24 -wfg -frs -0.25 -frs 0.0 -frs 0.25 -root %s -file %s" % (name, self.__files[-1]))

        MayaCmds.AbcImport(self.__files[-1], mode="import")
        shapeNames = MayaCmds.ls(exactType="nurbsCurve")

        MayaCmds.currentTime(1, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
        MayaCmds.currentTime(12, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
        MayaCmds.currentTime(24, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
Esempio n. 2
0
    def testAnimNurbsCurveGrpRW(self):

        # create Nurbs Curve group
        knotVec = [0,0,0,1,2,2,2]
        curve1CV = [(0, 0, 0), (3, 5, 0), (5, 6, 0), (9, 9, 0), (12, 10, 0)]
        curve2CV = [(0, 0, 3), (3, 5, 3), (5, 6, 3), (9, 9, 3), (12, 10, 3)]
        curve3CV = [(0, 0, 6), (3, 5, 6), (5, 6, 6), (9, 9, 6), (12, 10, 6)]

        MayaCmds.curve(d=3, p=curve1CV, k=knotVec, name='curve1')
        MayaCmds.curve(d=3, p=curve2CV, k=knotVec, name='curve2')
        MayaCmds.curve(d=3, p=curve3CV, k=knotVec, name='curve3')

        MayaCmds.group('curve1', 'curve2', 'curve3', name='group')
        MayaCmds.addAttr('group', longName='riCurves', at='bool', dv=True)

        # frame 1
        MayaCmds.currentTime(1, update=True)
        MayaCmds.select('curve1.cv[0:4]', 'curve2.cv[0:4]', 'curve3.cv[0:4]', replace=True)
        MayaCmds.setKeyframe()
        # frame 24
        MayaCmds.currentTime(24, update=True)
        MayaCmds.select('curve1.cv[0:4]')
        MayaCmds.rotate(0.0, '90deg', 0.0, relative=True )
        MayaCmds.select('curve2.cv[0:4]')
        MayaCmds.move(0.0, 0.5, 0.0, relative=True )
        MayaCmds.select('curve3.cv[0:4]')
        MayaCmds.scale(1.0, 0.5, 1.0, relative=True )
        MayaCmds.select('curve1.cv[0:4]', 'curve2.cv[0:4]', 'curve3.cv[0:4]', replace=True)
        MayaCmds.setKeyframe()

        self.__files.append(util.expandFileName('testAnimNCGrp.abc'))
        self.__files.append(util.expandFileName('testAnimNCGrp01_14.abc'))
        self.__files.append(util.expandFileName('testAnimNCGrp15_24.abc'))

        MayaCmds.AbcExport(j='-fr 1 14 -root %s -file %s' % ('group', self.__files[-2]))
        MayaCmds.AbcExport(j='-fr 15 24 -root %s -file %s' % ('group', self.__files[-1]))

        # use AbcStitcher to combine two files into one
        subprocess.call(self.__abcStitcher + self.__files[-3:])

        # reading test
        MayaCmds.AbcImport(self.__files[-3], mode='import')
        shapeNames = MayaCmds.ls(exactType='nurbsCurve')

        MayaCmds.currentTime(1, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i+3]))
        MayaCmds.currentTime(12, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i+3]))
        MayaCmds.currentTime(24, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i+3]))
Esempio n. 3
0
    def testAnimNurbsCurveGrpRW(self):

        # create Nurbs Curve group
        knotVec = [0, 0, 0, 1, 2, 2, 2]
        curve1CV = [(0, 0, 0), (3, 5, 0), (5, 6, 0), (9, 9, 0), (12, 10, 0)]
        curve2CV = [(0, 0, 3), (3, 5, 3), (5, 6, 3), (9, 9, 3), (12, 10, 3)]
        curve3CV = [(0, 0, 6), (3, 5, 6), (5, 6, 6), (9, 9, 6), (12, 10, 6)]

        MayaCmds.curve(d=3, p=curve1CV, k=knotVec, name="curve1")
        MayaCmds.curve(d=3, p=curve2CV, k=knotVec, name="curve2")
        MayaCmds.curve(d=3, p=curve3CV, k=knotVec, name="curve3")

        MayaCmds.group("curve1", "curve2", "curve3", name="group")
        MayaCmds.addAttr("group", longName="riCurves", at="bool", dv=True)

        # frame 1
        MayaCmds.currentTime(1, update=True)
        MayaCmds.select("curve1.cv[0:4]", "curve2.cv[0:4]", "curve3.cv[0:4]", replace=True)
        MayaCmds.setKeyframe()
        # frame 24
        MayaCmds.currentTime(24, update=True)
        MayaCmds.select("curve1.cv[0:4]")
        MayaCmds.rotate(0.0, "90deg", 0.0, relative=True)
        MayaCmds.select("curve2.cv[0:4]")
        MayaCmds.move(0.0, 0.5, 0.0, relative=True)
        MayaCmds.select("curve3.cv[0:4]")
        MayaCmds.scale(1.0, 0.5, 1.0, relative=True)
        MayaCmds.select("curve1.cv[0:4]", "curve2.cv[0:4]", "curve3.cv[0:4]", replace=True)
        MayaCmds.setKeyframe()

        self.__files.append(util.expandFileName("testAnimNCGrp.abc"))
        self.__files.append(util.expandFileName("testAnimNCGrp01_14.abc"))
        self.__files.append(util.expandFileName("testAnimNCGrp15_24.abc"))

        MayaCmds.AbcExport(j="-fr 1 14 -root %s -file %s" % ("group", self.__files[-2]))
        MayaCmds.AbcExport(j="-fr 15 24 -root %s -file %s" % ("group", self.__files[-1]))

        # use AbcStitcher to combine two files into one
        subprocess.call(self.__abcStitcher + self.__files[-3:])

        # reading test
        MayaCmds.AbcImport(self.__files[-3], mode="import")
        shapeNames = MayaCmds.ls(exactType="nurbsCurve")

        MayaCmds.currentTime(1, update=True)
        for i in range(0, 3):
            self.failUnless(util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
        MayaCmds.currentTime(12, update=True)
        for i in range(0, 3):
            self.failUnless(util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
        MayaCmds.currentTime(24, update=True)
        for i in range(0, 3):
            self.failUnless(util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
    def testAnimSimpleNurbsCurveRW(self):

        # create the Nurbs Curve
        name = MayaCmds.curve(d=3,
                              p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9),
                                 (12, 10, 2)],
                              k=[0, 0, 0, 1, 2, 2, 2])

        MayaCmds.select(name + '.cv[0:4]')
        # frame 1
        MayaCmds.currentTime(1, update=True)
        MayaCmds.setKeyframe()
        # frame 24
        MayaCmds.currentTime(24, update=True)
        MayaCmds.setKeyframe()
        # frame 12
        MayaCmds.currentTime(12, update=True)
        MayaCmds.move(3, 0, 0, r=True)
        MayaCmds.setKeyframe()

        self.__files.append(
            util.expandFileName('testAnimNurbsSingleCurve.abc'))
        self.__files.append(
            util.expandFileName('testAnimNurbsSingleCurve01_14.abc'))
        self.__files.append(
            util.expandFileName('testAnimNurbsSingleCurve15_24.abc'))

        MayaCmds.AbcExport(j='-fr 1 14 -root %s -file %s' %
                           (name, self.__files[-2]))
        MayaCmds.AbcExport(j='-fr 15 24 -root %s -file %s' %
                           (name, self.__files[-1]))

        # use AbcStitcher to combine two files into one
        subprocess.call(self.__abcStitcher + self.__files[-3:])

        MayaCmds.AbcImport(self.__files[-3], mode='import')
        shapeNames = MayaCmds.ls(exactType='nurbsCurve')

        MayaCmds.currentTime(1, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
        MayaCmds.currentTime(12, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
        MayaCmds.currentTime(24, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
Esempio n. 5
0
    def testNurbsSingleCurveReadWrite(self):

        name = MayaCmds.curve(d=3, p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9), (12, 10, 2)], k=[0, 0, 0, 1, 2, 2, 2])
        self.__files.append(util.expandFileName("testStaticNurbsSingleCurve.abc"))
        MayaCmds.AbcExport(j="-root %s -f %s" % (name, self.__files[-1]))

        # reading test
        MayaCmds.AbcImport(self.__files[-1], mode="import")
        shapeNames = MayaCmds.ls(exactType="nurbsCurve")
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
Esempio n. 6
0
    def testNurbsSingleCurveReadWrite(self):

        name = MayaCmds.curve(d=3,
                              p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9),
                                 (12, 10, 2)],
                              k=[0, 0, 0, 1, 2, 2, 2])
        self.__files.append(
            util.expandFileName('testStaticNurbsSingleCurve.abc'))
        MayaCmds.AbcExport(j='-root %s -f %s' % (name, self.__files[-1]))

        # reading test
        MayaCmds.AbcImport(self.__files[-1], mode='import')
        shapeNames = MayaCmds.ls(exactType='nurbsCurve')
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
Esempio n. 7
0
    def testAnimSimpleNurbsCurveRW(self):

        # create the Nurbs Curve
        name = MayaCmds.curve( d=3, p=[(0, 0, 0), (3, 5, 6), (5, 6, 7),
            (9, 9, 9), (12, 10, 2)], k=[0,0,0,1,2,2,2] )

        MayaCmds.select(name+'.cv[0:4]')
        # frame 1
        MayaCmds.currentTime(1, update=True)
        MayaCmds.setKeyframe()
        # frame 24
        MayaCmds.currentTime(24, update=True)
        MayaCmds.setKeyframe()
        # frame 12
        MayaCmds.currentTime(12, update=True)
        MayaCmds.move(3, 0, 0, r=True)
        MayaCmds.setKeyframe()

        self.__files.append(util.expandFileName('testAnimNurbsSingleCurve.abc'))
        self.__files.append(util.expandFileName('testAnimNurbsSingleCurve01_14.abc'))
        self.__files.append(util.expandFileName('testAnimNurbsSingleCurve15_24.abc'))

        MayaCmds.AbcExport(j='-fr 1 14 -root %s -file %s' % (name, self.__files[-2]))
        MayaCmds.AbcExport(j='-fr 15 24 -root %s -file %s' % (name, self.__files[-1]))

        # use AbcStitcher to combine two files into one
        subprocess.call(self.__abcStitcher + self.__files[-3:])

        MayaCmds.AbcImport(self.__files[-3], mode='import')
        shapeNames = MayaCmds.ls(exactType='nurbsCurve')

        MayaCmds.currentTime(1, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
        MayaCmds.currentTime(12, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
        MayaCmds.currentTime(24, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
    def testAnimWFGSimpleNurbsCurveRW(self):

        # create the Nurbs Curve
        name = MayaCmds.curve(d=3,
                              p=[(0, 0, 0), (3, 5, 6), (5, 6, 7), (9, 9, 9),
                                 (12, 10, 2)],
                              k=[0, 0, 0, 1, 2, 2, 2])

        MayaCmds.select(name + '.cv[0:4]')
        # frame 1
        MayaCmds.currentTime(1, update=True)
        MayaCmds.setKeyframe()
        # frame 24
        MayaCmds.currentTime(24, update=True)
        MayaCmds.setKeyframe()
        # frame 12
        MayaCmds.currentTime(12, update=True)
        MayaCmds.move(3, 0, 0, r=True)
        MayaCmds.setKeyframe()

        self.__files.append(
            util.expandFileName('testAnimWFGNurbsSingleCurve.abc'))

        MayaCmds.AbcExport(
            j='-fr 1 24 -wfg -frs -0.25 -frs 0.0 -frs 0.25 -root %s -file %s' %
            (name, self.__files[-1]))

        MayaCmds.AbcImport(self.__files[-1], mode='import')
        shapeNames = MayaCmds.ls(exactType='nurbsCurve')

        MayaCmds.currentTime(1, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
        MayaCmds.currentTime(12, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
        MayaCmds.currentTime(24, update=True)
        self.failUnless(util.compareNurbsCurve(shapeNames[0], shapeNames[1]))
    def testAnimNurbsCurveGrpRW(self):

        # create Nurbs Curve group
        knotVec = [0, 0, 0, 1, 2, 2, 2]
        curve1CV = [(0, 0, 0), (3, 5, 0), (5, 6, 0), (9, 9, 0), (12, 10, 0)]
        curve2CV = [(0, 0, 3), (3, 5, 3), (5, 6, 3), (9, 9, 3), (12, 10, 3)]
        curve3CV = [(0, 0, 6), (3, 5, 6), (5, 6, 6), (9, 9, 6), (12, 10, 6)]

        MayaCmds.curve(d=3, p=curve1CV, k=knotVec, name='curve1')
        MayaCmds.curve(d=3, p=curve2CV, k=knotVec, name='curve2')
        MayaCmds.curve(d=3, p=curve3CV, k=knotVec, name='curve3')

        MayaCmds.group('curve1', 'curve2', 'curve3', name='group')
        MayaCmds.addAttr('group', longName='riCurves', at='bool', dv=True)

        # frame 1
        MayaCmds.currentTime(1, update=True)
        MayaCmds.select('curve1.cv[0:4]',
                        'curve2.cv[0:4]',
                        'curve3.cv[0:4]',
                        replace=True)
        MayaCmds.setKeyframe()
        # frame 24
        MayaCmds.currentTime(24, update=True)
        MayaCmds.select('curve1.cv[0:4]')
        MayaCmds.rotate(0.0, '90deg', 0.0, relative=True)
        MayaCmds.select('curve2.cv[0:4]')
        MayaCmds.move(0.0, 0.5, 0.0, relative=True)
        MayaCmds.select('curve3.cv[0:4]')
        MayaCmds.scale(1.0, 0.5, 1.0, relative=True)
        MayaCmds.select('curve1.cv[0:4]',
                        'curve2.cv[0:4]',
                        'curve3.cv[0:4]',
                        replace=True)
        MayaCmds.setKeyframe()

        self.__files.append(util.expandFileName('testAnimNCGrp.abc'))
        self.__files.append(util.expandFileName('testAnimNCGrp01_14.abc'))
        self.__files.append(util.expandFileName('testAnimNCGrp15_24.abc'))

        MayaCmds.AbcExport(j='-fr 1 14 -root %s -file %s' %
                           ('group', self.__files[-2]))
        MayaCmds.AbcExport(j='-fr 15 24 -root %s -file %s' %
                           ('group', self.__files[-1]))

        # use AbcStitcher to combine two files into one
        subprocess.call(self.__abcStitcher + self.__files[-3:])

        # reading test
        MayaCmds.AbcImport(self.__files[-3], mode='import')
        shapeNames = MayaCmds.ls(exactType='nurbsCurve')

        MayaCmds.currentTime(1, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
        MayaCmds.currentTime(12, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
        MayaCmds.currentTime(24, update=True)
        for i in range(0, 3):
            self.failUnless(
                util.compareNurbsCurve(shapeNames[i], shapeNames[i + 3]))
    def testAnimNCurveGrpDeleteReload(self):

        # create an animated curves group
        MayaCmds.textCurves(ch=False, t='haka', name='Curves', font='Courier')
        MayaCmds.addAttr(longName='riCurves', at='bool', dv=True)
        MayaCmds.currentTime(1, update=True)
        MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]',
            'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]',
            'curve6.cv[0:15]', replace=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(24, update=True)
        MayaCmds.select('curve1.cv[0:27]', replace=True)
        MayaCmds.move(-3, 3, 0, relative=True)
        MayaCmds.select('curve2.cv[0:45]', 'curve3.cv[0:15]', replace=True)
        MayaCmds.scale(1.5, 1.5, 1.5, relative=True)
        MayaCmds.select('curve4.cv[0:19]', replace=True)
        MayaCmds.move(1.5, 0, 0, relative=True)
        MayaCmds.rotate(0, 90, 0, relative=True)
        MayaCmds.select('curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True)
        MayaCmds.move(3, 0, 0, relative=True)
        MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]',
            'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]',
            'curve6.cv[0:15]', replace=True)
        MayaCmds.setKeyframe()

        # write them out to an Abc file and load back in
        self.__files.append(util.expandFileName('testNCurveGrpReload.abc'))
        MayaCmds.AbcExport(j='-fr 1 24 -root CurvesShape -file ' + self.__files[-1])

        # load back the Abc file, delete the 2nd letter and save to a maya file
        MayaCmds.AbcImport(self.__files[-1], mode='open')

        # delete letter "a" which has two curves, but as a curve group.
        # the curve shapes are renamed under the group node
        MayaCmds.delete('CurvesShape1')
        MayaCmds.delete('CurvesShape2')
        self.__files.append(util.expandFileName('testCurves.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # import the saved maya file to compare with the original scene
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.select('|CurvesShape', replace=True)
        MayaCmds.group(name='ReloadGrp')
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        curveList = MayaCmds.ls(type='nurbsCurve')
        self.failUnlessEqual(len(curveList), 10)

        curves = [('|CurvesShape|CurvesShape',
            '|ReloadGrp|CurvesShape|CurvesShape'),
            ('|CurvesShape|CurvesShape8',
            '|ReloadGrp|CurvesShape|CurvesShape3'),
            ('|CurvesShape|CurvesShape9',
            '|ReloadGrp|CurvesShape|CurvesShape4'),
            ('|CurvesShape|CurvesShape10',
            '|ReloadGrp|CurvesShape|CurvesShape5')]
        for c in curves:
            for t in range(1, 25):
                MayaCmds.currentTime(t, update=True)
                if not util.compareNurbsCurve(c[0], c[1]):
                    self.fail('%s and %s are not the same at frame %d' %
                        (c[0], c[1], t))
    def testAnimNCurvesDeleteReload(self):

        # create some animated curves
        MayaCmds.textCurves(ch=False, t='Maya', name='Curves', font='Courier')
        MayaCmds.currentTime(1, update=True)
        MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]',
            'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]',
            'curve6.cv[0:15]', replace=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(24, update=True)
        MayaCmds.select('curve1.cv[0:27]', replace=True)
        MayaCmds.move(-3, 3, 0, relative=True)
        MayaCmds.select('curve2.cv[0:45]', 'curve3.cv[0:15]', replace=True)
        MayaCmds.scale(1.5, 1.5, 1.5, relative=True)
        MayaCmds.select('curve4.cv[0:19]', replace=True)
        MayaCmds.move(1.5, 0, 0, relative=True)
        MayaCmds.rotate(0, 90, 0, relative=True)
        MayaCmds.select('curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True)
        MayaCmds.move(3, 0, 0, relative=True)
        MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]',
            'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]',
            'curve6.cv[0:15]', replace=True)
        MayaCmds.setKeyframe()

        # write them out to an Abc file and load back in
        self.__files.append(util.expandFileName('testNCurvesReload.abc'))
        MayaCmds.AbcExport(j='-fr 1 24 -root CurvesShape -file ' + self.__files[-1])

        # load back the Abc file, delete the 2nd letter and save to a maya file
        MayaCmds.AbcImport(self.__files[-1], mode='open')

        # delete letter "a" which has two curves
        MayaCmds.delete('Char_a_1')
        self.__files.append(util.expandFileName('test.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # import the saved maya file to compare with the original scene
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.select('CurvesShape', replace=True)
        MayaCmds.group(name='ReloadGrp')
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        curveList = MayaCmds.ls(type='nurbsCurve')
        self.failUnlessEqual(len(curveList), 10)

        # test the equality of curves
        curves = [('|CurvesShape|Char_M_1|curve1|curveShape1',
            '|ReloadGrp|CurvesShape|Char_M_1|curve1|curveShape1'),
            ('|CurvesShape|Char_y_1|curve4|curveShape4',
            '|ReloadGrp|CurvesShape|Char_y_1|curve4|curveShape4'),
            ('|CurvesShape|Char_a_2|curve5|curveShape5',
            '|ReloadGrp|CurvesShape|Char_a_2|curve5|curveShape5'),
            ('|CurvesShape|Char_a_2|curve6|curveShape6',
            '|ReloadGrp|CurvesShape|Char_a_2|curve6|curveShape6')]
        for c in curves:
            for t in range(1, 25):
                MayaCmds.currentTime(t, update=True)
                if not util.compareNurbsCurve(c[0], c[1]):
                    self.fail('%s and %s are not the same at frame %d' %
                        (c[0], c[1], t))
Esempio n. 12
0
    def testAnimNCurveGrpDeleteReload(self):

        # create an animated curves group
        MayaCmds.textCurves(ch=False, t='haka', name='Curves', font='Courier')
        MayaCmds.addAttr(longName='riCurves', at='bool', dv=True)
        MayaCmds.currentTime(1, update=True)
        MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]',
            'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]',
            'curve6.cv[0:15]', replace=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(24, update=True)
        MayaCmds.select('curve1.cv[0:27]', replace=True)
        MayaCmds.move(-3, 3, 0, relative=True)
        MayaCmds.select('curve2.cv[0:45]', 'curve3.cv[0:15]', replace=True)
        MayaCmds.scale(1.5, 1.5, 1.5, relative=True)
        MayaCmds.select('curve4.cv[0:19]', replace=True)
        MayaCmds.move(1.5, 0, 0, relative=True)
        MayaCmds.rotate(0, 90, 0, relative=True)
        MayaCmds.select('curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True)
        MayaCmds.move(3, 0, 0, relative=True)
        MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]',
            'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]',
            'curve6.cv[0:15]', replace=True)
        MayaCmds.setKeyframe()

        # write them out to an Abc file and load back in
        self.__files.append(util.expandFileName('testNCurveGrpReload.abc'))
        MayaCmds.AbcExport(j='-fr 1 24 -root CurvesShape -file ' + self.__files[-1])

        # load back the Abc file, delete the 2nd letter and save to a maya file
        MayaCmds.AbcImport(self.__files[-1], mode='open')

        # delete letter "a" which has two curves, but as a curve group.
        # the curve shapes are renamed under the group node
        MayaCmds.delete('CurvesShape1')
        MayaCmds.delete('CurvesShape2')
        self.__files.append(util.expandFileName('testCurves.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # import the saved maya file to compare with the original scene
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.select('|CurvesShape', replace=True)
        MayaCmds.group(name='ReloadGrp')
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        curveList = MayaCmds.ls(type='nurbsCurve')
        self.failUnlessEqual(len(curveList), 10)

        curves = [('|CurvesShape|CurvesShape',
            '|ReloadGrp|CurvesShape|CurvesShape'),
            ('|CurvesShape|CurvesShape8',
            '|ReloadGrp|CurvesShape|CurvesShape3'),
            ('|CurvesShape|CurvesShape9',
            '|ReloadGrp|CurvesShape|CurvesShape4'),
            ('|CurvesShape|CurvesShape10',
            '|ReloadGrp|CurvesShape|CurvesShape5')]
        for c in curves:
            for t in range(1, 25):
                MayaCmds.currentTime(t, update=True)
                if not util.compareNurbsCurve(c[0], c[1]):
                    self.fail('%s and %s are not the same at frame %d' % 
                        (c[0], c[1], t))
Esempio n. 13
0
    def testAnimNCurvesDeleteReload(self):

        # create some animated curves
        MayaCmds.textCurves(ch=False, t='Maya', name='Curves', font='Courier')
        MayaCmds.currentTime(1, update=True)
        MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]',
            'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]',
            'curve6.cv[0:15]', replace=True)
        MayaCmds.setKeyframe()
        MayaCmds.currentTime(24, update=True)
        MayaCmds.select('curve1.cv[0:27]', replace=True)
        MayaCmds.move(-3, 3, 0, relative=True)
        MayaCmds.select('curve2.cv[0:45]', 'curve3.cv[0:15]', replace=True)
        MayaCmds.scale(1.5, 1.5, 1.5, relative=True)
        MayaCmds.select('curve4.cv[0:19]', replace=True)
        MayaCmds.move(1.5, 0, 0, relative=True)
        MayaCmds.rotate(0, 90, 0, relative=True)
        MayaCmds.select('curve5.cv[0:45]', 'curve6.cv[0:15]', replace=True)
        MayaCmds.move(3, 0, 0, relative=True)
        MayaCmds.select('curve1.cv[0:27]', 'curve2.cv[0:45]',
            'curve3.cv[0:15]', 'curve4.cv[0:19]', 'curve5.cv[0:45]',
            'curve6.cv[0:15]', replace=True)
        MayaCmds.setKeyframe()

        # write them out to an Abc file and load back in
        self.__files.append(util.expandFileName('testNCurvesReload.abc'))
        MayaCmds.AbcExport(j='-fr 1 24 -root CurvesShape -file ' + self.__files[-1])

        # load back the Abc file, delete the 2nd letter and save to a maya file
        MayaCmds.AbcImport(self.__files[-1], mode='open')

        # delete letter "a" which has two curves
        MayaCmds.delete('Char_a_1')
        self.__files.append(util.expandFileName('test.mb'))
        MayaCmds.file(rename=self.__files[-1])
        MayaCmds.file(save=True)

        # import the saved maya file to compare with the original scene
        MayaCmds.file(self.__files[-1], open=True)
        MayaCmds.select('CurvesShape', replace=True)
        MayaCmds.group(name='ReloadGrp')
        MayaCmds.AbcImport(self.__files[-2], mode='import')

        curveList = MayaCmds.ls(type='nurbsCurve')
        self.failUnlessEqual(len(curveList), 10)

        # test the equality of curves
        curves = [('|CurvesShape|Char_M_1|curve1|curveShape1',
            '|ReloadGrp|CurvesShape|Char_M_1|curve1|curveShape1'),
            ('|CurvesShape|Char_y_1|curve4|curveShape4',
            '|ReloadGrp|CurvesShape|Char_y_1|curve4|curveShape4'),
            ('|CurvesShape|Char_a_2|curve5|curveShape5',
            '|ReloadGrp|CurvesShape|Char_a_2|curve5|curveShape5'),
            ('|CurvesShape|Char_a_2|curve6|curveShape6',
            '|ReloadGrp|CurvesShape|Char_a_2|curve6|curveShape6')]
        for c in curves:
            for t in range(1, 25):
                MayaCmds.currentTime(t, update=True)
                if not util.compareNurbsCurve(c[0], c[1]):
                    self.fail('%s and %s are not the same at frame %d' % 
                        (c[0], c[1], t))