I am trying to tweak from a current script file, and as far as I know, when 
the plugin is loaded, user will just need to select the camera they would 
like to export (File>>Export selection) with format from the plugin -chan.

I will not be posting all the code, but the portions that are affilated 
with this exporting code. Hopefully it helps?

class customNodeTranslator(OpenMayaMPx.MPxFileTranslator):
    def __init__(self):
        OpenMayaMPx.MPxFileTranslator.__init__(self)
    def haveWriteMethod(self):
        return True
    def haveReadMethod(self):
        return True
    def filter(self):
        return "*.chan"
    def defaultExtension(self):
        return "chan"
    def writer( self, fileObject, optionString, accessMode ):
        try:
            fullName = fileObject.fullName()
            fileHandle = open(fullName,"w")


            selectList = OpenMaya.MSelectionList()
    
            OpenMaya.MGlobal.getActiveSelectionList(selectList)
            node = OpenMaya.MObject()
            depFn = OpenMaya.MFnDependencyNode()
            path = OpenMaya.MDagPath()
            iterator = OpenMaya.MItSelectionList(selectList)
            
            animationTime = OpenMayaAnim.MAnimControl()
            
            maxTime = int(animationTime.maxTime().value())
            minTime = int(animationTime.minTime().value())
            
            
            while (iterator.isDone() == 0):
                
                
                iterator.getDependNode(node)
                
                depFn.setObject(node)
                
                iterator.getDagPath(path, node)
                
                cameraObject = OpenMaya.MFnCamera(path)
                
                transform = OpenMaya.MFnTransform(path)
                
                chanMe = fileExporter(transform, minTime, maxTime, 
cameraObject)
                ...

                ...


class fileExporter():
    """ module for exporting chan files from application. arguments: 
object, startFrame, endFrame """


    fileExport = []


    def __init__(self, transform, startAnimation, endAnimation, cameraObj):


        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))


    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/3ce88cb8-1fc9-4fab-ac69-cc40c143466c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to