Hi I'm having a similar situation. In my case I import obj files and apply materials but running it with mayapy it can't find the shading group of each material which has the same name as the material ie: BlueGlass and BlueGlassSG.
On Tuesday, 12 May 2009 03:53:20 UTC+10, Sylvain Berger wrote: > > I manage to do this... it is a bit complex to explain, so i'll try my best. > > 1. Create a command calling mayapy.exe -m <script to run> <arguments> > 2. Create the script you are calling with mayapy.exe, in this script you > can grab the arguments sent to the script using sys.argv > example: > import sys > # store the arguments in variables > argument1 = sys.argv[1] > argument2 = sys.argv[2] > etc. > > 3. call the mayapy.exe command using subprocess. Here is part of my > script... Note that I am capturing the stdout and stderr of mayaPy so I can > diagnose problem more easily... you don't have to capture them. > > import subprocess > cmdAndArgs = 'mayapy.exe -m mayaPy.avol.batchExportInit > '+objExportedScene+' '+avolObj.NodeName+' '+camExportedScene+' > '+str(createPreviewRender) > tempFolder = os.path.dirname(objExportedScene) > # Create log file > sdtoutFile = r'%s\stdout.txt' %tempFolder > stderrFile = r'%s\sterr.txt' %tempFolder > outptr = file(sdtoutFile, 'w') > errptr = file(stderrFile, 'w') > # Call the subprocess using convenience method > startupinfo = subprocess.STARTUPINFO() > startupinfo.dwFlags = subprocess.STARTF_USESHOWWINDOW > retval = subprocess.call(cmdAndArgs, startupinfo=startupinfo, bufsize=0, > executable=None, stdin=None, stdout=outptr, stderr=errptr) > # Close log handles > errptr.close() > outptr.close() > > > This works fine for me... From maya I am exporting an object, I start a > maya in background using mayapy.exe, I cleanup the object, save it, etc. > In my case maya is loked because I am waiting for the stdout of the > subprocess, but if you send the process and don't wait for it, maya should > be free. > > Hope this helps > > On Sat, May 9, 2009 at 9:53 PM, sRheinfrank <[email protected] > <javascript:>> wrote: > >> >> Hi---I want to be able to capture arguments from a UI in a Maya >> session and send them to Mayapy to run in the background to keep from >> locking up the current session while waiting for the process to >> finish--- >> >> Ideally, I could access mayapy through the Script Editor (through a >> system call) and also pass it arguments and the right module to >> process them and still be able to work in Maya while it's running in >> the background... I figure using the maya.standalone module would be a >> vital part of this, what I'm unclear on is just how to get it going >> purely by running a command from within Maya.... >> >> Thanks!! >> -Steve >> >> >> > > > -- > They say, "Evil prevails when good men fail to act." What they ought to > say is, "Evil prevails." > Nicolas Cage as Yuri Orlov in Lord of War. > -- 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/7c4fe28c-9306-4b87-b050-4d882c579cbe%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
