-
Notifications
You must be signed in to change notification settings - Fork 0
/
WireTool
187 lines (92 loc) · 4.82 KB
/
WireTool
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#################################################################
###################### WireConntrolTool ########################
#################################################################
#Author:Siddarth Mehra
#Email:[email protected]
#Mobile: +91-7728050400(Whatsapp)
#copy &Run
import maya.cmds as cmds
import maya.mel as mel
clusterList=[]
ctrlList=[]
curveOptionFinal=[]
def UI():
if cmds.window('Wire', exists=True ):
cmds.deleteUI( 'Wire', window=True )
if cmds.windowPref('Wire', exists=1 ):
cmds.windowPref( 'Wire', r=1 )
cmds.window('Wire',title="WireControler", iconName='Short Name',s=0)
cmds.columnLayout(adj=False)
cmds.button(l='Create 8 Control Wire(Adjust controllers ac to the mesh)',h=50,c='Eightcrv()')
cmds.button(l='Create 5 Control Wire(Adjust controllers ac to the mesh)',h=50,c='Fivecrv()')
cmds.button(l='Create 12 Control Wire(Adjust controllers ac to the mesh)',h=50,c='Twlcrv()')
cmds.button(l='FinalizeRig (Select Mesh and Wire)',w=300,h=100,c='final()')
cmds.showWindow('Wire')
def Eightcrv():
GlobalName = 'tmp'
basecurve8 = cmds.rename( mel.eval("curve -d 3 -p -7 0 0 -p -5 0 0 -p -3 0 0 -p -1 0 0 -p 1 0 0 -p 3 0 0 -p 5 0 0 -p 7 0 0 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 5 -k 5 ;"),(GlobalName+'_Wire'))
curve8Size = 8
curveOption = basecurve8
curveOptionFinal.append(curveOption)
curveSize=curve8Size
for i in range(curveSize):
cls = cmds.cluster(str(curveOption)+'.cv['+str(i)+']',n=(GlobalName+'CrvCls_0'+str(i)))
clusterList.append(cls[1])
for i in clusterList:
tmpctrls = cmds.circle(n=(i+'_Ctrl'),nr=[1,0,0],ch=0)
cmds.delete(cmds.pointConstraint(i,tmpctrls))
cmds.makeIdentity(tmpctrls, apply=True, t=1, r=1, s=1 )
cmds.pointConstraint(tmpctrls,i,mo=True)
ctrlList.append(tmpctrls[0])
clGrp = cmds.group(clusterList,n=('Cl_Group'+GlobalName))
ctrlGrp = cmds.group(ctrlList,n=('Ctrl_Group'+GlobalName))
mainGrp = cmds.group(clGrp,ctrlGrp,curveOption,n=('Main_'+GlobalName+'_Grp'))
return ctrlList
def Twlcrv():
GlobalName = 'tmp'
basecurve12 = cmds.rename( mel.eval("curve -d 3 -p -11 0 0 -p -9 0 0 -p -7 0 0 -p -5 0 0 -p -3 0 0 -p -1 0 0 -p 1 0 0 -p 3 0 0 -p 5 0 0 -p 7 0 0 -p 9 0 0 -p 11 0 0 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 9 -k 9 ;"),(GlobalName+'_Wire'))
curve12Size = 12
curveOption = basecurve12
curveOptionFinal.append(curveOption)
curveSize=curve12Size
for i in range(curveSize):
cls = cmds.cluster(str(curveOption)+'.cv['+str(i)+']',n=(GlobalName+'CrvCls_0'+str(i)))
clusterList.append(cls[1])
for i in clusterList:
tmpctrls = cmds.circle(n=(i+'_Ctrl'),nr=[1,0,0],ch=0)
cmds.delete(cmds.pointConstraint(i,tmpctrls))
cmds.makeIdentity(tmpctrls, apply=True, t=1, r=1, s=1 )
cmds.pointConstraint(tmpctrls,i,mo=True)
ctrlList.append(tmpctrls[0])
clGrp = cmds.group(clusterList,n=('Cl_Group'+GlobalName))
ctrlGrp = cmds.group(ctrlList,n=('Ctrl_Group'+GlobalName))
mainGrp = cmds.group(clGrp,ctrlGrp,curveOption,n=('Main_'+GlobalName+'_Grp'))
return ctrlList
def Fivecrv():
GlobalName = 'tmp'
basecurve5 = cmds.rename( mel.eval("curve -d 3 -p -4 0 0 -p -2 0 0 -p 0 0 0 -p 2 0 0 -p 4 0 0 -k 0 -k 0 -k 0 -k 1 -k 2 -k 2 -k 2 ;"),(GlobalName+'_Wire'))
curve5Size = 5
curveOption = basecurve5
curveOptionFinal.append(curveOption)
curveSize=curve5Size
for i in range(curveSize):
cls = cmds.cluster(str(curveOption)+'.cv['+str(i)+']',n=(GlobalName+'CrvCls_0'+str(i)))
clusterList.append(cls[1])
for i in clusterList:
tmpctrls = cmds.circle(n=(i+'_Ctrl'),nr=[1,0,0],ch=0)
cmds.delete(cmds.pointConstraint(i,tmpctrls))
cmds.makeIdentity(tmpctrls, apply=True, t=1, r=1, s=1 )
cmds.pointConstraint(tmpctrls,i,mo=True)
ctrlList.append(tmpctrls[0])
clGrp = cmds.group(clusterList,n=('Cl_Group'+GlobalName))
ctrlGrp = cmds.group(ctrlList,n=('Ctrl_Group'+GlobalName))
mainGrp = cmds.group(clGrp,ctrlGrp,curveOption,n=('Main_'+GlobalName+'_Grp'))
return ctrlList
def final():
mesh=cmds.ls(sl=True)
cmds.select(cl =True)
for i in ctrlList:
cmds.makeIdentity(i, apply=True, t=1, r=1, s=1 )
wireDeformer = mel.eval("wire -gw false -en 1.000000 -ce 0.000000 -li 0.000000 -w "+str(mesh[1]) +" "+ str(mesh[0])+";")
cmds.setAttr(str(wireDeformer[0])+'.dropoffDistance[0]',20)
UI()