-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (40 loc) · 1.67 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import maya.cmds as cmds
def createJoint():
j_number = cmds.intField(jointNumber, q=True, v=True)
parentJnt = ''
rootJnt = ''
curveSelected = cmds.ls(sl=True)[0]
rad = cmds.radioCollection(orient, q=True, sl=True)
# flexible estimate
curveLen = cmds.arclen(curveSelected)
if cmds.checkBox('flexEst', q=True, v=True): j_number = int(round(curveLen / 0.27))
for i in range(j_number):
cmds.select(cl=True)
newJnt = cmds.joint()
mp = cmds.pathAnimation(newJnt, c=curveSelected, fm=True)
cmds.cutKey(mp + '.u', time=())
cmds.setAttr(mp + '.u', i * (1.0 / (j_number - 1)))
cmds.delete(newJnt + '.tx', icn=True)
cmds.delete(newJnt + '.ty', icn=True)
cmds.delete(newJnt + '.tz', icn=True)
cmds.delete(mp)
if i == 0:
parentJnt = newJnt
rootJnt = newJnt
continue
cmds.parent(newJnt, parentJnt)
parentJnt = newJnt
if rad == 'child': cmds.joint(rootJnt, edit=True, oj='xyz', sao='yup', ch=True, zso=True)
if cmds.window('joint_Curve', exists=True):
cmds.deleteUI('joint_Curve')
cmds.window('joint_Curve', title='Joint Along Curve', w=150)
cmds.columnLayout(adjustableColumn=True)
cmds.frameLayout(label='Select a curve', cll=False, bgc=[0.3, 0, 0.3], w=200)
jointNumber = cmds.intField(v=15, min=2)
cmds.checkBox('flexEst', label='Flexible estimate')
cmds.frameLayout(label='Orientation', cll=False, bgc=[0.3, 0, 0.3], w=200)
orient = cmds.radioCollection()
cmds.radioButton('world', label='World orientation', sl=True)
cmds.radioButton('child', label='Child orientation')
cmds.button('create', c='createJoint()')
cmds.showWindow()