-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get_Maps_v01_02.py
68 lines (53 loc) · 1.94 KB
/
Get_Maps_v01_02.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
62
63
64
65
66
67
"""
STATUS: V01_02 In Progress
Feature/Purpose: Created Textures class which returns dict object
"""
import hou, os
class Texture_Files():
def __init__(self):
self.tex_maps = {
"alb" : "",
"rough" : "",
"metal" : "",
"spec" : "",
"opac" :"",
"nrml" : "",
"disp" : "",
}
def __str__(self) -> str:
string = ""
for tex in self.tex_maps:
string += tex + " = " + self.tex_maps[tex] + "\n"
return string
def extractMaps(self):
return self.tex_maps
#-----------------------------------------------------------#
# Get Maps From Node
def GetMapsFromNode(self, prinMatShader):
"""
:param prinMatShader: Dest Path for creating materialX subnet
:type prinMatShader: matnet
:raise TypeError: if folderPath not str
:rtype: dictionary
"""
if prinMatShader.type().name() != "principledshader::2.0":
print("Not a principle shader")
return None
self.tex_maps["alb"] = prinMatShader.parm("basecolor_texture").eval()
self.tex_maps["rough"] = prinMatShader.parm("rough_texture").eval()
self.tex_maps["metal"] = prinMatShader.parm("metallic_texture").eval()
self.tex_maps["spec"] = prinMatShader.parm("reflect_texture").eval()
self.tex_maps["opac"] = prinMatShader.parm("opaccolor_texture").eval()
self.tex_maps["nrml"] = prinMatShader.parm("baseNormal_texture").eval()
self.tex_maps["disp"] = prinMatShader.parm("dispTex_texture").eval()
# safety strip
for tex in self.tex_maps:
self.tex_maps[tex] = self.tex_maps[tex].strip()
# print(self.tex_maps[tex])
return self.tex_maps
def main():
shader = hou.selectedNodes()[0]
texture = Texture_Files()
texture.GetMapsFromNode(shader)
print(texture.extractMaps())
print(texture)