Is there any way to set a modifier or constraints index in the stack without using bpy.ops?
The idea is to easily reformat the stack order of constraint.
An example could be to re-order constraints alphabetically
Asked
Active
Viewed 1,321 times
8
1 Answers
6
Sadly no. I ran in to the same limitation when trying to sort logic bricks.
The constraints, modifiers, and logic bricks are all read only collections.
The only way to reorder them is through the ops operators, moving one at a time, up or down one place. (which stinks for any scripting)
For constraints it is:
bpy.ops.constraint.move_up(constraint="constraintName", owner='OBJECT')
bpy.ops.constraint.move_down(constraint="constraintName", owner='OBJECT')
For modifier it is:
bpy.ops.object.modifier_move_up(modifier="modifierName")
bpy.ops.object.modifier_move_down(modifier="modifierName")
For logic bricks it is:
bpy.ops.logic.sensor_move(sensor="logicBrickName", object="objName", direction='UP')
bpy.ops.logic.actuator_move(actuator="logicBrickName", object="objName", direction='UP')
bpy.ops.logic.controller_move(controller="logicBrickName", object="objName", direction='UP')
bpy.ops.logic.sensor_move(sensor="logicBrickName", object="objName", direction='DOWN')
bpy.ops.logic.actuator_move(actuator="logicBrickName", object="objName", direction='DOWN')
bpy.ops.logic.controller_move(controller="logicBrickName", object="objName", direction='DOWN')
You probably would not want to reorder constraints or modifiers alphabetically. Both constraints and modifiers work from the top down, the order effects the out come.
Here is an example with the exact same modifiers and default settings, just the order is reversed. Stack order makes a huge difference.


David
- 49,291
- 38
- 159
- 317
-
Thanks for the answer, that's what i thought. About alphabetical order, that was just an example to explain the need ;). Waiting before validation, in case someone come with a magic solution! – Boris Oct 05 '15 at 00:24
-
I would love a "magic solution," but have looked (I made a logic brick addon) and there is none. :( – David Oct 05 '15 at 13:37
-
1Seems right, nothin magic happened. Thanks again – Boris Oct 06 '15 at 13:53
-
@David is there anyway I can put the modifier at the top of the stack? – Omar Emara Feb 08 '16 at 10:57
-
@OmarAhmad short answer is yes. But it takes more python then I could fit in to a comment. ask a question, and I'll answer with the script. – David Feb 08 '16 at 22:10