I want to add a displacement modifier to the active object and set the source image in python when you press a button. How can I do this?


The code is

heightTex = bpy.data.textures.new('Texture name', type = 'IMAGE')
heightTex.image = bpy.data.images['Myimage.jpg']
dispMod = ob.modifiers.new("Displace", type='DISPLACE')
dispMod.texture = heightTex

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.