I am stuck with this and I really need to figure this out
I used the subprocess method and got somewhat closer to what I am looking for, I implemented the readFile() method to read san_telus_pan_v009.ma which gets read by readMayaFile.py via mayapy interpreter but the getcams function in it doesnt return a value that I can capture by subprocss
def readFile(self):
## call to readMayaFile.py using mayapy.exe interpreter
fileToOpen="I:/scenes/[san_telus_pan_v009.ma](http://san_telus_pan_v009.ma)"
code_str = \
"""
import readMayaFile
readMayaFile.getCams('"""+fileToOpen+"""')
"""
# save the code
phile=os.path.join(os.path.split(__file__)[0],"test.py")
filename=phile
fout = open(filename, "w")
fout.write(code_str)
fout.close()
# execute the code with mayapy and pipe the result to a string
#mayapy="D:/Program Files/Autodesk/Maya2013/bin/mayapy.exe"
#the path D:/Program Files/Autodesk/Maya2013/bin/ must be added to sys path environment variables
test = "mayapy " + filename
process = subprocess.Popen(test, shell=True, stdout=subprocess.PIPE)
process.wait()
print process.returncode,"<" # 0 = success, optional check
# read the result to a string
strRead = process.stdout.read()
print strRead
after I click QPushButton the above slot is executinf and i get the following result in Command prompt
E:\Dropbox\Rnd\myprojects\Batch>ipython RenderUI.py
File read in 0 seconds.
0 <
[u’frontShape’, u’perspShape’, u’sideShape’, u’topShape’]
but the above valuse got printed should also be returned by the getCams function in readMayaFile.py
#mapay interprer file
import os
import maya.standalone
import maya.cmds as cmds
def getCams(phileToOpen):
maya.standalone.initialize(name='python')
cmds.file(phileToOpen, force=True,open=True)
cams=[cmds.ls](http://cmds.ls)(type="camera")
print cams
return cams
do I have to change something in readMayaFile.py to return the value to subprocess or do I need to change some thing in the actual slot( readFile() ) ?