I assume that this operation is not clear to me. When I add a new modifier, I would like to move a modifier (which I have already identified) to be moved to the bottom of the list of existing modifiers. I am trying to move it, but I see that Unfortunately it does not work if the object in question, where the "Smooth" modifier is present, is not movedand I don't get why. On the contrary..? However, if the object in question is activeactive, it is movedmoves perfectly to the bottom.
I am using:
#ob = my object, not necessarily it must be selected, it is found by a function
#smooth = #my modifier (found through a function)
for m in ob.modifiers:
bpy.ops.object.modifier_move_down(modifier = smooth.name)
This only works if the active object is ob
.
Do I have to overwriteoverride the context?
I saw There is a similar answer to thissimilar question to this question, but I'm not sure it's my case, I would likehave no idea how to understand better. Although it appears that I am not getting any errorsapply this in my case.
Note:
It seems that I have solved my problem with this solutionby overriding the context members:
for m in ob.modifiers:
c = {}
c["object"] = c["active_object"] = ob
bpy.ops.object.modifier_move_down(c ,modifier = smooth.name)
I understandAny thoughts? Is there a better way of doing that the "for" loop method is not the best, as it may already be almost at the bottom, so it would "Move down" many more times than you need?