Define a global mel proc in python script

395 views
Skip to first unread message

Emil Ljungberg

unread,
Nov 19, 2013, 6:32:55 AM11/19/13
to maya...@googlegroups.com
Hi Guys

Thanks for accepting me into your group. I am currently working on a scene which I script completely through the Python API. I have some spheres emitting particles and I want to add an event procedure upon collision between particles and spheres. An example from the API doc of how this would work is:

pm.event( 'myCloud', proc='myProc' )
# Call the MEL proc "myProc(name, id, name) each time a particle
# of myCloud collides with anything.

The problem is that the procedure must be defined as a global MEL proc. How can I do this within my Python script? 

Very thankful for any advice!

/ Emil

Andres Weber

unread,
Dec 19, 2013, 10:03:35 AM12/19/13
to maya...@googlegroups.com

import maya.mel as mel

#Just define the function to take arguments etc however the pm.event function is designed to take

mel.eval('global proc test(){print "test";}')

mel.eval('test()')



Also if you're planning on doing more frankensteining between mel/python you can look here for at least a little bit of info:
http://download.autodesk.com/us/maya/2009help/index.html?url=Using_Python_in_Maya_Communicating_between_Python_and_MEL.htm,topicNumber=d0e40141
Reply all
Reply to author
Forward
0 new messages