it does not work in general, but it is a starting point:
//
// only test code...
// does only work in a few cases...
// g.s
//
var obj = document.selectedItems[0];
var center = obj.bounds.center;
var corner1 = obj.curves[0].point1;
var corner2 = obj.curves[1].point1;
var refPoint = new Point(corner2.x,corner1.y);
print(corner1);
print(corner2);
document.createCircle(corner1, 3);
document.createCircle(corner2, 3);
document.createCircle(refPoint, 3);
var ak = refPoint.getDistance(corner2);
var gk = refPoint.getDistance(corner1);
var tan = gk / ak;
var angle = Math.atan(tan);
print(angle);
var refRect = document.createRectangle(Rectangle(0, 0, 50, 50));
refRect.rotate(angle,refRect.bounds.center);
look at these for some explanation: http://img518.imageshack.us/img518/9151/rotatell2.gif
i think there is a better way to go, but this was my first idea how to solve the problem.
i'd like to see other solutions...
greetings
g.s