Python script crashes Mayabatch but runs fine in Maya GUI

220 views
Skip to first unread message

Fabrice Altman

unread,
Mar 25, 2015, 3:23:19 PM3/25/15
to python_in...@googlegroups.com
Hi,

we have a simple python script that runs totally fine in Maya GUI but breaks and crashes Maya GUI.
The script simply moves a bunch of locators to points on a curve.

Being Maya newbies (ex Softies) we must be missing something major so apologies in advance.

To simplify, the snippet bellow drwas a circle an saves the scene. Why is this not even working in Mayabatch 2015 Ext1 SP5?? 

print "OPENED!"
import maya.cmds as cmds
cmds.circle(r=10, d=1, n="test_Curve", s=20,)
cmds.file( rename='\\\\AKAAPPS\\Maya_Workgroups\\Tools\\test.ma')
cmds.file( save=True, type='mayaAscii')
print "SAVED!"

Any ideas much appreciated!

Cheers,
F.

Justin Israel

unread,
Mar 25, 2015, 4:11:09 PM3/25/15
to python_in...@googlegroups.com
On Thu, Mar 26, 2015 at 8:23 AM Fabrice Altman <afab...@gmail.com> wrote:
Hi,

we have a simple python script that runs totally fine in Maya GUI but breaks and crashes Maya GUI.

Do you mean that it breaks in Maya batch? 
 
The script simply moves a bunch of locators to points on a curve.

Being Maya newbies (ex Softies) we must be missing something major so apologies in advance.

To simplify, the snippet bellow drwas a circle an saves the scene. Why is this not even working in Mayabatch 2015 Ext1 SP5?? 

print "OPENED!"
import maya.cmds as cmds
cmds.circle(r=10, d=1, n="test_Curve", s=20,)
cmds.file( rename='\\\\AKAAPPS\\Maya_Workgroups\\Tools\\test.ma')
cmds.file( save=True, type='mayaAscii')
print "SAVED!"


Did you first import maya.standalone and initialize it?
 
Any ideas much appreciated!

Cheers,
F.

--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/bb722f49-fab0-45c0-9dd1-f7bac2891d4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fabrice Altman

unread,
Mar 25, 2015, 4:21:28 PM3/25/15
to python_in...@googlegroups.com


On 25 Mar 2015 20:11, "Justin Israel" <justin...@gmail.com> wrote:
>
>
>
> On Thu, Mar 26, 2015 at 8:23 AM Fabrice Altman <afab...@gmail.com> wrote:
>>
>> Hi,
>>
>> we have a simple python script that runs totally fine in Maya GUI but breaks and crashes Maya GUI.
>
>
> Do you mean that it breaks in Maya batch? 
>

Yes. The script runs but is not able to move locators it generates so we end up erroring down the line.
But even running this simple create and save snipet proves problematic.

>>
>> The script simply moves a bunch of locators to points on a curve.
>>
>> Being Maya newbies (ex Softies) we must be missing something major so apologies in advance.
>>
>> To simplify, the snippet bellow drwas a circle an saves the scene. Why is this not even working in Mayabatch 2015 Ext1 SP5?? 
>>
>> print "OPENED!"
>> import maya.cmds as cmds
>> cmds.circle(r=10, d=1, n="test_Curve", s=20,)
>> cmds.file( rename='\\\\AKAAPPS\\Maya_Workgroups\\Tools\\test.ma')
>> cmds.file( save=True, type='mayaAscii')
>> print "SAVED!"
>>
>
> Did you first import maya.standalone and initialize it?
>

No... The script is just started via Mel command : Python  executefile file.py.
Please send snipet on how to import Maya.standalone and initialise :)




>>
>> Any ideas much appreciated!
>>
>> Cheers,
>> F.
>>
>> --
>> 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 python_inside_m...@googlegroups.com.
>>
>> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/bb722f49-fab0-45c0-9dd1-f7bac2891d4f%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --

> You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/aa2cuj2M1Yk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Us%3DgGFNso1Gr70W2XZYCkfyk6apEOZdjsfG1esrJGng%40mail.gmail.com.

Justin Israel

unread,
Mar 25, 2015, 5:19:36 PM3/25/15
to python_in...@googlegroups.com
On Thu, Mar 26, 2015 at 9:21 AM Fabrice Altman <afab...@gmail.com> wrote:


On 25 Mar 2015 20:11, "Justin Israel" <justin...@gmail.com> wrote:
>
>
>
> On Thu, Mar 26, 2015 at 8:23 AM Fabrice Altman <afab...@gmail.com> wrote:
>>
>> Hi,
>>
>> we have a simple python script that runs totally fine in Maya GUI but breaks and crashes Maya GUI.
>
>
> Do you mean that it breaks in Maya batch? 
>

Yes. The script runs but is not able to move locators it generates so we end up erroring down the line.
But even running this simple create and save snipet proves problematic.

>>
>> The script simply moves a bunch of locators to points on a curve.
>>
>> Being Maya newbies (ex Softies) we must be missing something major so apologies in advance.
>>
>> To simplify, the snippet bellow drwas a circle an saves the scene. Why is this not even working in Mayabatch 2015 Ext1 SP5?? 
>>
>> print "OPENED!"
>> import maya.cmds as cmds
>> cmds.circle(r=10, d=1, n="test_Curve", s=20,)
>> cmds.file( rename='\\\\AKAAPPS\\Maya_Workgroups\\Tools\\test.ma')
>> cmds.file( save=True, type='mayaAscii')
>> print "SAVED!"
>>
>
> Did you first import maya.standalone and initialize it?
>

No... The script is just started via Mel command : Python  executefile file.py.
Please send snipet on how to import Maya.standalone and initialise :)


Sorry, I was thinking of mayapy, not Mayabatch. What kind of errors do you get?
 





>>
>> Any ideas much appreciated!
>>
>> Cheers,
>> F.
>>
>> --
>> 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 python_inside_m...@googlegroups.com.
>>
>> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/bb722f49-fab0-45c0-9dd1-f7bac2891d4f%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --

> You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/aa2cuj2M1Yk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0Us%3DgGFNso1Gr70W2XZYCkfyk6apEOZdjsfG1esrJGng%40mail.gmail.com.


>
> 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 python_inside_m...@googlegroups.com.

Marcus Ottosson

unread,
Mar 25, 2015, 5:28:39 PM3/25/15
to python_in...@googlegroups.com

As someone who has never used mayabatch, what is its advantage over mayapy?

This works for me.

script.py

print "OPENED!"
import os
import maya.cmds as cmds

import maya.standalone
maya.standalone.initialize()

output_path = os.path.join(os.getcwd(), "test.ma")

cmds.circle(r=10, d=1, n="test_Curve", s=20,)
cmds.file( rename=output_path)
cmds.file( save=True, type='mayaAscii')
print "SAVED!"

Runs like this.

$ mayapy script.py
OPENED!
SAVED!


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Fabrice Altman

unread,
Mar 26, 2015, 6:40:49 AM3/26/15
to python_in...@googlegroups.com
Thanks guys! Looks like we are back in business with Mayapy!
As a studio who has never used Maya before, we are strugling to get up to speed with the "Maya obvious" stuff ;)
I thought Mayabatch was the way to do this as for some reason, I thought Mayapy was a 3rd party implementation, actually not the factory standalone.

Regards from www.studioaka.co.uk


Marcus Ottosson

unread,
Mar 26, 2015, 6:50:28 AM3/26/15
to python_in...@googlegroups.com

Glad you got it working. :)

By the looks of it, batch is for running scene files without a GUI.
http://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Interface-overview-Start-Maya-from-the-command-line--htm.html

Assuming it’s mainly related to launching renders via the command-line.



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Colas Fiszman

unread,
Mar 26, 2015, 1:33:41 PM3/26/15
to python_in...@googlegroups.com
Hi,
Take care that is some case you will not get the same results with mayapy that in the maya gui (mostly in dynamics simulation).
If you want to be sure that you will get the same result in your batch process that in the gui use mayabatch.
Greets,
Colas

Marcus Ottosson

unread,
Mar 26, 2015, 1:44:52 PM3/26/15
to python_in...@googlegroups.com
Ah, interesting, thanks for the heads up.

Another thing to watch out for is that the Qt event-loop isn't running within `mayapy` which may also cause quirks, especially if you run code that depends on it.


For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages