I have kind of manage to get it to work. 
This is actually an exporting object plugin but I have got 2 problems.
1. My initial window aren't popping up when I select my object >> File >> 
Export selection
2. Based on the selection, will it be possible for me to grab the different 
values based on the menu selection and used it in my __init__ function?



def __init__(self, transform, startAnimation, endAnimation, cameraObj):
        
        self.fileExport = []
        self.initialWindow()
        
        mayaGlobal = OpenMaya.MGlobal()
        mayaGlobal.viewFrame(OpenMaya.MTime(1))

        for i in range(startAnimation, (endAnimation + 1)):

            focalLength = cameraObj.focalLength()
            
            vFilmApp = cameraObj.verticalFilmAperture()

            focalOut = 2* math.degrees(math.atan(vFilmApp * 25.4/ (2* 
focalLength)))

            myEuler = OpenMaya.MEulerRotation()
            spc = OpenMaya.MSpace.kWorld

            trans = transform.getTranslation(spc)

            rotation = transform.getRotation(myEuler)
            rotVector = OpenMaya.MVector(myEuler.asVector())

            self.fileExport.append((str(i) + '\t' + str(trans[0]) + "\t" + 
str(trans[1]) + "\t" + str(trans[2]) + "\t" + str(math.degrees(rotVector[0
])) + "\t" + str(math.degrees(rotVector[1])) + "\t" + str(math.degrees(
rotVector[2])) + "\t" + str(focalOut) + "\n"))

            mayaGlobal.viewFrame(OpenMaya.MTime(i+1))
            
            
    def optionMenuCallback(*args):
        fn = cmds.menuItem (args[0], q=True, c=True)
        if fn:
            fn()

    def menu1Callback():
        print 'menu 1 fired'
        startAnimation = cmds.playbackOptions(query=True, minTime=True)
        endAnimation = cmds.playbackOptions(query=True, maxTime=True)

    def menu2Callback():
        print 'menu 2 fired'
        startAnimation = cmds.findKeyframe(which='first')
        endAnimation = cmds.findKeyframe(which='last')


    def initialWindow(self, *args):
        w = cmds.window(w=150, h=100, title = "Export Selection" )
        cmds.columnLayout(adjustableColumn=True)
        form = cmds.formLayout(numberOfDivisions=100)
        exportSelection = cmds.optionMenuGrp(label='example', cc=
optionMenuCallback)
        test1 = cmds.menuItem('item1', c = menu1Callback)
        test1 = cmds.menuItem('item2', c= menu2Callback)
        cmds.showWindow(w)

    def __call__(self):
        return self.fileExport


-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/c63319d6-8853-41be-9277-560018daf3f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to