# Python script for “Cursor to Active”

I am making a python script that replace lights by spheres (to get the Blender light positions in Unity) for Dark Blender, but the script Cursor to Active command is specific to the 3d view so it does not compile from the text editor. What code should i write to make it work?

If a 3d view is not in local mode then bpy.ops.view3d.snap_cursor_to_active() is the equivalent of

context.scene.cursor_location = context.active_object.location


Could also just get the location from the lamps in the scene

import bpy

context = bpy.context
scene = context.scene

lamps = [o for o in scene.objects if o.type == 'LAMP']

for l in lamps:

lamps = context.selected_objects