Guest User

Untitled

a guest
Jul 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.03 KB | None | 0 0
  1. '''
  2.  
  3. _________________Modeling_Tool_Kit_________________
  4. Built by:
  5. Alexander Torres
  6.  
  7. How to Run:
  8. import modeling_toolkit
  9. reload (modeling_toolkit)
  10. modeling_toolkit.gui()
  11.  
  12. What this Script does:
  13. This Script creates a toolkit that can be used to for modeling.
  14. Meant to speed up your workflow and proved useful tools as well as frequently used buttons.
  15. Make sure to put script in your maya script folder:
  16. (These are the default paths, Any custom paths you would need to know)
  17. OSX:Users/insertYourComputersNameHere/Library/Preferences/Autodesk/maya/scripts
  18. WIN:
  19. Just copy the code above in the "How to Run:" section and paste into a python tab in your version of maya, works with 2016,/17,/18. Other version maybe not.
  20. Have Fun!
  21.  
  22.  
  23. '''
  24.  
  25. # Color Index
  26. red = [1.0, 0.0, 0.0]
  27. blue = [0.0, 0.0, 1.0]
  28. drk_blue = [.0, .016, .373]
  29. green = [0.0, 1.0, 0.0]
  30. yellow = [1.0, 1.0, 0.0]
  31. black = [0.0, 0.0, 0.0]
  32. white = [1.0, 1.0, 1.0]
  33. grey = [0.5, 0.5, 0.5]
  34.  
  35. import pymel.core as pm
  36.  
  37. win_name = 'Modelers_Toolkit'
  38. script_name = __name__
  39.  
  40. def gui():
  41. if pm.window(win_name, query=True, exists=True):
  42. pm.deleteUI(win_name)
  43.  
  44. if pm.windowPref(win_name, q=True, exists=True):
  45. pm.windowPref(win_name, r=True)
  46.  
  47. if pm.dockControl('dock_windows', q=True, exists=True):
  48. pm.deleteUI('dock_windows')
  49.  
  50. win_h = 850
  51. win_w = 200
  52.  
  53. win_w7 = win_w / 7
  54. button_h = 40
  55. tab_h = (win_w / 10) * 9
  56. scroll_w = win_w - 24
  57. scroll_w2 = scroll_w / 2
  58. column_w = win_w / 2
  59. column_w2 = column_w / 2
  60. column_w3 = scroll_w / 3
  61. column_w4 = scroll_w / 4
  62. win_w4 = win_w / 4
  63.  
  64. global win
  65. win = pm.window(win_name, t='Modelers Toolkit', w=win_w, h=win_h, backgroundColor=grey, nde=True, tlb=True, s=False)
  66.  
  67. header_layout(win_w7, button_h, win_w7, win_w4)
  68.  
  69. main_win_layout = pm.scrollLayout(w=win_w, h=win_h)
  70. test_layout = pm.columnLayout()
  71. what = renamer_layout(test_layout, scroll_w, tab_h, scroll_w2)
  72. # what.setLabel('something new')
  73. create_primitives_layout(scroll_w, tab_h, column_w3, column_w4)
  74. pm.setParent(main_win_layout)
  75.  
  76. topology_tools_layout(scroll_w, tab_h)
  77. pm.setParent(main_win_layout)
  78.  
  79. positioning_tools_layout(scroll_w, tab_h)
  80. pm.setParent(main_win_layout)
  81.  
  82. uv_tools_layout(scroll_w, tab_h)
  83. pm.setParent(main_win_layout)
  84.  
  85. mesh_tools_layout(scroll_w, tab_h)
  86. pm.setParent(main_win_layout)
  87.  
  88. win.show()
  89.  
  90. def do_dock_win():
  91. dock_window(win)
  92.  
  93. def dock_window(win):
  94. allowedAreas = ['right', 'left']
  95. if pm.dockControl('dock_windows', q=True, exists=True):
  96. return
  97.  
  98. left_right_chk_var = pm.optionMenu(left_right_chk, query=True, sl=True)
  99. area_var = ''
  100.  
  101. if left_right_chk_var == 1:
  102. area_var = 'right'
  103.  
  104. if left_right_chk_var == 2:
  105. area_var = 'left'
  106.  
  107. pm.dockControl('dock_windows', area=area_var, content=win, allowedArea=allowedAreas)
  108.  
  109. def dock_win_chng_side():
  110. left_right_chk_var = pm.optionMenu(left_right_chk, query=True, sl=True)
  111. area_var = ''
  112.  
  113. if left_right_chk_var == 1:
  114. area_var = 'right'
  115.  
  116. if left_right_chk_var == 2:
  117. area_var = 'left'
  118.  
  119. dock_window = pm.dockControl('dock_windows', e=True, area=area_var)
  120.  
  121. def header_layout(w, h, w7, w4):
  122. header_layout = pm.rowColumnLayout()
  123. pm.text(l='Modelers Tools', w=w)
  124. pm.separator(h=5, w=w)
  125. global left_right_chk
  126. row_col_layout = pm.rowColumnLayout(nc=2, cw=[[1, (w7 * 2)], [2, (w7 * 5)]])
  127. left_right_chk = pm.optionMenu(bgc=black, w=(w7 * 2), cc=script_name + '.dock_win_chng_side()')
  128. pm.menuItem(l='Right')
  129. pm.menuItem(l='Left')
  130. pm.setParent(row_col_layout)
  131. dock_button = pm.button(bgc=black, l="dock UI", c=script_name + '.do_dock_win()', w=(w7 * 5))
  132. pm.setParent(header_layout)
  133. pm.separator(h=5, w=w)
  134.  
  135. row_layout = pm.rowColumnLayout(nc=7, h=h)
  136. pm.rowColumnLayout(row_layout, edit=True,
  137. cw=[[1, w], [2, w], [3, w], [4, w], [5, w], [6, w], [7, w]])
  138. pm.text(label='')
  139. pm.iconTextButton(label='FT', width=w, height=h, style='iconAndTextVertical',
  140. image1='menuIconModify.png', c=script_name + '.freeze_transform()')
  141. pm.text(label='')
  142. pm.iconTextButton(label='DH', width=w, height=h, style='iconAndTextVertical', image1='menuIconEdit.png',
  143. c=script_name + '.delete_history()')
  144. pm.text(label='')
  145. pm.iconTextButton(label='CP', width=w, height=h, style='iconAndTextVertical',
  146. image1='menuIconModify.png', c=script_name + '.center_pivot()')
  147. pm.text(label='')
  148. pm.setParent(header_layout)
  149. pm.separator(h=5, w=w)
  150.  
  151. # row2_layout = pm.rowColumnLayout(nc=4, h=h)
  152. # pm.rowColumnLayout(row2_layout, edit=True, cw=[[1, w4], [2, w4], [3, w4], [4, w4]])
  153. # pm.iconTextButton(label='Object', width=w4, height=h, style='iconAndTextVertical',
  154. # image1='menuIconModify.png')
  155. # pm.iconTextButton(label='Edges', width=w4, height=h, style='iconAndTextVertical',
  156. # image1='menuIconModify.png')
  157. # pm.iconTextButton(label='Verts', width=w4, height=h, style='iconAndTextVertical',
  158. # image1='menuIconModify.png')
  159. # pm.iconTextButton(label='Faces', width=w4, height=h, style='iconAndTextVertical',
  160. # image1='menuIconModify.png')
  161. #
  162. # pm.setParent(header_layout)
  163. # pm.separator(h=5, w=w)
  164.  
  165. def renamer_layout(parent_layout, w, h, cw):
  166.  
  167. # main_layout = pm.columnLayout()
  168. header_layout = pm.frameLayout(label='Renamer', w=w, cll=True, cl=False, bgc=black, parent=parent_layout)
  169. org_layout = pm.columnLayout()
  170. renamer_layout = pm.rowColumnLayout(nc=2, cw=[[1, cw], [2, cw]], h=80)
  171. txt_column = pm.columnLayout(w=cw)
  172. pm.text(l='Prefix:')
  173. pref_txt = pm.textFieldGrp(text='ct')
  174. pm.text(l='Name:')
  175. name_txt = pm.textFieldGrp(text='back')
  176. pm.setParent(renamer_layout)
  177. button_column = pm.columnLayout()
  178. pm.text(l='Type:')
  179.  
  180. global suf_title, suf_txt, type_opt
  181. type_opt = pm.optionMenu(bgc=black, w=cw, cc=script_name + '.namer_visSwp()')
  182. pm.menuItem(l='Count')
  183. pm.menuItem(l='Cntrls')
  184. pm.menuItem(l='Geo')
  185. pm.menuItem(l='Custom')
  186. pm.setParent(button_column)
  187. suf_title = pm.text(l='Suffix', vis=False)
  188. suf_txt = pm.textFieldGrp(text='bind', vis=False)
  189. pm.setParent(org_layout)
  190. pm.button(l='Rename!', w=w, h=20, backgroundColor=black)
  191. pm.setParent(parent_layout)
  192. return header_layout
  193. def namer_visSwp():
  194. type = pm.optionMenu(type_opt, query=True, sl=True)
  195.  
  196. # global pref_txt, name_txt, suf_txt, type_opt, suf_title
  197.  
  198. if type == 1 or 2 or 3:
  199. suf_title.setVisible(0)
  200. suf_txt.setVisible(0)
  201. if type == 4:
  202. suf_title.setVisible(1)
  203. suf_txt.setVisible(1)
  204.  
  205. def create_primitives_layout(w, h, w3, w4):
  206. main_layout = pm.columnLayout()
  207. header_layout = pm.frameLayout(label='Create Primitives', w=w, cll=True, cl=False, bgc=black)
  208. org_layout = pm.shelfTabLayout(scr=True, h=(2 * h),)
  209.  
  210. polygons_tab = pm.columnLayout('Polygons')
  211. # pm.iconTextButton(label='Cube', w=(w4 - 5), h=(w4 + 5), style='iconAndTextVertical', image1='polyCube.png')
  212. # pm.setParent(polygons_tab)
  213. # pm.iconTextButton(label='Circle', w=(w4 - 5), h=(w4 + 5), style='iconAndTextVertical', image1='polySphere.png')
  214. # pm.setParent(polygons_tab)
  215. # pm.iconTextButton(label='Cylinder', w=(w4 - 5), h=(w4 + 5), style='iconAndTextVertical', image1='polyCylinder.png')
  216. # pm.setParent(polygons_tab)
  217. # pm.iconTextButton(label='Create', w=(w4 - 5), h=(w4 + 5), style='iconAndTextVertical', image1='polyCreateFacet.png')
  218. # pm.setParent(polygons_tab)
  219. # pm.iconTextButton(label='Platonic Solid', w=(w4 - 5), h=(w4 + 5), style='iconAndTextVertical', image1='polyPlatonicSolid.png')
  220. # pm.setParent(polygons_tab)
  221. # pm.iconTextButton(label='Disc', w=(w4 - 5), h=(w4 + 5), style='iconAndTextVertical', image1='polyDisc.png')
  222. # pm.setParent(polygons_tab)
  223. pm.text(l='X', h=15)
  224. pm.intSliderGrp(w=(w - 10), field=True, minValue=0, maxValue=20, fieldMinValue=-100, fieldMaxValue=100, value=0, h=18)
  225.  
  226. pm.text(l='Y', h=15)
  227. pm.intSliderGrp(w=(w - 10), field=True, minValue=0, maxValue=20, fieldMinValue=-100, fieldMaxValue=100, value=0, h=18)
  228.  
  229. pm.text(l='Z', h=15)
  230. pm.intSliderGrp(w=(w - 10), field=True, minValue=0, maxValue=20, fieldMinValue=-100, fieldMaxValue=100, value=0, h=18)
  231.  
  232. pm.setParent(polygons_tab)
  233.  
  234. pm.setParent(org_layout)
  235.  
  236. nurbs_tab = pm.shelfLayout('Nurbs')
  237. pm.setParent(org_layout)
  238.  
  239. curve_tab = pm.shelfLayout('Curves')
  240. pm.setParent(org_layout)
  241. pm.setParent(header_layout)
  242. pm.separator(w=w, h=5)
  243.  
  244. def topology_tools_layout(w, h):
  245. main_layout = pm.columnLayout()
  246. header_layout = pm.frameLayout(label='Topology Tools', w=w, cll=True, cl=False, bgc=black)
  247. org_layout = pm.columnLayout()
  248. pm.separator(w=w, h=5)
  249. pm.text(w=w, label='These Tools are meant to make\nre-topologizing a model easier!')
  250. pm.separator(w=w, h=5)
  251. pm.button(l='Quad Draw')
  252. pm.button(l='')
  253.  
  254. pm.separator(w=w, h=5)
  255.  
  256. def positioning_tools_layout(w, h):
  257. main_layout = pm.columnLayout()
  258. header_layout = pm.frameLayout(label='Positioning Tools', w=w, cll=True, cl=False, bgc=black)
  259. org_layout = pm.columnLayout()
  260. pm.separator(w=w, h=5)
  261. pm.text(w=w, h=60,
  262. label='HI!')
  263. pm.separator(w=w, h=5)
  264.  
  265. pm.separator(w=w, h=5)
  266.  
  267. def uv_tools_layout(w, h):
  268. main_layout = pm.columnLayout()
  269. header_layout = pm.frameLayout(label='UV Tools', w=w, cll=True, cl=False, bgc=black)
  270. org_layout = pm.columnLayout()
  271. pm.separator(w=w, h=5)
  272. pm.text(w=w, h=60,
  273. label='HI!')
  274. pm.separator(w=w, h=5)
  275.  
  276. pm.separator(w=w, h=5)
  277.  
  278. def mesh_tools_layout(w, h):
  279. main_layout = pm.columnLayout()
  280. header_layout = pm.frameLayout(label='Mesh Tools', w=w, cll=True, cl=False, bgc=black)
  281. org_layout = pm.columnLayout()
  282. pm.separator(w=w, h=5)
  283. pm.text(w=w, h=60,
  284. label='HI!')
  285. pm.separator(w=w, h=5)
  286.  
  287. pm.separator(w=w, h=5)
Add Comment
Please, Sign In to add comment