Posted By

nebirousee on 07/06/16


Tagged


Versions (?)

test


 / Published in: Python
 

rewrwer

  1. import re
  2. for n in hou.selectedNodes():
  3. parent = n.parent().path()
  4. position = n.position()
  5. name = n.name()
  6. path_node = n.path()
  7. pos_razn = hou.Vector2 ((0, 1))
  8. k = n.geometry()
  9. p = k.primGroups()
  10. count_gr = p.__len__()
  11. shop = hou.node("/shop/").createNode("Global_shade")
  12. shop.setName("%s_shade"%(name))
  13. shop_path = shop.path()
  14. mat = hou.node(parent).createNode("material")
  15. mat.setName("%s_material"%(name))
  16. mat.setPosition(position - pos_razn)
  17. mat.setInput(0, n)
  18. mat.setParms({"num_materials": count_gr})
  19. cg_02 = p.__len__() + 1
  20.  
  21.  
  22. tt = p[1]
  23. grop_name = tt.name()
  24. pattern7 = re.compile('([^_]*$)')
  25. hdaFileNameee2 = re.search(pattern7, grop_name).group(1)
  26. grop_name_pre = grop_name.replace(hdaFileNameee2, '')
  27.  
  28.  
  29.  
  30. tex_path_gl3 = "%s/mat_path_gl"%path_node
  31. tex_path_gl2 = hou.parm(tex_path_gl3)
  32. tex_path_gl = tex_path_gl2.unexpandedString()
  33.  
  34. pattern2 = re.compile('([^_]*$)')
  35. hdaFileName = re.search(pattern2, tex_path_gl).group(1)
  36. num_tex_comp_f = hdaFileName.replace("0000", '')
  37. pattern1 = re.compile('([^.]*$)')
  38. hdaFileName2 = re.search(pattern1, num_tex_comp_f).group(1)
  39. num_tex_comp2 = num_tex_comp_f.replace(hdaFileName2, '')
  40. num_tex_comp = num_tex_comp2.replace(".", '')
  41. pattern3 = re.compile('([^/]*$)')
  42. hdaFileName3 = re.search(pattern3, tex_path_gl).group(1)
  43. num_tex_comp_f2 = tex_path_gl.replace(hdaFileName3, '')
  44. pattern4 = re.compile('([^_]*$)')
  45. hdaFileName4 = re.search(pattern4, num_tex_comp_f2).group(1)
  46. num_group2 = hdaFileName4.replace("/", '')
  47. num_group = num_group2.replace("0", '')
  48.  
  49. t = num_group.__len__()
  50. if t>1:
  51. num_group = num_group
  52. else:
  53. num_group = "0%s"%(num_group)
  54.  
  55. path_01 = num_tex_comp_f2.replace(hdaFileName4, '')
  56. path_02 = hdaFileName3.replace(num_tex_comp_f, '')
  57. path_03 = num_tex_comp_f.replace(num_tex_comp, '')
  58. path_new = "%s%s/%s%s%s"%(path_01, num_group, path_02, num_tex_comp, path_03)
  59.  
  60.  
  61.  
  62. for i in range(cg_02):
  63. if i != 0:
  64. nm_local = "num_local%s"%(i)
  65. mat.setParms({nm_local: 5})
  66.  
  67. mat_path = "shop_materialpath%s"%(i)
  68. mat.setParms({mat_path: shop_path})
  69.  
  70. nm_group = "group%s"%(i)
  71. if i>9:
  72. val_group = "%s%s"%(grop_name_pre, i)
  73. else:
  74. val_group = "%s0%s"%(grop_name_pre, i)
  75. mat.setParms({nm_group: val_group})
  76.  
  77. dirs = [1,2,3,4,5]
  78. for j in dirs:
  79. num_string = "local%s_type%s"%(i, j)
  80. mat.setParms({num_string: "string"})
  81.  
  82. over_01 = "local%s_name1"%(i)
  83. mat.setParms({over_01: "my_shader3_texmap_base"})
  84. over_path_01 = "local%s_sval1"%(i)
  85. if i > 9:
  86. over_path_dir_01 = "%s%s/%s0%s"%(path_01, i, path_02, path_03)
  87. else:
  88. over_path_dir_01 = "%s0%s/%s0%s"%(path_01, i, path_02, path_03)
  89. mat.setParms({over_path_01: over_path_dir_01})
  90.  
  91.  
  92. over_02 = "local%s_name2"%(i)
  93. mat.setParms({over_02: "my_shader3_texmap_diff"})
  94. over_path_02 = "local%s_sval2"%(i)
  95. if i > 9:
  96. over_path_dir_02 = "%s%s/%s1%s"%(path_01, i, path_02, path_03)
  97. else:
  98. over_path_dir_02 = "%s0%s/%s1%s"%(path_01, i, path_02, path_03)
  99. mat.setParms({over_path_02: over_path_dir_02})
  100.  
  101.  
  102.  
  103. over_03 = "local%s_name3"%(i)
  104. mat.setParms({over_03: "my_shader3_texmap_clr_spec_f"})
  105. over_path_03 = "local%s_sval3"%(i)
  106. if i > 9:
  107. over_path_dir_03 = "%s%s/%s2%s"%(path_01, i, path_02, path_03)
  108. else:
  109. over_path_dir_03 = "%s0%s/%s2%s"%(path_01, i, path_02, path_03)
  110. mat.setParms({over_path_03: over_path_dir_03})
  111.  
  112.  
  113. over_04 = "local%s_name4"%(i)
  114. mat.setParms({over_04: "my_shader3_texmap_clr_trace_refl"})
  115. over_path_04 = "local%s_sval4"%(i)
  116. if i > 9:
  117. over_path_dir_04 = "%s%s/%s3%s"%(path_01, i, path_02, path_03)
  118. else:
  119. over_path_dir_04 = "%s0%s/%s3%s"%(path_01, i, path_02, path_03)
  120. mat.setParms({over_path_04: over_path_dir_04})
  121.  
  122.  
  123. over_05 = "local%s_name5"%(i)
  124. mat.setParms({over_05: "my_shader_d2_texmap_displ_1"})
  125. over_path_05 = "local%s_sval5"%(i)
  126. if i > 9:
  127. over_path_dir_05 = "%s%s/%s4%s"%(path_01, i, path_02, path_03)
  128. else:
  129. over_path_dir_05 = "%s0%s/%s4%s"%(path_01, i, path_02, path_03)
  130. mat.setParms({over_path_05: over_path_dir_05})

Report this snippet  

You need to login to post a comment.