-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconnectCurves.py
63 lines (52 loc) · 1.54 KB
/
connectCurves.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
54
55
56
57
58
59
60
61
"""
creator function
"""
def createCurveSystem():
"""
select original curves and run this script
by default 50 curves was genereated
"""
curvesGenerated=50
curves=cmd.ls(sl=1)
C=curveSystem(curves,curvesGenerated)
"""
base class to create system
"""
class curveSystem:
def __init__(self,origCurves,numChild):
"""
init function
"""
if origCurves != None:
self.__curves = origCurves
self.__numCurves = numChild
self.__nodeName = self.createCGNode()
self.connectCurves()
self.createSubCurves()
return
def createCGNode(self):
"""
create a curvesGenNode
"""
node = cmd.createNode("curvesGen",n="CGNode")
return node
def connectCurves(self):
for c in range(len(self.__curves)):
outAttr=".".join([self.__curves[c],"worldMatrix[0]"])
inAttr=".".join([self.__nodeName,"inputCurvesM[%d]"%(c)])
try:
cmd.connectAttr(outAttr,inAttr,f=1)
except:
# insert warning here
pass
def createSubCurves(self):
CGName="curvesGen1"
cmd.setAttr("%s.numCurves"%self.__nodeName,self.__numCurves)
for c in range(self.__numCurves):
C=cmd.curve(d=3,p=[0,0,0])
Cs=cmd.listRelatives(C,s=1)[0]
try:
cmd.connectAttr("%s.outputCurves[%d]"%(self.__nodeName,c),"%s.create"%(Cs))
except:
# insert warning here
pass