Create joints in a straight line

Create joints in a straight line

stony331
Enthusiast Enthusiast
889 Views
2 Replies
Message 1 of 3

Create joints in a straight line

stony331
Enthusiast
Enthusiast

Hi all is there a way to make the joints I create in a perfect straight line, like I want 10 joints going left to right but in a perfect line.  Also if possible without the help of the grid either -- thanks Mayans!

0 Likes
Accepted solutions (1)
890 Views
2 Replies
Replies (2)
Message 2 of 3

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

You can do this quite easily with a script.

Run this script from a python tab in the Script Editor:

import maya.cmds as mc

def createJointChain(start = None, step = None, number = None, direction = None, prefix = None):
    par = None
    for i in range(0,number):
        mc.select(cl = True)
        jnt = mc.joint(n = "{0}_{1}_JNT".format(prefix, i))
        if direction == "X":
            mc.xform(jnt, t= (start, 0,0), ws = True)
        elif direction == "Y":
            mc.xform(jnt, t= (0, start,0), ws = True)
        elif direction == "Z":
            mc.xform(jnt, t= (0, 0,start), ws = True)
        
        if par != None:
            mc.parent(jnt, par)
        
        par = jnt
        start = start + step
        
createJointChain(start = 0, step = 2, number = 10, direction = "X", prefix = "Line")

You can change the prameters in the last line to your liking. "start" is the position of the first joint, "step" is the length of the joints, "number" is the number of joints, "direction" is the direction your chain builds in (takes values "X", "Y", "Z") and "prefix" is what the name of the joint should start with.

 

I hope it helps!

Message 3 of 3

stony331
Enthusiast
Enthusiast
You are beautiful - thanks!!!
0 Likes