I am trying to run shrinkwrap and then remesh modifier repeatedly but not working. It seems to me there is a infinite loop inside the code. I am new to blender and python coding. What is wrong with that code?

I am using Blender 3.6

import bpy

jaw = bpy.data.objects['jaw']

for i in range(0,20):
    bpy.context.object.modifiers["Shrinkwrap"].target = jaw
    bpy.context.object.modifiers["Shrinkwrap"].offset = 0.5

    bpy.context.object.modifiers["Remesh"].mode = 'SMOOTH'
    bpy.context.object.modifiers["Remesh"].use_remove_disconnected = False
    bpy.context.object.modifiers["Remesh"].octree_depth = 8

  • $\begingroup$ This is XY problem. Please specify what you are trying to accomplish, why would you want to add the modifier 20 times? $\endgroup$
    – Harry McKenzie
    Commented Sep 30, 2023 at 12:42
  • $\begingroup$ There is no infinite loop, the code is ok. Depending on the complexity of your mesh, it just may take a while to perform. Even for two simple cubes it takes some seconds. Add a print(i) statement in the loop to observe this in the system console. As @HarryMcKenzie already asked, what are you trying to achieve? $\endgroup$
    – taiyo
    Commented Sep 30, 2023 at 14:01

1 Answer 1



takes actual modifier name, which is unique for every modifier. What you are passing is modifier type.

Add modifier to selected and another to active object

See the above link.

In your specific case, you can get away using


As new modifiers are named that way.


You must log in to answer this question.

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