The title says it all.
I have an empty that I want to move to the 3D cursor while maintaining its orientation.
I’m sure this is simple but I’m new to Python.
bl_info = {
"name": "Add WCS",
"description": "Adds a WCS for view management",
"author": "Tim Frank (tfrank)",
"version": (0,0,1),
"blender": (2, 5, 7),
"api": 35853,
"location": "View3D > Add > Mesh > WCS",
"warning": '', # used for warning icon and text in addons panel
"wiki_url": "",
"tracker_url": "",
"category": "Add Mesh"}
import bpy
import mathutils
from math import *
from bpy.props import *
def Add_WCS():
#Add an Empty to the Scene
bpy.ops.object.add(type='EMPTY', view_align=True, layers=(True, False,
False, False, False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False))
#Remname the Empty
empty = bpy.context.object
empty.name = "WCS"
bpy.context.active_object.location(2,2,0)
class AddWCS(bpy.types.Operator):
bl_idname = "mesh.primitive_wcs_add"
bl_label = "Add WCS"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
Add_WCS()
return {'FINISHED'}
# Register the operator
def menu_func(self, context):
self.layout.operator(AddWCS.bl_idname, text="WCS", icon='PLUGIN')
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_mesh_add.append(menu_func)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_mesh_add.remove(menu_func)
if __name__ == "__main__":
register()