Skip to main content
removed unnecessary body content, grammar
Source Link
brockmann
  • 12.8k
  • 4
  • 51
  • 94

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?

I assume that this operation is not clear to me. When I add a new modifier, I would like 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 it does not work if the object in question, where the "Smooth" modifier is present, is not moved. On the contrary, if the object in question is active, it is moved 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 overwrite the context?

I saw a similar answer to this question, but I'm not sure it's my case, I would like to understand better. Although it appears that I am not getting any errors in my case.

Note:

It seems that I have solved my problem with this solution:

for m in ob.modifiers:
    c = {}
    c["object"] = c["active_object"] = ob
    bpy.ops.object.modifier_move_down(c ,modifier = smooth.name)

I understand 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

I would like to move a modifier (which I have already identified) to the bottom of the list of existing modifiers. Unfortunately it does not work and I don't get why...? However, if the object is active, it moves perfectly to the bottom:

#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 override the context? There is a similar question to this but I have no idea how to apply this in my case.

 

It seems that I have solved my problem by 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)

Any thoughts? Is there a better way of doing that?

edited title
Link
brockmann
  • 12.8k
  • 4
  • 51
  • 94

How to move a modifiermodifiers of multiple objects up or down with Python?

added 393 characters in body
Source Link
Noob Cat
  • 1.4k
  • 3
  • 25
  • 67

I assume that this operation is not clear to me. When I add a new modifier, I would like 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 it does not work if the object in question, where the "Smooth" modifier is present, is not moved. On the contrary, if the object in question is active, it is moved 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 overwrite the context?

I saw a similar answer to this question, but I'm not sure it's my case, I would like to understand better. Although it appears that I am not getting any errors in my case.

Note:

It seems that I have solved my problem with this solution:

for m in ob.modifiers:
    c = {}
    c["object"] = c["active_object"] = ob
    bpy.ops.object.modifier_move_down(c ,modifier = smooth.name)

I understand 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

I assume that this operation is not clear to me. When I add a new modifier, I would like 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 it does not work if the object in question, where the "Smooth" modifier is present, is not moved. On the contrary, if the object in question is active, it is moved 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 overwrite the context?

I saw a similar answer to this question, but I'm not sure it's my case, I would like to understand better. Although it appears that I am not getting any errors in my case.

I assume that this operation is not clear to me. When I add a new modifier, I would like 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 it does not work if the object in question, where the "Smooth" modifier is present, is not moved. On the contrary, if the object in question is active, it is moved 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 overwrite the context?

I saw a similar answer to this question, but I'm not sure it's my case, I would like to understand better. Although it appears that I am not getting any errors in my case.

Note:

It seems that I have solved my problem with this solution:

for m in ob.modifiers:
    c = {}
    c["object"] = c["active_object"] = ob
    bpy.ops.object.modifier_move_down(c ,modifier = smooth.name)

I understand 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

grammar, more specific title
Source Link
Ray Mairlot
  • 29.4k
  • 12
  • 105
  • 126
Loading
Source Link
Noob Cat
  • 1.4k
  • 3
  • 25
  • 67
Loading