Home Website Youtube GitHub

Create components with python

Hey all
I want to create a chain_spring_01 component using python.
The problem is when i create it a window pop asking for parameters: section number, direction and spacing.
I want to create the component only with python and determine the section number in the code.
This is the code i use to create the component:

import pymel.core as pm
import mgear.shifter as shifter
guide = shifter.guide.Rig()
guide.drawNewComponent(None, ‘chain_spring_01’, showUI=False)

Thanks
Amit

Hi Amit,

So I don’t know. I’ve never done this. But this is how I would approach it if I were trying to figure it out.

Go find the drawNewComponent() method in guide.py

You’ll see it does some stuff, and then ultimately calls comp_guide.drawFromUI(parent, showUI)

From there, I haven’t found it yet. But somewhere you’ll find the code that gets called after you use the UI. And you’ll be able to call that code more directly, with the parameters pre-chosen. But the command you are running right now is only meant to show the UI.

Again, I don’t know. So I’m not sure if that code is exposed as a command. If it is, I guess one day it should be added to the documentation. If it’s not, and you write some useful code, please share it with us later! :slight_smile:

(I’ve always manually built my guide templates, and then saved them as scene files. I’ve never tried to procedurally build the guides themselves. Maybe someone has a clearer answer!)

1 Like

Thanks for the respond Chris :pray:t3: