0
$\begingroup$

How to copy a texture from bpy.data.textures

# Assuming it has a texture in bpy.data.textures

textures = bpy.data.textures
new_texture = textures[0].copy()
name = textures.new("", new_texture.type).name
textures[name] = new_texture

and it raise error

TypeError: bpy_prop_collection[key]: invalid key, must be a string or an int, not str

Is there a way to duplicate that texture, or need to set all the attributes to the new texture?

$\endgroup$
2
  • 1
    $\begingroup$ The line textures[0].copy() already creates a duplicate and pushes it into bpy.data.textures $\endgroup$
    – Harry McKenzie
    Commented Mar 23, 2023 at 3:52
  • 1
    $\begingroup$ Thank you, I got it, Turns out I didn't find it added $\endgroup$
    – X Y
    Commented Mar 23, 2023 at 4:14

1 Answer 1

2
$\begingroup$

The line textures[0].copy() already creates a duplicate and pushes it into bpy.data.textures

textures = bpy.data.textures
t = textures[0].copy()
t.name = "new-texture-duplicate" # if you want to rename it
print(t.name)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .