Monday, November 23, 2009

Huh?

Here's an interesting thing I learned today:

Some commands cannot be used in a MEL script unless they are done before manually OR called from the source. For example,

Lets say you want to break a connection in the channel box. The command you will get in the script editor is:

CBdeleteConnection "Wrist_l_orientConstraint.w0"
;

So naturally, you'll put this in a script if trying to break connections. And since you've already done it, since the scene remains open, it's fine. However...lets say you reopen the scene and try to run the script. You will get a cannot find procedure CBdeleteConnection (or whatever command) error. Hmmm.

Apparently, for this to work, you have to call the source file that these scripts are in before using them in a script, unless you do it manually each time (which sources it automatically). The command for this is:

source
generateChannelMenu.mel;

And bam, this sources all of those hidden procedures. Best part - Maya help has no information about this. Thanks guys!

2 comments:

  1. ah i like your idea for dealing with the name change when using reference. i think i'm going to do something to the same effect in my own IKFK snap script

    about the channel box thing...
    CBdeleteConnection uses the "connectionInfo" to find the source and the destination of the string input. "Wrist_l_orientConstraint.w0"

    from there it uses the "disconnectAttr" to break the connection. the "disconnectAttr" is good enough to do what your aiming for...without more steps added, and maya help actually have examples for it. stupid maya...

    ReplyDelete
  2. I actually was using disconnectAttr to begin with, but every once in a while I would get an error saying that the attribute was already disconnected, so I tried CBdeleteConnection because it will run even if the connection is already broken (weird).

    Ahhh well. Good luck with your match script! Let me know if you need help :]

    ReplyDelete