Blender_bevy_components_wor.../tools/blenvy/bevy_components/utils.py
kaosat.dev dc7422fe7a feat(blenvy): components can now also be added to collections/blueprints directly
* this is in preparation for future support in bevy & for more coherence & practicality
 * overhauled metadata tooling
 * overhauled most of the operators
 * overhauled most of the UI
 * all the basics & more work !
 * unrelated: also started preping for auto_export operator removal
2024-05-19 23:35:12 +02:00

18 lines
532 B
Python

import bpy
#FIXME: does not work if object is hidden !!
def get_selected_object_or_collection(context):
target = None
object = next(iter(context.selected_objects), None)
collection = context.collection
if object is not None:
target = object
elif collection is not None:
target = collection
return target
def get_selection_type(selection):
if isinstance(selection, bpy.types.Object):
return 'Object'
if isinstance(selection, bpy.types.Collection):
return 'Collection'