cwisbg

nExtrude

May 23rd, 2016
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.73 KB | None | 0 0
  1. #extruder
  2. # rev 01
  3. from pymel.core import*
  4. def getPiv(s):
  5. select(s)
  6. setToolTo('Move')
  7. piv = manipMoveContext('Move', q=True, p=True,m=2)
  8. return piv
  9. sl = selected()
  10. def grpr(name):
  11. g = ls(name)
  12. if not g:
  13. g = group(n=name,em=1)
  14. else:
  15. g = g[0]
  16. return g
  17. def grprk(name):
  18. g = ls(name)
  19. if g:
  20. delete(g)
  21. g = group(n=name,em=1)
  22. return g
  23.  
  24. grp = grprk("neuronConnections_grp")
  25. slList = []
  26.  
  27.  
  28. for s in sl:
  29. crv = s
  30. mult = .3
  31. cLenght = arclen(s)
  32. baseWidth = .02
  33. extruded = polyPlane(sh=1,sw=1,w=cLenght*baseWidth*mult, h=cLenght*baseWidth*mult)
  34. setAttr(extruded[0].displaySmoothMesh , 2)
  35. parent(extruded,grp)
  36. slList.append(extruded)
  37. piv = getPiv(crv.cv[0])
  38. move(extruded[0], piv)
  39. tl = spaceLocator(n="tempLocation")
  40. piv2 = getPiv(crv.cv[1])
  41. move(tl,piv2)
  42. ac = aimConstraint(tl, extruded, u = [0,1,0], wu = [0,1,0],wut = "vector",aim = [0,1,0])
  43. pe = polyExtrudeFacet(crv,extruded[0].f[0], pvx = piv[0], pvy = piv[1], pvz = piv[2],ch=1, kft=1, d =40,tp=1)
  44. connectAttr(str(crv.getShape())+".worldSpace[0]", str(pe[0])+".inputProfile",f=1)
  45. delete(tl)
  46. #setAttr(s.visibility, 0)#_______________________________
  47.  
  48. if cLenght > 2:
  49. cLenght = cLenght/4
  50. offR = r.uniform(-.3,.3)
  51. offestMAmnt = offR
  52.  
  53. ends = 10 #* cLenght
  54.  
  55. widthM = r.uniform(2,3)#* cLenght
  56. middle = 12 #* cLenght
  57.  
  58. extrudeList = [["p1",ends, 0],["p2",ends-ends/2, 0.01],["p2.5",ends-ends/2, 0.05],["p3",widthM, .1],["p4",widthM, .45+offestMAmnt],
  59.  
  60. ["p5",middle, 0.48+offestMAmnt],["p2.6",middle, 0.52+offestMAmnt],
  61.  
  62. ["p7",widthM, .55+offestMAmnt],["p8",widthM, .9],["p9",ends-ends/2, .95],["p10",ends, 0.995],["p11",0, 1]]
  63.  
  64. #extrudeList = [["p1",ends*2, 0],["p2",ends/2, .5],["p2.5",ends*2, 1]]
  65. x = 2
  66. i = 0
  67. for ex in extrudeList:
  68. #print i, ex[1],ex[2]
  69. setAttr(pe[0]+".taperCurve[{0}].taperCurve_FloatValue".format(i), ex[1])
  70. setAttr(pe[0]+".taperCurve[{0}].taperCurve_Position".format(i), ex[2])
  71. setAttr(pe[0]+".taperCurve[{0}].taperCurve_Interp".format(i), 2)
  72. x += 1
  73. i += 1
  74.  
  75.  
  76. #delete(extruded,ch=1)
  77.  
  78. #wD = wire(extruded[0],dds=[(0,100),(1,100)],en=1,gw=0,ce=0,li=0, w = s, n = s+"_extruededWire")
  79. #wire -gw false -en 1.000000 -ce 0.000000 -li 0.000000 -w curve1 pPlane1;
  80.  
  81.  
  82.  
  83.  
  84.  
  85. select(cl=1)
  86. select(sl,add=1)
  87.  
  88.  
  89.  
  90.  
  91. """
  92. #extruder
  93.  
  94. from pymel.core import*
  95. def getPiv(s):
  96. select(s)
  97. setToolTo('Move')
  98. piv = manipMoveContext('Move', q=True, p=True,m=2)
  99. return piv
  100. sl = selected()
  101. def grpr(name):
  102. g = ls(name)
  103. if not g:
  104. g = group(n=name,em=1)
  105. else:
  106. g = g[0]
  107. return g
  108. grp = grpr("neuronConnections_grp")
  109. slList = []
  110. for s in sl:
  111. crv = s
  112. mult = .1
  113. cLenght = arclen(s)
  114. baseWidth = .02
  115. extruded = polyPlane(sh=1,sw=1,w=cLenght*baseWidth*mult, h=cLenght*baseWidth*mult)
  116. setAttr(extruded[0].displaySmoothMesh , 2)
  117. #parent(extruded,grp)
  118. slList.append(extruded)
  119. piv = getPiv(crv.cv[0])
  120. move(extruded[0], piv)
  121. tl = spaceLocator(n="tempLocation")
  122. piv2 = getPiv(crv.cv[1])
  123. move(tl,piv2)
  124. ac = aimConstraint(tl, extruded, u = [0,1,0], wu = [0,1,0],wut = "vector",aim = [0,1,0])
  125. pe = polyExtrudeFacet(crv,extruded[0].f[0], pvx = piv[0], pvy = piv[1], pvz = piv[2],ch=1, kft=1, d =40,tp=1)
  126. connectAttr(str(crv.getShape())+".worldSpace[0]", str(pe[0])+".inputProfile",f=1)
  127. delete(tl)
  128. #setAttr(s.visibility, 0)#_______________________________
  129. if cLenght > 2:
  130. cLenght = cLenght/4
  131.  
  132. offR = r.uniform(-.2,.2)
  133. offestMAmnt = offR
  134.  
  135. ends = 10 * cLenght
  136. widthM = 3 * cLenght
  137. middle = 12 * cLenght
  138.  
  139. extrudeList = [["p1",ends, 0],["p12",ends- ends/2, 0.05],["p4",widthM, .2],["p6",widthM, .4+offestMAmnt],["p2",middle, 0.5+offestMAmnt],["p7",widthM, .6+offestMAmnt]
  140. ,["p5",widthM, .8],["p13",ends- ends/2, 0.95],["p3",ends, 1]]
  141.  
  142. x = 2
  143. i = 0
  144. for ex in extrudeList:
  145. #print i, ex[1],ex[2]
  146. setAttr(pe[0]+".taperCurve[{0}].taperCurve_FloatValue".format(i), ex[1])
  147. setAttr(pe[0]+".taperCurve[{0}].taperCurve_Position".format(i), ex[2])
  148. setAttr(pe[0]+".taperCurve[{0}].taperCurve_Interp".format(i), 2)
  149. x += 1
  150. i += 1
  151.  
  152.  
  153. delete(extruded,ch=1)
  154. print extruded[0]
  155. wD = wire(extruded[0],dds=[(0,100),(1,100)],en=1,gw=0,ce=0,li=0, w = s, n = s+"_extruededWire")
  156. #wire -gw false -en 1.000000 -ce 0.000000 -li 0.000000 -w curve1 pPlane1;
  157.  
  158.  
  159.  
  160.  
  161.  
  162. """
Add Comment
Please, Sign In to add comment