there is a file in pymel called pluginFactory.py. it aids in
converting a python class into a mel command. for example, this test
class:
class test(object):
__init__(self, arg ):
self.arg = arg
doThis(self, funcArg)
print self.arg, funcArg
would become this mel command:
test -doThis "this is a flag arg" "this is a command arg"
every class method becomes a flag with its own arguments. the
commands are just wrapping the python code, so every time you change
your class, the mel commands are updated as well.
I never supplied an example of how to use this, but i will do so with
the next release of pymel. if this sounds like something you'd like
to use, i can send you an example in the meantime.
-chad
On Jan 21, 11:44 pm, "Ofer Koren" <
kor...@gmail.com> wrote:
> Sorry, I didn't explain this well I guess.
> What I'm trying to do is 'expose' a python function to the Mel interperter
> in a completely transparent way. Exposing it will be done from the python
> module that defines that python function. Mel scripts that use this function
> should be unaware that it actually runs python code. This way I could embed
> python functionality into existing mel code (specifically "hooks", or
> function-callbacks that expect mel procs)
> I've actually managed to create a generic method for this. Here's an
> [not-so-very-useful] example of how it can be used:
>
> ----------------sampleModule.py:
> def pySampleFunc(arr, cnt):
> return arr[:cnt]
> exportToMel(funcMelName="melSampleFunc", retType="string[]",
> argType=["string[]","int"], func=pySampleFunc)
>
> ----------------sampleScript.mel:
> string $ret[] = melSampleFunc({"a","b","c","d"},3);
> # {"a","b","c"}
>