Website Youtube GitHub

Create and edit guides with pymel


#1

hey you all.

i’m trying to write a pymel code that will create and edit guide components.
for now i’ve managed to create a simple control_01 guide and rename it.
the most important thing that i need now, and don’t know how, is to decide if the controller will have a joint or not.

this is what i have for now:

import mgear.maya.shifter as shifter

componentName = "name"
guide = shifter.guide.Rig()
guide.drawNewComponent(parent, 'control_01')
root = pm.PyNode("control_C0_root")
ComponentGuide = shifter.component.guide.ComponentGuide()
ComponentGuide.rename(root , componentName , "C", index)

i’m using currently mgear 2.6.1 , seems like in the near future i will upgrade to the latest 3 version.
so if it’s different or much easier in 3 i’ll be happy to know.

thanks!

Amit


#2

This video on the mGear youtube channel helped me a lot with getting started with writing components and understanding how they work.

I’d duplicate the mgear\shifter_classic_components\control_01 folder and have a look at the guide.py and the _init_.py.

if self.settings["joint"]:
   self.jnt_pos.append([self.ctl, 0, None, self.settings["uniScale"]])

mGear gets the self.settings dict from the attributes on the guide component at build time, the “joint” key is a bool that will determine if a joint will need to be created for the component or not. If it is, the control will be added to the jnt_pos list along with some other settings. mGear then creates all the joints from the info in this list later on in the build process.

Hope this helps! I’m mostly certain of my explanation, but if something isn’t quite right I’m sure Miquel or Chris will correct me :wink:


#3

I don’t have any answer to your question. I just want to let you know that upgrading is easy and pretty painless and a lot of stuff remains compatible. If you are not in the middle of a deadline, it won’t take you too long. But I doubt anything in what you are trying to do will be any easier. It should be pretty much the same.

You might have to upgrade your existing guides with the menu mGear -> Shifter -> Update Guide.

And in your scripts, you’ll just have to change some of your imports because the modules were reorganized. For example mgear.maya.shifter becomes mgear.shifter

old examples:

import mgear.maya.shifter.customStep as cstp
from mgear.maya import skin
from mgear.maya import rigbits

new examples:

import mgear.shifter.custom_step as cstp
from mgear import rigbits
from mgear.core import attribute, primitive, curve
from mgear.core import skin

#4

hey chris.
thanks for the reply.
i’m working in a studio and we will finish soon a big scale projects so we don’t want to change versions to avoid problems.
that’s the only reason we haven’t upgrade yet.


#5

hey Justin.
thanks so much!
the video is indeed really helpful :slight_smile: