import sys, dia def center_objects (objs) : r = objs[0].bounding_box cx = (r.right + r.left) / 2 cy = (r.bottom + r.top) / 2 for o in objs[1:] : r = o.bounding_box (x, y) = o.properties["obj_pos"].value dx = (r.right + r.left) / 2 - cx dy = (r.bottom + r.top) / 2 - cy o.move (x - dx, y - dy) def dia_objects_center_cb (data, flags) : grp = data.get_sorted_selected() if (len(grp) > 1) : center_objects (grp) data.update_extents () dia.active_display().diagram.add_update_all() dia.register_callback ("Center Objects", "/Objects/Center", dia_objects_center_cb)