Home Website Youtube GitHub

Tutorial for Building Custom Modules in Shifter?

Having issues setting up mGear in pycharm. Getting these errors when it’s trying to find calls to other parts of the code.

I set up my pycharm to read pyMel in the settings and I copied over the mGear python script componants into a new project.

I’m not sure what im doing wrong. Any help would be greatly appreciated.

I guess the environment cant find the modules. I didn’t use pycharm since some ago, so not sure how to configure now.

I don’t know if this is what you’re looking for.

1 Like

This should do the trick, it would be what I would suggest as well! :+1:

I think that did it, but for some reason it’s now not picking pymel.core

Ah I figured it out, for some reason it went back to using python 3.8 as well

Do you guys know how to get the QtWidgets and stuff to be found?

Hey guys would using Visual studio for this be a better option. I’m having issues figuring out how to highlight something in pycharm and getting it to tell me where in the mGear core things are being called from. What classes ect. Any advice before I start diving deeply into this?

Hi dew! What exactly you are trying to do?
Qt.py enables you to write software that runs on any of the 4 supported bindings - PySide2, PyQt5, PySide and PyQt4.

If you want to write code using PySide2/PyQt5 I would suggest to use Qt Classes reference. It’s more complete and logic than PyQt one.
https://doc.qt.io/archives/qt-5.9/classes.html

If you just want autocomplete for Qt.py than you should read this thread :

I’m used to scripting my own auto rig parts. I’d like to make my own spine, wing and specific body parts that aren’t included in mGear. I’m very unfamiliar with scripting using a specific custom API. I was just wondering what would be the easiest way to get into creating something custom from the ground up using mGears api. I have pyCharm installed and set up but it doesn’t work how something like visual studio does where it knows where each call and iteration comes from in the entire sourced code. What would, as a beginner to this whole system, be the best program to use to write custom modules in? Just so I can better understand logically what the shifter components are doing and how they function.

Hi dew. Here are some tips to use PyCharm:
You can CTL + LMB click over the object in code(method, variable) and if it is inherited or is overriding other methods or variables from parent class Pycharm will ask you what to do. You can jump to that class or just see where the variable is used. For example in control_01.__init__py the very first method addObjects() is reimplemented method from component.Main class. So with CTL + LMB I’l find this relation:

You can see that Main() inherits from object this means that this class is parent class for all inherited objects.
To find usage of the attribute/variable you use the same CTL + LMB click
In the Main() class you can CTL + LMB click on self.connections:

You can also right click on selected object and choose find usage:

In the same package of control_01 you will find guide.py . This class inherits objects form Component.guide.ComponetnGuide() class, which inherits from shifter.guide.Main() class. With CTL + ALT + LMB you can collapse all object. With the same key combination clicking on the object it will show implementations of that objects:

I hope this tips will help you in some way.

Thank you very much for the very clear explanation. That’s is extremely useful. One thing I was not able to replicate was the clicking on the connections object.

for some reason it’s throwing a little error. I’m not sure why my pyCharm is tossing me little errors like that. But the rest works perfectly ty! If I start to write my own components will pycharm autofill ?

I also im trying to figure out what specific stuff does. like

self.ik_cns = primitive.addTransform(
self.root, self.getName(“ik_cns”), t)

What does primative.addTransform do. It says in the framework documentation it creates a DAG node, but what kind of node? is it custom, is it just a null? Sorry for so many questions it’s always confusing to figure out another API

CTL + LMB click in my case works . Anyway right click + Find usage does the same.

This is the addTransform function of primitive module of mgear.core. If you CTL + LMB click on .addTransform you will see that this function creates transform node. It expects 3 arguments - parent, name and matrix. Passed this 3 arguments it will create the transform node under provided parent transform node, with given name and transformation info. So, in this case it creates _ik_cns node under root node(self.root which should be root control of the module) with name provided with self.getName("_ik_cns") and transformation info with t

Yes it will show all parent class methods/attributes

Thanks iRex. Sorry for all of the questions. It’s going to take me quite some time to learn the API.

1 Like

I have a question about the Shifter Component class in mGear. I’ve been delving into the mgear.core components and getting myself familiarized with them, however I don’t see any documentation written about the shifter class. When I copy and paste a new classic shifter componant to make a duplicate of it and edit the name in the guide.py file mGear still treats it as if it is the same component. I’m not specifically sure how mGear treats shifter components. How are they registered or disseminated differently from one another?

As you can see shifterGuide manager does not see the updated description. I feel as though it’s still just seeing it as Control_01 and not as it’s own separate thing. Because when I select Control_01 and back to Control_02 this happens.

It seems to just get it’s information and values from control_01. I’ve tried making a copy of Chain_01 and shifter does not even load the Options like it does in chain_01 it won’t draw the componant whatsoever. Any help would be greatly appreciated in trying to delve deeper into this and start making my own components.

the TYPE in the guide and the folder name should be the same
image
and avoid name clashing. If 2 components have the same name only the first found will be load
that is all

That worked like a charm ty Miquel! I’ll post more questions as I run into issues.

1 Like

I meant to edit my post not delete it, apologies. I wanted to know what arguments the add2DChain required.

Currently using this command

mgear.core.primitive.add2DChain(root, ‘TestName’, vecList, NormalS, negate=False)

In the list on the framework website it says a list of vectors for the position which I provided but i’m not sure what vector the normal needs. Wanted to test this out and see how mgear functions under the hood. Ty in advance!

Edit: I got it to work but is it supposed to make all these null groups under each joint in the chain?

Also its scalling the groups on the Y and Z like crazy and giving a 0 scale on the joint itself. Not sure why.

I have a question about how shifter populates the rig components with joints at their vector positions. Why or how does it subtract one? As there is no end joint but the position is there from the Guide. Where in the code does that exist that -1 is being told to to populate? I am unable to get mGear to print statements at certain points in the code during build it just won’t do it so I’m having trouble reverse engineering what is going on.

Any help would greatly be appreciated. I am currently editing the init.py on this custom component test.

Hey there @Dew,

The reason for the last element not being adding to when you build it because that last element in the guide is acting as an “aim/orientation” for the actual last bone to point to as well as to calculate the size of the control. You can see this with most components, let’s take the chain, for example, if you move those guides further away from each other, the lengths of the controls (cubes) always adjust to that length between each point. - talking out of the box standard setup here - with regards to dubugging your code, I mentioned in another post about a handy “workflow” when developing these guides:

from mgear import shifter
shifter.reloadComponents()

You can combine it with selection your guide and running this:
shifter.Rig().buildFromSelection()

The reloading components part should hopefully help you out to maybe see what you get if you have a bunch of print statements.

If you look in any component, normally it saves out all the positions of the guides in a class variable called self.guide.apos In the base class for the component guide, you’ll find all these useful goodies. These will help you looking for all the information that you are interested in when the guide builds.
image

Hope that this helps you a bit man!

2 Likes

Hey thank you for messaging me Jascha, that helps clear some things up. I’m still trying to wrap my head around how shifter wants to build things. My goal is to try making my own spine component from scratch (Eventually). What I’m confused about is how shifter components like to assemble themselves. It seems like the primitives are built first, then the connections are made, then things are cleaned up? For example im messing with the chain to edit it somewhat and learn how everything works. How would I for example be able to lets say add two bones sticking on the positive and negative Z axis or Y doesn’t matter 1 CM unit in distance for each joint in the chain grouped under.

This would help me understand how to make adjustments to things. Another thing I’m trying to figure out how to do is perhaps adding a simple multiply and divide node attached to each joint’s Rotate output, for no reason other then to learn how to make new utility nodes and create them.

Lastly I have no idea how to edit the PyQt widgets for the settings aside from fiddling with the code. I’ve always made my GUI’s with regular maya never PyQt, but it seems like mGear has a lot of functions to simplify it, other then that I’m not sure how I would go about removing things from lets say the chain_01. for example I was trying to remove all IK options from the code to learn how to omit or add things.