Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/modules/sbstudio/plugin/operators/update_formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def collect_objects_and_points_for_formation_update(selection, name):
obj: [Vector()] for obj in Collections.find_drones().objects
}
elif selection == "SELECTED_OBJECTS":
objects.extend(get_selected_objects())
objects.extend(get_selected_objects(sort = True))
elif selection == "POSITIONS_OF_SELECTED_OBJECTS":
points_in_local_coords = {obj: [Vector()] for obj in get_selected_objects()}
points_in_local_coords = {obj: [Vector()] for obj in get_selected_objects(sort = True)}
elif selection == "POSITIONS_OF_SELECTED_VERTICES":
points_in_local_coords = {
obj: [point.co for point in points]
Expand Down
7 changes: 5 additions & 2 deletions src/modules/sbstudio/plugin/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_selected_drones(*, context: Optional[Context] = None):


@with_context
def get_selected_objects(*, context: Optional[Context] = None):
def get_selected_objects(*, sort = False, context: Optional[Context] = None):
"""Returns the list of selected objects in the given context.

When the context is in object mode, all the objects currently selected in
Expand All @@ -58,7 +58,10 @@ def get_selected_objects(*, context: Optional[Context] = None):
the list of selected objects, taking into account the current mode
"""
if context.mode == "OBJECT":
return context.selected_objects
if sort:
return sorted(context.selected_objects, key=lambda obj: obj.name)
else:
return context.selected_objects
else:
active_object = context.active_object
return [active_object] if active_object else []
Expand Down