I would like to snap the 3D-cusor to an object. After that I would like to copy another object to the position of the 3D-cursor. The code is as follow:
Code sample:
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
ctx = bpy.context.copy()
ctx['area'] = area
ctx['region'] = area.regions[-1]
bpy.ops.view3d.view_selected(ctx)
bpy.ops.view3d.snap_cursor_to_selected()
obj.select = False
new_obj.select = True
bpy.context.scene.objects.active = new_obj
bpy.ops.view3d.snap_selected_to_cursor(use_offset=False)
break
Python error is:
RuntimeError: Operator bpy.ops.view3d.snap_cursor_to_selected.poll() failed, context is incorrect
Modified code sample:
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
ctx = bpy.context.copy()
ctx['area'] = area
ctx['region'] = area.regions[-1]
bpy.ops.view3d.view_selected(ctx)
bpy.ops.view3d.snap_cursor_to_selected(ctx, use_offset=False)
obj.select = False
new_obj.select = True
bpy.context.scene.objects.active = new_obj
bpy.ops.view3d.snap_selected_to_cursor(use_offset=False)
break
Python message:
TypeError: Converting py args to operator properties: : keyword "use_offset" unrecognized
I use Blender 2.77a. What can I do? Many thanks for our help.
snap_cursor_to_selected(ctx)
and so on $\endgroup$bpy.ops.view3d.snap_selected_to_cursor(ctx, use_offset=False)
also ? $\endgroup$