I am using Python to create some shapes in blender. I want to group these shapes together and use the following code to do that:
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 I can join them to an 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
it doesn't select any objects within the group.
You should be using
bpy.context.scene.objects['objName'].select
before calling select_same_group
. Hope it helps.
You have an uppercase 'For' that should be 'for' as @Antoni4040 mentioned in the comments.
If this is not the problem, please paste the error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.