Blender Asked by pronto on December 26, 2021
In other answer script not working:
(in Add a Texture to an Object using Python and Blender 2.8 answer not working, generate only black image and delete everything)
import bpy nazwa_tek="cyfry" plik_tek_gr="//grafiki/gr.png" tek =
bpy.data.materials.new(name=nazwa_tek) tek.use_nodes = True bsdf =
tek.node_tree.nodes["Principled BSDF"] texImage =
tek.node_tree.nodes.new('ShaderNodeTexImage') texImage.image =
bpy.data.images.load(plik_tek_gr)
#tek.diffuse_color = (1.0, 0.0, 1.0, 0.8) tek.node_tree.links.new(bsdf.inputs['Base Color'],
texImage.outputs['Color']) print("tekstura:=", tek)
def DodajTeksture(ob, nazwa="cyfry", plik_gr="//grafiki/gr.png"):
global tek
# Assign it to object
if ob.data.materials:
ob.data.materials[0] = tek
else:
ob.data.materials.append(tek)
return
bpy.data.scenes["Scene"].render.image_settings.file_format = 'JPEG'
bpy.data.scenes["Scene"].render.filepath = './'
bpy.ops.render.render(animation = False) img = bpy.data.images[0]
img.save_render('wynik.jpg')
bpy.ops.wm.save_mainfile(filepath='bb.blend')
but how create a image texture? My texture are now procedural and do not have .image value. (I need image texture not procedural)
obrazek = bpy.ops.image.open(filepath="//file.png")
bpy.data.images["//file.png"].pack(as_png=True)
load image, but how aplying image for object named "Cube"?
How creating procedure in python
def appimage(obj, name_image, dx, dy)
#applying image to object name obj staring from (dx,dy) in image
return
create texture, add image to texture (one texture will be assign to some object) specifi region in image for this object. I have big texture for many objects. Only small region is for object. My image have transparent region (it schow diffuse color from bottom?).
appimage("Cube", "//file.png", 170, 200)
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP