- Messages
- 195
- Country
I'm trying to run a script for Blender in order to speed up modelling but the script was for previous versions of blender. Specifically, the line "bpy.context.scene.objects.active" (bold) is supposedly no longer used by Blender. I don't quite understand what I should replace that line with in order to fix the script for Blender 2.8. There were also similar issues for the VIEW3D lines. If you're curious about this script, it came from Austin Sass (no longer active unfortunately so he couldn't answer these questions)
Error Message: AttributeError: bpy_prop_collection: attribute "active" not found
Error Message:
File "C:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\modules\bpy\ops.py", line 199, in __call__
ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
AttributeError: Calling operator "bpy.ops.view3d.viewnumpad" error, could not be found
Script:
import bpy
template = 'Loft 2.5'
selected = bpy.context.selected_objects
for o in selected:
o.data.bevel_object = bpy.data.objects['Loft 2.5']
for o in selected:
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.context.scene.objects.active = o
bpy.ops.object.convert(target='MESH')
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
o.data.polygons[0].select = True;
bpy.ops.object.mode_set(mode = 'EDIT')
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
override = bpy.context.copy()
override['area'] = area
bpy.ops.view3d.viewnumpad(override, type='TOP', align_active=True)
break
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.mesh.select_all(action = 'TOGGLE')
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for region in area.regions:
if region.type == 'WINDOW':
override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object}
bpy.ops.uv.follow_active_quads()
break
bpy.ops.object.mode_set(mode = 'OBJECT')
EDIT (SOLUTION): Here is the corrected script for Blender 2.8
import bpy
template = 'template'
selected = bpy.context.selected_objects
for o in selected:
o.data.bevel_object = bpy.data.objects['template']
for o in selected:
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.context.view_layer.objects.active = o
bpy.ops.object.convert(target='MESH')
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
o.data.polygons[0].select = True;
bpy.ops.object.mode_set(mode = 'EDIT')
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
override = bpy.context.copy()
override['area'] = area
bpy.ops.view3d.view_axis(override, type='TOP', align_active=True)
break
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.mesh.select_all(action = 'TOGGLE')
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for region in area.regions:
if region.type == 'WINDOW':
override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object}
bpy.ops.uv.follow_active_quads()
break
bpy.ops.object.mode_set(mode = 'OBJECT')
Error Message: AttributeError: bpy_prop_collection: attribute "active" not found
Error Message:
File "C:\Program Files\Blender Foundation\Blender 2.82\2.82\scripts\modules\bpy\ops.py", line 199, in __call__
ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
AttributeError: Calling operator "bpy.ops.view3d.viewnumpad" error, could not be found
Script:
import bpy
template = 'Loft 2.5'
selected = bpy.context.selected_objects
for o in selected:
o.data.bevel_object = bpy.data.objects['Loft 2.5']
for o in selected:
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.context.scene.objects.active = o
bpy.ops.object.convert(target='MESH')
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
o.data.polygons[0].select = True;
bpy.ops.object.mode_set(mode = 'EDIT')
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
override = bpy.context.copy()
override['area'] = area
bpy.ops.view3d.viewnumpad(override, type='TOP', align_active=True)
break
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.mesh.select_all(action = 'TOGGLE')
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for region in area.regions:
if region.type == 'WINDOW':
override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object}
bpy.ops.uv.follow_active_quads()
break
bpy.ops.object.mode_set(mode = 'OBJECT')
EDIT (SOLUTION): Here is the corrected script for Blender 2.8
bevel_selected_objects_and_unwrap_2.8.txt
drive.google.com
template = 'template'
selected = bpy.context.selected_objects
for o in selected:
o.data.bevel_object = bpy.data.objects['template']
for o in selected:
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.context.view_layer.objects.active = o
bpy.ops.object.convert(target='MESH')
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.object.mode_set(mode = 'OBJECT')
o.data.polygons[0].select = True;
bpy.ops.object.mode_set(mode = 'EDIT')
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
override = bpy.context.copy()
override['area'] = area
bpy.ops.view3d.view_axis(override, type='TOP', align_active=True)
break
bpy.ops.mesh.select_all(action = 'DESELECT')
bpy.ops.mesh.select_all(action = 'TOGGLE')
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for region in area.regions:
if region.type == 'WINDOW':
override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object}
bpy.ops.uv.follow_active_quads()
break
bpy.ops.object.mode_set(mode = 'OBJECT')
Last edited: