# bpy.ops.view3d functions not throwing errors but not working

The paste is here, but since the not working part is only one line I'll paste it here

bpy.ops.view3d.snap_selected_to_cursor(ctx, use_offset=True)


The code used to work perfectly, but as it always is, I changed something a hundred lines up and now that line doesn't work. For a while it used to move the last created object, but now I force deselect created objects after I'm done processing them. When the code runs, it generates everything correctly and all objects that should be selected are selected, but it doesn't snap to the cursor. I know that it should work not only because it used to but also because after the code runs I can just move the mouse over and do the command manually, but that's not the point of having an autonomous script. It may also be worth noting that no other view3d functions seem to do anything either, no errors but no effect.

Upon further testing of printing what ctx to the console, the objects show up so it should be the correct context.

• In case nobody wanted to answer this, a workaround for any interested is (empty is the variable referring to an object that they are all children of) average = mathutils.Vector((0,0,0)) for child in empty.children: average += (child.location)/ len(empty.children) for child in empty.children: child.location -= average – Neywiny Aug 15 '17 at 0:37
• Hi. Either put the additional information in the question or if you view it as the solution, then post it as an answer. Putting code as a comment isn't really readable. Secondly, either that 'paste' is not relevant and should be removed or it is relevant and should be part of the question body (the relevant parts/a cut down version that shows the problem). – Ray Mairlot Aug 15 '17 at 11:23
• well it's not the solution, so I didn't put it as one and shouldn't be perceived as one since it doesn't solve the problem. Also, some people like to view the entire code, so I think a single line in the bottom of the question is allowed to be there. I made it pretty clear that that line is the only one that's not working, but sometimes it's something much further up that changes a setting or something. – Neywiny Aug 15 '17 at 13:46
• External links, whether intentionally or not, can go down, at which point the question will no longer have the relevant code attached. That is why I suggest adding the relevant parts into the question body. I have never seen someone request seeing the whole code, only the parts that relate to the question and still demonstrate the problem. – Ray Mairlot Aug 15 '17 at 14:19
• Seriously? Nobody on the blender stack exchange does that? I've been on stack exchanges and forums for years, and every single one of them requires you to post the entire code. That's very interesting. – Neywiny Aug 15 '17 at 14:49