I'd like to group curves by color, so I'm try to join them together. I used an override from this solution. Everything works splendid inside Blender but in my external program I have
AttributeError: 'ID' object has no attribute 'data'
This is function:
def curvegroup():
for crvobj in bpy.data.objects:
if re.match(r'^curve', crvobj.data.name):
crvs = []
color = crvobj.active_material.diffuse_color
for crvobjcol in bpy.data.objects:
if re.match(r'^curve', crvobjcol.data.name):
if (crvobjcol.active_material.diffuse_color == color):
crvs.append(crvobjcol)
ctx = bpy.context.copy()
ctx['active_object'] = crvs[0]
ctx['selected_objects'] = crvs
ctx['selected_editable_bases'] = [scene.object_bases[crv.name] for crv in crvs]
bpy.ops.object.join(ctx)
I am not sure that I understand scene.object_bases so I really don't know why ID object is there and what cause this error.
Another method causes Error: EXCEPTION_ACCESS_VIOLATION
def curvegroup02():
for crvobj in bpy.context.scene.objects:
bpy.ops.object.select_all(action='DESELECT')
if re.match(r'^Curve', crvobj.name):
scene.objects.active = crvobj
color = crvobj.active_material.diffuse_color
for crvobjcol in bpy.context.scene.objects:
if re.match(r'^Curve', crvobjcol.data.name):
if (crvobjcol.active_material.diffuse_color == color):
crvobjcol.select = True
for selected in bpy.context.selected_objects:
if selected.type == 'CURVE':
if (bpy.ops.object.join.poll()):
bpy.ops.object.join()
type
field. Collecting all curves[object for object in bpy.data.objects if object.type == 'CURVE']
for example $\endgroup$