LumaPictures / pymel

Python in Maya Done Right
Other
479 stars 130 forks source link

Namespace-protected MEL procedures support #359

Closed kartikg3 closed 8 years ago

kartikg3 commented 8 years ago

In MEL we can name prefix procedure names with a namespace and a dot. Consider the following example:

proc string Foo(){
    return "Foo() just ran!";
}

proc string Foo.bar(){
    return "Foo.bar() just ran!";
}

print(Foo());
// Result: Foo() just ran! //

print(Foo.bar());
// Result: Foo.bar() just ran! //

Here the procedure bar() is defined with the namespace Foo.

Currently, pymel.core.language.Mel does not support running the namespace protected procedure using this format:

>>>pymel.core.mel.Foo()
# Result: u'Foo() just ran!' # 

>>>pymel.core.mel.Foo.bar()
# Error: AttributeError: file <maya console> line 1: 'function' object has no attribute 'bar' # 

The second case errors out (and understandably so). It'll be great if we can support this format too.

kartikg3 commented 8 years ago

Apparently, MEL allows unlimited namespace protection naming structure for procedure names.

proc string Foo.bar.spam.e.g.e.g.e.g.e.g.e.g.e.d.c.x.d.f.g.h.b.n.h(){
    return "Foo.bar.spam.e.g.e.g.e.g.e.g.e.g.e.d.c.x.d.f.g.h.b.n.h() just ran!";
}

print(Foo.bar.spam.e.g.e.g.e.g.e.g.e.g.e.d.c.x.d.f.g.h.b.n.h());
// Result: Foo.bar.spam.e.g.e.g.e.g.e.g.e.g.e.d.c.x.d.f.g.h.b.n.h() just ran! // 
pmolodo commented 8 years ago

Hmm... interesting, I'd never known about the ability to "namespace" mel functions before.

Given that this is probably a pretty uncommon practice, though, and implementation might be tricky - plus the fact that there's a workaround (ie, you can always just use pm.mel.eval) - I don't think we're going to act on this. If you wanted to implement it yourself, though, we'd probably merge it. Until then, though, closing this issue...

kartikg3 commented 8 years ago

Submitted a PR for this. Please let me know if you have any feedback or suggestions. Thank you.