Thursday, July 12, 2012

Script for creating/editing message attrs . . .

I know I mentioned it in the 3rd part of the IK/FK snapping videos, so here it is for those of you who might be inclined to use it, the message mapping script . . .

If you're not sure what I'm talking about re: message attrs, watch this or look it up, sucka.

Here it is! zbw_messageMapper or go to the Downloads page above. . .

There are 2 tabs here:

 The first tab is for creating message attributes.

Select the object you want to add the message attrs to (the "base object") and click the "choose object" button to add it to the text field.
Click "add new attrs" to create a row that will allow you to type in the attr name and select the object the you want to send a message to that attr. You can do multiple attrs at a time, btw. If you want to delete the last row you created, click the red button (this just deletes the UI part, not any attrs). Once you've got what you need entered, then click the green button and the magic will happen. (it's really boring magic). A bit of text will pop up letting you know what you've got has been added and any problems or warnings should show up in your script editor. It will also run down what attr have been connected to what in the script editor.

The second tab is reviewing what message attrs you have on your selected base obj.

Select your base the same way you did in the last tab and click "list all message attrs". Any attributes of type "message" (however they were created) will be listed below in columns, one for the attr, one for the connected obj, if any, and a delete button.
The delete button is obvious, I hope, but if you right click on either of the other two columns you'll get a little menu giving you the option to change the name of the attr or change the obj connected to that attr. Clicking on either will open up a little window that gives you opportunity to change the respective end of the connection (and obviously reconnect things when done).

That's about it. I taken care of most of the dummy checking here (i.e. what happens when there are no message attrs or when you leave a field empty, etc), but there may be some situation that spits out an error or something. Be aware that creation side will force connect things, so it will overwrite any attrs that have the same name. It will show this warning in the script editor (though it just does anyways. Ha!). It will also show a little text message in the main window once you've created the messages, which will disappear when you change base objs. I chose not to reset the fields back to empty in case you wanted to do multiple base obj with the same attrs.

Hope it's useful to someone. And let me know if there are any big problems. I may try to fix them, you never know.

To run it, put it into your python scripts folder (maya doesn't automatically read all scripts folders for python files) and type:
import zbw_messageMapper

zbw_messageMapper.messageMapper()

You can drag that code to your shelf and run it from a button there.

9 comments:

  1. Thanks willie that looks really handy.

    Cheers

    ReplyDelete
  2. HI Willie, thanks for the great uploads and currently I am in the midst of doing such rigging for my assignments and they have make me understand in depth for the ik/fk snap.

    However, I have a curious question. Pardon me if you have raised this question in your blog/video but I would like to know, without the usage of any MEL/Python scripting, expressions or plugins, is it possible to achieve the ikfk snap just using normal Maya functions?

    By functions, I would mean the nodes, constraints etc..

    Achievable?

    ReplyDelete
  3. HI Willie, thanks for the great uploads and currently I am in the midst of doing such rigging for my assignments and they have make me understand in depth for the ik/fk snap.

    However, I have a curious question. Pardon me if you have raised this question in your blog/video but I would like to know, without the usage of any MEL/Python scripting, expressions or plugins, is it possible to achieve the ikfk snap just using normal Maya functions?

    By functions, I would mean the nodes, constraints etc..

    Achievable?

    ReplyDelete
  4. @Salik-

    I've never really thought of it, but I imagine you could do it all with utility nodes, etc, since it's mostly just adding and multiplying. You'd have to work some conditional nodes in there too, I would guess, to keep it from running all the time (in which case you'd never be able to move your IK node). Don't know if conditional nodes work like scripts in the sense that if the condition is not true, it doesn't evaluate the rest of the chain, because it also seems unnecessarily heavy to evaluate all the nodes all the time. But some extra grouping and stuff I would guess off the top of my head that it's probably possible. . .
    I wouldn't do it :) but let me know if you figure it out.
    Z

    ReplyDelete
  5. I really liked your videos on space snapping for IK/FK chain.I dont know much about scripting but after watching your video i understood the gist of it and tried it on my rig but the only problem is message mapper script is not working in maya.I am using maya 2013.i am new to this so if that script does work it would be wonderful.

    thnaks

    ReplyDelete
    Replies
    1. No, it works in 2013, for sure. What's not working? Are you not getting the window? Or is something not working right within the window, etc?

      Delete
    2. The issue was probably that I forgot to change the text here when I changed it in the script (which I did when I moved things to the download page).
      So get the script here: http://williework.blogspot.com/p/downloads.html
      and instead of typing the second line "zbw_messageMapper.zbw_messageMapper()", type "zbw_messageMapper.messageMapper()". My bad for changing that and not coming back and changing this page. . .

      Delete
  6. I've just try it, and the script run but i can't see the window.

    ReplyDelete
    Replies
    1. What I just told Raj above:
      The issue was probably that I forgot to change the text here when I changed it in the script (which I did when I moved things to the download page).
      So get the script here: http://williework.blogspot.com/p/downloads.html
      and instead of typing the second line "zbw_messageMapper.zbw_messageMapper()", type "zbw_messageMapper.messageMapper()". My bad for changing that and not coming back and changing this page. . .

      I'm changing this page now to avoid future confusion! Sorry!

      Delete