Closed KirilStrezikozin closed 6 months ago
Using the meshes listed in behavior 2a above, the built-in bpy.context.selected_objects
contains objects of order put into BakeMaster (BakeMaster itself does not contain any order manipulations unless name matching is used):
# Console input:
>>> C.selected_objects
# Console Output:
[
bpy.data.objects['Circle'],
bpy.data.objects['Sphere'],
bpy.data.objects['Plane'],
bpy.data.objects['Torus']
]
The type of bpy.context.selected_objects
is <class 'list'>
. Lists are ordered:
assert type(C.selected_objects) == list
It is noticeable that the order of objects in bpy.context.selected_objects
is the order they were edited to a scene. Thus, a conclusion is that BakeMaster adds objects from Blender Outliner in the order these objects were added to a Blender scene in the first place.
Blender Outliner has an Alphabetic Sorting option that is defined in each Outliner area.
~Introduce a property in BakeMaster Addon Preferences~ The best idea is to adapt to each situation. Every time the BakeMaster Object Add operator is called (and name matching is not used), find the first Outliner area in the current screen. If it has alphabetic object sorting, add selected objects to BakeMaster via:
sorted(C.selected_objects, key=lambda x: x.name)
If it doesn't have alphabetic sorting, plain add objects to BakeMaster. Overall, this way BakeMaster adds objects in the order they are in the Outliner, which makes it more convenient and visually appealing to the user.
This bug report is:
Describe the bug When multiple objects are added to BakeMaster, they do not follow the order they had in Blender Outliner.
To Reproduce Steps to reproduce the behavior:
Expected behavior Should the order of objects be preserved?
Screenshots 1a. Order in the Outliner: 1b. Order in BakeMaster:
The reason probably is BakeMaster respects the alphabetical order of Meshes:
The behavior of the following case is unknown: 2a. Order in the Outliner: 2b. Order in BakeMaster:
Desktop (please complete the following information):
Additional context Found and reported by @KirilStrezikozin.