-
-
Save DarthMoulByte/8bb1b7090156771058340fab3b1d39c8 to your computer and use it in GitHub Desktop.
blender-selectRandomObjectInGroup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy | |
| from random import choice | |
| scene = bpy.context.scene | |
| ob = bpy.context.object | |
| random_group = choice(ob.users_group) | |
| obs = random_group.objects[:] | |
| obs.remove(ob) | |
| try: | |
| random_ob = choice(obs) | |
| except IndexError: | |
| # no other object in chosen group | |
| pass | |
| #bpy.ops.object.select_all(action='DESELECT') | |
| for ob in scene.objects: | |
| ob.select = False | |
| random_ob.select = True | |
| bpy.context.scene.objects.active = random_ob |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment