1
$\begingroup$

I'm importing 300-400 images via Images as planes add-on, stacking them at world origin and below each other (0.001 offset). Render engine is Blender Internal. Then I want to disable interpolation for all textures with this small code:

import bpy

for x in bpy.data.textures:
    x.use_interpolation = False

Sometimes it works, especially for amounts of images less than 10-20, but usually it throws error:

AttributeError: 'Texture' object has no attribute 'use_interpolation'

$\endgroup$
0
$\begingroup$

Non blender internal textures

There may be some textures in blend that don't have the use_interpolation property. For example switch to cycles and add a new brush texture. bpy.data.textures["Texture"] the newly added one, doesn't.

Check whether the texture has the attribute with hasattr

>>> for t in bpy.data.textures:
...     t.name, hasattr(t, "use_interpolation")
...     
('dice', True)
('Tex', True)
('Texture', False)

Find all with that property, then set.

bi_textures = [t for t in bpy.data.textures if hasattr(t, "use_interpolation")]
for t in bi_textures:
    t.use_interpolation = False

or get the textures from the materials on the planes. Test code to get all textures on selected nesh objects

import bpy

context = bpy.context

textures = [ts.texture 
        for o in context.selected_objects if o.type == 'MESH'
        for m in o.data.materials 
        for ts in m.texture_slots if ts and ts.texture]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.