Python Blender selects an object inside the same group?

I use Python to create some shapes in blender. I want to group these shapes together and use the following code to do this:

import bpy bpy.ops.group.create(name= "NewGroup") bpy.ops.object.group_link(group="NewGroup") For i in range (1,3,1): tempobject = bpy.data.objects["Cube" + str(i)] bpy.context.scene.objects.active=tempobject bpy.ops.object.group_link(group="NewGroup") 

When I try to select a group so that I can join it with the active object:

  host_object = bpy.data.objects["Cube1"] bpy.context.scene.objects.active=host_object bpy.ops.object.select_same_group(group="NewGroup") bpy.ops.object.join() # all selected objects join to active object 

he does not select any objects within the group.

+6
source share
2 answers

You have to use

 bpy.context.scene.objects['objName'].select 

before calling select_same_group . Hope this helps.

0
source

You have an uppercase "For", which should be a "for", as indicated in the comments to @ Antoni4040.

If this is not a problem, insert the error.

0
source

All Articles