I want to export my 3ds max vray models to blender. So i try bmax and maxtoblender addons. Problem is they cant export material correctly. I want to write my own script. Workflow is simple when you make manualy. Vray bump = blender bump, specular = reflection etc. How can i do this with script. Where should i start any advice?
Omer,
I did post some advice in the forum sub-category “Materials and Textures” and the thread name “V-ray 3Ds max to Cycles”.
1 Like
Max-To-Blender I don’t know, but the other way is done like this. I remembered having answered that a while ago. Not exactly that is the perfect solution but only just to get the ball rolling.
import bpy
def get_materials():
# a list of dictionaries
matlist = []
# iterating all of the materials
for mat in bpy.data.materials:
# get the bsdf node
bsdf = None
if mat.node_tree != None: # should have node tree
for n in mat.node_tree.nodes.keys(): # searching all nodes
node = mat.node_tree.nodes[n]
if node.type == 'BSDF_PRINCIPLED': # node type should be bdsf
bsdf = node # setting the node
break # exit node tree
# bsdf not found, skipping
if bsdf == None:
continue
# dictionary
d = {} # create a dictionary
d["name"] = mat.name # set material name
# get roughness socket
roughness = bsdf.inputs.get("Roughness")
# ensure input node is an image
if len(roughness.links) == 1 and roughness.links[0].from_node.type == 'TEX_IMAGE':
d["roughness"] = roughness.links[0].from_node.image.filepath
else:
d["roughness"] = roughness.default_value
# list
matlist.append(d) # appending to list
# return
return matlist
m = get_materials()
print(m)
2 Likes