Home Website Youtube GitHub

Custom Select All function for facial custom tab

Hi!

We are trying to create facial/body tabs for our rigs using the custom synoptic workflow you explain in a video. We have added in our rig a group called “rig_facial_grp” using a post script in which we added all facial controllers and removed the ones in this group from the builtin “rig_controllers_grp”, so we separated facial from body groups

Is there a easy way of calling facial controls from the facial tab and body controls from body tab passing the set name as an attribute? What do you recomend?
Also, where does the connection of the clicked event for the buttons “Select All”, " Key Sel"… occurs? I dont happen to find them.

Thanks very much in advance and Best Regards

Jaime

Hola @Jaime_Bescansa

You can find the code that gets called in mgear.synoptic.tabs module and it’s on the init python file.

Now for this part. I’ll try to explain it tghe best way I can, so please let me know if something isn’t clear enough.

You can add as many custom functions to a picker in mGear but you do need to understand a little bit their structure so first take the time to get confortable with the files been used when creating a picker.

  • The UI file is your picker but it isn’t in any case the direct file been called by synoptic.
  • The widget.py file is the one been called by Synoptic and it contains your picker when you compile the UI file using mGear’s menu inside Maya.
    *The init python file is the one responsible for loading it all and it is there where you can add custom functionalities to your pickers.

In the image above I created a button called Select All but it actually refers to what you are trying to do as that is a picker for just the face. You can inside this file create either a list with the names of the controls or either jkust the name of your facial set and get the controls from there. The posibilities from there are endless.

  • You just need to understand that inside the UI file you need to name your button the same way as you are planning to name them in the buttons dictionary inside the init file (but in the UI file they need to have a b_ defore the name)
  • The functions that the buttons called beed to have again the same name but this time with an _clicked in the function name.

I hope this helps you.
Let me know if this isn’t clear enough.

Cheers

1 Like

Hi Jerome! I now understand perfectly the workflow for the custom calls for synoptics…Thank you so much for your clear answer, I appreciate it very much!

All Best!

Jaime

1 Like

Hi,

I was trying to tho the same you explain, so
First I made sure that the buttons in qt Designer were named correctly. In my case “b_selAll”
In the __init__file…
I modified the buttons variable adding a dict with {“name”: “selAll”}
Then I set a member variable with a list of all facial controlers like you did with “self.facial_controls”
Lastly I created a funcion exactly as the one you describe. def selAll_clicked(self):…

I do not get any trace of it getting into the function, nor any message on any click on the button.

Im working in a custom synoptic location (outside of the mgear installation location) and we have both, body and facial tabs, just in case it helps to figure out the problem.

Let me know if you have any idea of qhat I’m doing wrong here…

Thanks very much Jerome! Much appreciated.

Cheers
Jaime

Hello @Jaime_Bescansa

It’s hard without having the files but I would say that normally you can have your pickers totally outside the mGear installation folders. I would even recomment it.

You are using the environment variable to set that custom synoptic pickers location right?

Yes I’m setting MGEAR_SYNOPTIC_PATH = /to/a/location/that/contains/:

charABody
charAFacial
charBBody
charBFacial

And so on … and inside of each folder the _ init _.py, widget, etc.

And then we load body and facial from the Synoptic attribute in the model root attr…

Another thing that I have notice is that I cannot leave any trace or print in any of the functions on the _ init _.py file. Is there a place in which I can activate them to mak easier debugging?

Thanks very much Jerome

Jaime

Strange… On my side adding printings to the init files work.

There is one thing to keep in mind. If you are making changes to the Init file of a picker and you want your current session of Maya/Synoptic to pick up the changes you need to reload the python module of the picker. The usual way I do it is by searching the Picker tab name on the sys.modules like followed


import sys

to_delete = ["pickerA",
                    "pickerB","]

for i in sys.modules.keys():
    for module in to_delete:
        if module in i :
            print("deleting module {}".format(i))
            del sys.modules[i]

Now here is a full init file example of a button on my picker to key all controls inside the rig_controllers_grp Maya selection set.


# imports
import os
import pymel.core as pm
from mgear.synoptic import utils
from mgear.synoptic.tabs import MainSynopticTab
from mgear.vendor.Qt import QtWidgets
from .widget import Ui_biped_body


class SynopticTab(MainSynopticTab, Ui_biped_body):
    description = "humans"
    name = "humans"
    bgPath = os.path.join(os.path.dirname(__file__), "background.png")

    buttons = [
                {"name": "keyAllControls"},
              ]

    def __init__(self, parent=None):
        super(SynopticTab, self).__init__(self, parent)
        self.cbManager.selectionChangedCB(self.name, self.selectChanged)

    def keyAllControls_clicked(self):
        print("I AM GOIN TO KEY ALL CONTROLS")
        model = utils.getModel(self)
        namespace = utils.getNamespace(model)
        controlers = pm.sets("{}:rig_controllers_grp".format(namespace), query=True)
        with pm.UndoChunk():
            pm.setKeyframe(controlers)

I added a pint inside the keyAllControls_clicked function and it does work. You could have a loggin python module logger registered to your own needs and call it there as well.

Let me know if this works for you. If not I will need you to send me a message with your picker files attached so that I can take a look.

Cheers

1 Like

Hi Jerome!

Now it works as a charm! Thank you so much.

The only thing is that each time I click the button, seems like the print statement is called twice.
Is it maybe because I have a couple of tabs loaded on the sinoptic each one with the QPushButton called b_keyAllControls? Just have tested it and yes, it seems that having the same button name on other widget that is called by the synoptic makes this double call… Good to know! Also easy to avoid…

Also…The script for reloading the modules is really great! Also works perfect.
Everything is clear and working! Thank you very much for your help. Much appreciated.

Have a nice day, Jerome!!

Jaime

1 Like