Oh ok. This make a little more sense now. I can see that your fileExporter is a completely custom class and has nothing to do with the actual plugin class. What you probably want to do is to move your logic that is in your __init__ into another method. Your writer plugin can then create an instance of the FileExplorer, and have it show the UI. Then it can take the values from the UI and call another method that actually does the work. Your constructor shouldn't be doing all the work.
On Thu, Oct 16, 2014 at 2:22 AM, likage <[email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/python_inside_maya/3ce88cb8-1fc9-4fab-ac69-cc40c143466c%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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/CAPGFgA0bzgNFa4EVWLR0-MU2Hpd3JMuO1KmpKM7xTvmZ0%3DaEcQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
