hello, thank you it was really very useful
I have a question
I only have 1 model, 1 head
to this I want to apply different textures and backgrounds
in order to release various versions
In that case, add multiple materials(textures) to the object (e.g. material names are "material_1", "material_2", so on) in advance, then you can write for example:
# gen_metadata.py
# List
list_background=[black,red,green,...]list_head=[material_1,material_2,...]random_background=random.choice(list_background)# ...
attributes=[{"trait_type":"Background","value":random_background},# ...
]
# gen_model.py
# Assign background material
defassign_background_material(material_name):# Get the object named "background" in the "misc" collection from the scene
background_object=bpy.data.objects["background"]# Set the material you want to assign
target_material=bpy.data.materials.get(material_name)# Assign material
background_object.data.materials[0]=target_material# Append head
defappend_head(trait_value):# Set the material name (e.g. "material_1", "material_2", etc)
material_name=trait_value# Append "head" collection in the scene
path=PARTS_DIR+"head/head.blend/Collection/"bpy.ops.wm.append(filename="head",directory=path)# Get the "head" collection
head_col=bpy.data.collections["head"]# Assign material
target_material=bpy.data.materials.get(material_name)forheadinhead_col.objects:head.data.materials[0]=target_material# Generate
defgenerate(id,metadata):# Background
ifattrinmetadata["attributes"]:ifattr["trait_type"]=="Background"andattr["value"]!="":assign_background_material(attr["value"])# ....
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
hello, thank you it was really very useful
I have a question
I only have 1 model, 1 head
to this I want to apply different textures and backgrounds
in order to release various versions
is it possible to do this with this script?
In that case, add multiple materials(textures) to the object (e.g. material names are "material_1", "material_2", so on) in advance, then you can write for example: