狛犬 写真 xy 平面に
import bpy
# コレクションを作成
collection_name = "写真 xy 正方形"
if collection_name not in bpy.data.collections:
sphere_collection = bpy.data.collections.new(collection_name)
bpy.context.scene.collection.children.link(sphere_collection)
else:
sphere_collection = bpy.data.collections[collection_name]
import bpy
zion_name = "狛犬 xy"
shashin = "C:/aaa 2023 dondon/aaa2023いつもの/test_image/komainu20230415sat.jpg"
# 正方形を作成
bpy.ops.mesh.primitive_plane_add(size=60, enter_editmode=False, align='WORLD', location=(0,0,0))
square_obj = bpy.context.active_object
# オブジェクトに名前を付ける
obj = bpy.context.active_object
obj.name = zion_name
# マテリアルを作成
material = bpy.data.materials.new(name="ImageMaterial")
material.use_nodes = True
square_obj.data.materials.append(material)
square_obj.active_material = material
# テクスチャイメージを読み込む
img_path = shashin
tex = bpy.data.images.load(img_path)
# テクスチャノードを作成し、マテリアルに接続する
tex_node = material.node_tree.nodes.new("ShaderNodeTexImage")
tex_node.image = tex
tex_node.location = (-400, 0)
output_node = material.node_tree.nodes["Material Output"]
material.node_tree.links.new(tex_node.outputs[0], output_node.inputs[0])
俺用
import bpy
shashin = "C:/aaa 2023 dondon/aaa2023いつもの/test_image/komainu20230415sat.jpg"