PDA

View Full Version : allIntersections using mel


Wixman
09-29-2010, 11:37 PM
I've seen octube's great wrapper for the maya api function allIntersections to test if point lies inside of a mesh.

http://forums.cgsociety.org/showthread.php?t=905100

is it possible to roll the same thing into a mel procedure? or is this wrapper actually a maya python api function?

any help would be appreciated - i'm a little confused

nessus
09-30-2010, 01:25 AM
I have seen that python wrapper of MFnMesh::allIntersections used in a number of other python scripts, every handy indeed. :applause:

You can access python procedures in MEL too,
e.g.
python( "import maya.cmds" )
python( "maya.cmds.ls" )

Wixman
09-30-2010, 06:19 PM
oh thats cool. So i'm using mel to access python to access the api functions. perfect.

Wixman
09-30-2010, 06:29 PM
ahh one thing i'm a little lost at, is how to include my variables from mel in my lines of python code?

nessus
09-30-2010, 07:42 PM
Yeah, it can be done, but its ugly:


global string $str="haha";
python("import maya.mel as mel");
python("test = mel.eval(\"global string $str;$temp=$str;\")");
python("print test");


The trick is $temp which holds the last assignment. Hope this helps.

nessus
09-30-2010, 07:54 PM
Also if you really need to dig into this, go to your maya doc at:
user guide-> general -> python -> Important differences between MEL and Python

Wixman
09-30-2010, 08:00 PM
wow. that is ugly.

yeah, i saw the section on Important differences between MEL and Python but I couldn't get that last bit to work. I'll give it another shot - thanks!

NaughtyNathan
09-30-2010, 09:04 PM
While I would ideally persuade you to switch to python for situations just like this ;) if you are sticking with MEL you could always just use the rayIntersect plug-in, which is the MEL wrapper for all the API intersection functions... check this post for info and download details:

http://forums.cgsociety.org/showthread.php?f=89&t=874836&highlight=rayIntersect

and here's a version completely in MEL code someone wrote:
http://forums.cgsociety.org/showthread.php?f=89&t=895822&highlight=rayIntersect

:nathaN

nessus
10-01-2010, 01:20 AM
While I would ideally persuade you to switch to python for situations just like this ;) if you are sticking with MEL you could always just use the rayIntersect plug-in, which is the MEL wrapper for all the API intersection functions... check this post for info and download details:

http://forums.cgsociety.org/showthread.php?f=89&t=874836&highlight=rayIntersect

and here's a version completely in MEL code someone wrote:
http://forums.cgsociety.org/showthread.php?f=89&t=895822&highlight=rayIntersect

:nathaN

Cool, this is much better solution!

CGTalk Moderation
10-01-2010, 01:20 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.