The code I have creates an addon which takes an existing material on my model and then grabs baked image textures from my laptop before it adds them using the principle texture setup feature from the node wrangler. The image below is an example of the output after I have ran my code and hit the button on my addon.
class SHADER_OT_bunnygirl_body(bpy.types.Operator):
bl_label = "Bunny Girl Body"
bl_idname = 'myaddonbody.my_operator'
#Executes once the button is pressed
def execute(self, context):
win = bpy.context.window
scr = win.screen
areas = [area for area in scr.areas if area.type == 'NODE_EDITOR']
regions = [region for region in areas[0].regions if region.type == 'WINDOW']
with bpy.context.temp_override(window=win,area=areas[0], region=regions[0],screen=scr):
bpy.ops.node.nw_add_textures_for_principled(filepath="//Body Color.png", directory="C:\\stable internship\\bunny girl\\bunny girl baked textures ATTEMPT 3\\", files=[{"name":"Body Normal.png", "name":"Body Normal.png"}, {"name":"Body Specular.png", "name":"Body Specular.png"}, {"name":"Body Roughness.png", "name":"Body Roughness.png"}, {"name":"Body Color.png", "name":"Body Color.png"}], relative_path=True)
#I have no idea whether the following line of code works
body = bpy.data.materials.get("Body")
#My idea here is to connect the top Base Color image texture's alpha thing with the
#alpha slider on principled BSDF
return {'FINISHED'}
However, in all the tutorials I watched they manually created the new nodes on the node tree using code rather than condensing it to 1 line like I have. Because of this I don't exactly know how I can grab the image texture on the top that says "Base Color" and connecting it with the Alpha slider on my "Principled BSDF" node.
Please don't flame me if this question is really dumb I am new to this kind of stuff. Many thanks!