Problem with cursor to selected

Hello,

First of all let me start by saying I am very new to Python so I am guessing this is something I am doing, but I can’t figure it out.

I would like to make an extremely basic script that moves all selected objects to the active object. Normal workflow would be set the cursor to active followed by move selected to cursor. The info window shows the following commands:

bpy.ops.view3d.snap_cursor_to_selected()
bpy.ops.view3d.snap_selected_to_cursor(use_offset=False)

When I type these into the python console, I get the following error(s)

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "C:\Users\ai\Programs\blender-2.68-r58800-win64\2.68\scripts\modules\bpy\ops.py", line 188, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.view3d.snap_selected_to_cursor.poll() failed, context is incorrect

Is this something I am doing, or is there a different problem here?

@rcpongo
http://blenderpythonscripts.wordpress.com/category/addon/

try to use this addon. It’s not perfect now, but you can use some scripts.

how about this:

C = bpy.context
ob_act = C.object # active object

for ob in C.selected_editable_objects:
    if ob == ob_act: continue
    ob.location = ob_act.location