Home Website Youtube GitHub

Control Icons Library

After evaluating MGear for a client last year, we are using MGear on the next project and we’ve finally moved over to it. Yeah!

I’m digging about now in the code and having a few requests from the team to update the icons to the animator preferences. This has raised a few points, that I’m still investigating.

Buffer Controls. This works as tested previously and I don’t seem to have the old bug. Great. We can move on for now.

Feature Request: Control Library as JSON and read by Shifter Components

We want to push our default shapes into some of the shifter components. Looking at this it seems that this is hardcoded into the .ui files and the converted .py file. I’d prefer all controls to be a JSON file in a folder somewhere within MGear. That way we could add more icons to the folder easily. The icon.py file seems to be the place to add icons at the moment. This opens up for future icon themes.

Also, sometimes we don’t need a control icon, but an empty group is sufficient. This is useful when we want to use a basic shifter component, but it’s not needed to be animated, just built and hidden. At the moment, correct me if I’m wrong. I’d need to update icon.py to add an “Empty” icon (just a group). Then update all the shifter .ui files and .py files (where appropriate).

For now, it seems the best place to do this is with a post-build hook and replace the icons with the JSON icons we already have saved and delete shapes from the controls we want to be a simple group node.

Potential Bug

We have all our icons in the control buffer group of the guide currently. If we save the template and import the template back into the scene or directly build the rig from the template. The icons get corrupt. guess that because the controls built from the default icons, then the CV is set from the data. But our controls aren’t the default icons so they get corrupt as the CV doesn’t match. I haven’t looked deeper into this yet, so I’m guessing at this at the moment.

1 Like

Hell @Dave_Moulder

Have you tried the module curves.py from the mgear_core?

at the end of the module, there is a section of curves IO that stores the data in .json format
I want to create a proper UI/tool in the future. But for the moment I am using it with custom steps

Here are a couple of snippets for the custom step

# export curves
from mgear.core import curve
import pymel.core as pm
path = r"YOUR_PATH\control_shape.crv"
curve.export_curve(path, pm.selected())

# import curves
path = r"YOUR_PATH\control_shape.crv"
conf = curve._curve_from_file(path)
curve.update_curve_from_data(conf, rplStr=["", ""])

about this, I am not sure if I understand the idea. the .ui are files generated by QtDesigner

cheers,
Miquel

Hi Miquel,

Yeah, I found the curve.py file and the respective JSON functions. That’s why I though that this feature wasn’t to hard to implement. Currently the icons in the combobox are manually added in designer files and then converted the to py files.

From doing some shotgun development I remember you can tell designer to swap out a widget for an an already implemented widget. I believe this is called promoting a widget in the qt designer application language. So maybe just that icon combo widget could be promoted to a icon library aware widget. That way when doing the designer ui work, you have a widget that represents what you want, but is replaced by the actual implementation.

If you think there is value to this, I don’t mind adding it onto my list of Todo’s and submitting a pull request.

For now I’ve implemented a custom step to load the icons as you’ve described.

Thanks Miquel.

ah! I think I understand better your idea :slight_smile:
The only thing is that the controls created with Shifter component are not just a static shape library, It will adjust the length and weight depending on the guide proportions.

But yes! your ideas It is totally possible but is not just feeding a library of curve shapes.

Cool.

The meta data for icon manipulation is encoded in the guide via the group nodes *_sizeRef? and attribute ctlSize. If so it should be possible to do. Forgive me, I’ll be better informed once I’ve spent more time in mGear.

I’ve just found a bug in the curve.py file.

knots = range(len(points) + degree - 1)

This doesn’t work in all cases, the knot layout isn’t always describes as this formula. For example the knot layout of one of our curves is [0, 0, 1, 1] where the above formula create [0, 1, 2, 3]. It’s a valid curve, but the end points are not correct.

I’ve updated curve.py to store knots in the json and load them from the file if they exist to preserve backwards compatibility. This means we can update the icons correctly now and that storing the guide as .sgt with our custom shapes loads them correctly. Perfect, no post custom step loading shapes.