I am using blender 3.2, am trying to execute the below steps using python script
s1) Import Rigged avatar (.glb) into Blender
s2) Select the mesh of upper human body
s3) Go to shade editor, delete existing material and add new material
s4) @shade editor, select "Principled BSDF" and use Hot key ctrl + shift + t to upload the image of texture (Node wrangler is already enabled)
s5) Adjust the scale parameters at the Mapping node
s6)Export the updated avatar in same glb format
I generated the below script for the above steps:
import bpy
import functools
threeD_viewport = None
bpy.ops.import_scene.gltf(filepath="C:\\Users\\ASUS\\Desktop\\stage\\STAGEGLB3.glb", files=[{"name":"STAGEGLB3.glb",
"name":"STAGEGLB3.glb"}], loglevel=50)
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for space in area.spaces:
if space.type == 'VIEW_3D':
threeD_viewport = space
threeD_viewport.shading.type = 'MATERIAL'
threeD_viewport.material.new()
bpy.ops.node.select(deselect_all=True, location=(420, 240))
bpy.ops.node.nw_add_textures_for_principled(filepath="C:\\Users\\brown_color.jpg", directory="C:\\Users\\ASUS\\Desktop\\", files=[{"name":"brown_color.jpg", "name":"brown_color.jpg"}], relative_path=True)
bpy.data.materials["Material.003"].node_tree.nodes["Mapping"].inputs[3].default_value[0] = 5
bpy.data.materials["Material.003"].node_tree.nodes["Mapping"].inputs[3].default_value[1] = 5
bpy.context.space_data.shading.type = 'MATERIAL'
bpy.context.space_data.system_bookmarks_active = 3
bpy.context.space_data.system_bookmarks_active = 1
bpy.context.space_data.system_bookmarks_active = 1
bpy.context.space_data.params.filename = "STAGEGLB4.glb"
The error am getting is at line 11
Python: Traceback (most recent call last): File "\Text", line 18, in AttributeError: 'SpaceView3D' object has no attribute 'material'
@marty-fouts
can u pls help us in this regard
Thanks vij
nw_xxxx
ops are from the Node Wrangler addon. Is it installed/activated? $\endgroup$