def execute(self, context):
wm = context.window_manager
scene = context.scene
o = scene.objects.active
# calculationg the new position of the active object center
v = -Vector((wm["_x"], wm["_y"], o.location.z))
p = o.matrix_world * v
projection = TransverseMercator(lat=scene["lat"], lon=scene["lon"])
(lat, lon) = projection.toGeographic(p[0], p[1])
scene["lat"] = lat
scene["lon"] = lon
scene["heading"] = (o.rotation_euler[2]-wm["_h"])*180/math.pi
# restoring original objects location and orientation
bpy.ops.transform.rotate(value=-(o.rotation_euler[2]-wm["_h"]), axis=(0,0,1))
bpy.ops.transform.translate(value=-(o.location+v))
# cleaning up
del wm["_x"], wm["_y"], wm["_h"]
return {"FINISHED"}
评论列表
文章目录