forked from lookbothways/vfxTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoWireTS
134 lines (93 loc) · 3.66 KB
/
autoWireTS
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
## Select two groups containing locators and run script.
## This will generate one wire from each locator in
## Group 1 to a random locator in Group 2.
import maya.cmds as cmds
import random
from pymel.core import *
def genCurve(originalSelection,droopVal, randomVal):
twoSelected = True
list = cmds.ls(sl=True)
if list != 2:
twoSelected = False
print "Only one locator selected, using first selected locator as source"
list = originalSelection
p1X = (cmds.getAttr(list[0]+".translateX"))
p1Y = (cmds.getAttr(list[0]+".translateY"))
p1Z = (cmds.getAttr(list[0]+".translateZ"))
p2X = (cmds.getAttr(list[1]+".translateX"))
p2Y = (cmds.getAttr(list[1]+".translateY"))
p2Z = (cmds.getAttr(list[1]+".translateZ"))
nCurve = cmds.curve( p=[(p1X, p1Y, p1Z),(p1X, p1Y, p1Z), (p2X, p2Y, p2Z), (p2X, p2Y, p2Z)] )
cmds.rebuildCurve( rt=0, s=1 )
cmds.select(nCurve+".cv[1:2]")
amount = droopVal
rndAmount = randomVal
amount = (amount*-1.0)+((random.random()*rndAmount)*-1.0)
cmds.move(0,amount,0,r=True,ls=True,wd=True)
cmds.select(nCurve)
setupArnoldCurves(nCurve)
cmds.rebuildCurve( rt=0, s=3 )
if twoSelected == False:
cmds.select(list[-1])
else:
cmds.select(list)
curves.append(nCurve)
def queryTextField(originalSelection):
# Gets the contents of the fiels in 'createWindow'
droopVal = cmds.textFieldGrp( 'droopVal', query = True, text = True)
randomVal = cmds.textFieldGrp( 'randomVal', query = True, text = True)
doit = 'OK'
selectedThings = cmds.ls(sl=True)
print selectedThings
if selectedThings != 1:
print "Creating wire.",
genCurve(originalSelection,int(droopVal), int(randomVal))
if selectedThings == 0:
print "Nothing selected",
else:
print "Only one object selected",
def setupArnoldCurves(nCurve):
try:
cmds.setAttr(nCurve+".aiRenderCurve",1)
cmds.setAttr(nCurve+".aiMode",1)
cmds.setAttr(nCurve+".aiCurveWidth",0.02)
#cmds.setAttr(nCurve+".aiMinPixelWidth",1)
except:
print "Curve not found",
def createWindow(originalSelection):
windowID = 'Autowire'
if cmds.window(windowID, exists = True):
cmds.deleteUI('Autowire')
window = cmds.window(windowID)
cmds.rowColumnLayout()
cmds.textFieldGrp('droopVal', label = 'Droop: ')
cmds.textFieldGrp('randomVal', label = 'Random: ' )
#cmds.button( label='Choose these values', command=('queryTextField();cmds.deleteUI(\"' + window + '\", window=True)') )
"""
This button calls autoWire.queryTextField and therefore will have interesting issues if run from the script editor.
Use this line if running from the script editor:
cmds.button( label='Choose these values:', command=('queryTextField(originalSelection)') )
"""
cmds.button( label='Choose these values:', command=Callback(queryTextField, originalSelection))
# The old way
#cmds.button( label='Choose these values:', command=('autoWire.queryTextField(originalSelection)') )
cmds.showWindow( window )
return values
def start():
originalSelection = cmds.ls(sl=True)
values = createWindow(originalSelection)
return originalSelection
#--------------------
def temp():
# Source curve
selectedSource = cmds.ls(sl=True)
# Curves to get extruded along
selected = cmds.ls(sl=True)
for each in selected:
cmds.extrude( selectedSource, each, et=2, fpt=True, ucp=1, upn=True )
nCurve = []
curves = []
values = ""
originalSelection = []
#
#originalSelection = start()