Maya API macro : How did they work?

71 views
Skip to first unread message

illunara

unread,
May 12, 2015, 11:04:48 AM5/12/15
to python_in...@googlegroups.com
Hi everybody
Maya's macro like check_mstatus_and_return_it used a lots. I just a bit confuse about how it works. In the document said, { Return if status is not MStatus::kSuccess. }

How can a macro stop the function and return immediately without calling return? This question is a bit outside Maya's boundary, but i got curious and can't help it. Still looking for source to see how it works through :D

And thank for dropping by :)

Justin Israel

unread,
May 12, 2015, 4:22:11 PM5/12/15
to python_in...@googlegroups.com
Hi,

C++ has this thing called a preprocessor. It runs over the source code before it gets to the compiler, and can do a bunch of things like handling macros, and various conditional compilation directives. 

A macro is like a snippet, that can support patterns being swapped in. When you use a macro, the preprocessor swaps in the literal code in place of the macro, and swaps in any variables you might have used for the macro. For instance, CHECK_MSTATUS_AND_RETURN_IT is a macro that takes a status. That macro expands into the same logic you would write, yourself, checking the status and returning if its an error. 

Basically just think of macros as text replacement. They are less preferred nowadays, as far as I understand, because they are harder to debug, and are not type safe. 

Justin


--
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/ec22387e-ea48-4e3f-9a6e-3ba90ba1a398%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tuan Nguyen

unread,
May 12, 2015, 9:45:22 PM5/12/15
to python_in...@googlegroups.com
Thank Justin for easy and clear explanation. I know there was a risk using macro because of typesafe, however i like the way Maya use it with MStatus. I would love to do something like that with my code too :D
 

Justin Israel

unread,
May 12, 2015, 9:57:57 PM5/12/15
to python_in...@googlegroups.com
Well what I meant was actually writing and using your own macros are more prone to debugging issues. But using the ones provided by the Maya API, I am sure, are well tested. 

On Wed, May 13, 2015 at 1:45 PM Tuan Nguyen <cb.il...@gmail.com> wrote:
Thank Justin for easy and clear explanation. I know there was a risk using macro because of typesafe, however i like the way Maya use it with MStatus. I would love to do something like that with my code too :D
 

--
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.

Tuan Nguyen

unread,
May 12, 2015, 10:56:03 PM5/12/15
to python_in...@googlegroups.com
Yup, of course.
Oh btw, are there any parts of maya open-source? Or they just provide us the API library?

Justin Israel

unread,
May 12, 2015, 11:04:01 PM5/12/15
to python_in...@googlegroups.com
I don't know of any part of Maya that is open source. You get a public API to work with.


On Wed, May 13, 2015 at 2:56 PM Tuan Nguyen <cb.il...@gmail.com> wrote:
Yup, of course.
Oh btw, are there any parts of maya open-source? Or they just provide us the API library?

--
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.

Tuan Nguyen

unread,
May 12, 2015, 11:17:10 PM5/12/15
to python_in...@googlegroups.com
I though so too.
Hey, Justin, since you're working on top company like Weta , how do they develop inhouse tool ( like custom Fur, Hair, deform, render system ... )?  It still base on Maya's core, or it completely new ? Can you give me some experiment about it? :D

Justin Israel

unread,
May 12, 2015, 11:40:41 PM5/12/15
to python_in...@googlegroups.com


On Wed, 13 May 2015 3:17 PM Tuan Nguyen <cb.il...@gmail.com> wrote:

I though so too.

Hey, Justin, since you're working on top company like Weta , how do they develop inhouse tool ( like custom Fur, Hair, deform, render system ... )?  It still base on Maya's core, or it completely new ? Can you give me some experiment about it? :D

I'm not exactly sure what you are asking here, but if it is something for use inside of Maya, then it will have to use the Maya API in some capacity to integrate as a plugin. Can you be more specific about what you want to know? What would be your definition of "completely new"? We have tons of custom functionality for sure. But I don't know if that answers your question.

--
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/CAMCvD%2BGS2WKNdTwcfJKe7YU6bLqDzPvjo%2BMosxthkPJiYGJamg%40mail.gmail.com.

Tuan Nguyen

unread,
May 13, 2015, 1:08:46 AM5/13/15
to python_in...@googlegroups.com

I'm not exactly sure what you are asking here, but if it is something for use inside of Maya, then it will have to use the Maya API in some capacity to integrate as a plugin.

Nah, you already gave me the answer i ask for :) What inside of Maya should use Maya API to handle. For other in-house system (like PentaRay ) was developed separately outside of Maya, and only interact with each other later.

Marcus Ottosson

unread,
May 13, 2015, 2:34:41 AM5/13/15
to python_in...@googlegroups.com

Oh btw, are there any parts of maya open-source?

It’s got plenty of open source components, but that’s probably not what you’re after.


On 13 May 2015 at 06:08, Tuan Nguyen <cb.il...@gmail.com> wrote:

I'm not exactly sure what you are asking here, but if it is something for use inside of Maya, then it will have to use the Maya API in some capacity to integrate as a plugin.

Nah, you already gave me the answer i ask for :) What inside of Maya should use Maya API to handle. For other in-house system (like PentaRay ) was developed separately outside of Maya, and only interact with each other later.

--
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.

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



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

Tuan Nguyen

unread,
May 13, 2015, 3:10:06 AM5/13/15
to python_in...@googlegroups.com
Yeah, i look after Maya's source. Sometimes it easy for me to read it directly to understand problem :)

Justin Israel

unread,
May 13, 2015, 4:17:40 AM5/13/15
to python_in...@googlegroups.com
On Wed, May 13, 2015 at 5:08 PM Tuan Nguyen <cb.il...@gmail.com> wrote:

I'm not exactly sure what you are asking here, but if it is something for use inside of Maya, then it will have to use the Maya API in some capacity to integrate as a plugin.

Nah, you already gave me the answer i ask for :) What inside of Maya should use Maya API to handle. For other in-house system (like PentaRay ) was developed separately outside of Maya, and only interact with each other later.

Ah right. Well ya, we have our own in-house renderer called Manuka:

And our own in-house hardware renderer called Gazebo:

So there would be bits that integrate with Maya, and bits that are standalone. 

--
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.

Nicolas Combecave

unread,
May 13, 2015, 5:07:21 AM5/13/15
to python_in...@googlegroups.com
About barberShop, is it a completely stand-alone tool or is it integrated in maya in any way?

Justin Israel

unread,
May 13, 2015, 5:33:53 AM5/13/15
to python_in...@googlegroups.com


On Wed, 13 May 2015 9:07 PM Nicolas Combecave <zezebub...@gmail.com> wrote:

About barberShop, is it a completely stand-alone tool or is it integrated in maya in any way?


I can probably only point you at this:


http://www.fxguide.com/featured/barbershop-at-weta-sci-tech-winner-explained/

... Which describes it being integrated via a maya plugin

To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAD65uqm9vCfO0pEY43PrHmEY_%2BxCn3zABbx4tPGtH_z62qpjZQ%40mail.gmail.com.

Tuan Nguyen

unread,
May 13, 2015, 6:06:45 AM5/13/15
to python_in...@googlegroups.com
@Justin : For those in-house tool, you guys wrote everything from the scratch, a new system or still base on Maya's core?

Justin Israel

unread,
May 13, 2015, 6:14:57 AM5/13/15
to python_in...@googlegroups.com


On Wed, 13 May 2015 10:06 PM Tuan Nguyen <cb.il...@gmail.com> wrote:

@Justin : For those in-house tool, you guys wrote everything from the scratch, a new system or still base on Maya's core?

Like I said, many parts of these things can be completely standalone, and then integrated into Maya and other host applications by way of plugins.

Ideally one would try to not design a huge custom solution that is completely tied to a single host app. If you can make it application independent at its core, then you can just use host specific plugins to integrate them to more than one application.

--
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/CAMCvD%2BEQ56as9oHMDR9s34OeNqC98fSDras_GkuFUerpNz3%2Bdw%40mail.gmail.com.

Tuan Nguyen

unread,
May 13, 2015, 6:21:28 AM5/13/15
to python_in...@googlegroups.com
Oh, i got it. However, to develop a huge system like that will take a lots of jobs, times and works.
Well, that's how big company going:D

Nicolas Combecave

unread,
May 13, 2015, 12:53:30 PM5/13/15
to python_in...@googlegroups.com
Yeah I did read this one, but it wasn't clear to me if the interactive tools were accessible from within maya or just the core, which may be related to render the hairs...
 

Justin Israel

unread,
May 13, 2015, 7:49:41 PM5/13/15
to python_in...@googlegroups.com
On Thu, May 14, 2015 at 4:53 AM Nicolas Combecave <zezebub...@gmail.com> wrote:
Yeah I did read this one, but it wasn't clear to me if the interactive tools were accessible from within maya or just the core, which may be related to render the hairs...

Pretty sure the interactive aspect is specifically a Maya plugin

Reply all
Reply to author
Forward
0 new messages