public static double AngleFromXY(Point3d pt1, Point3d pt2, Editor ed)
{
Matrix3d ucsmtx = ed.CurrentUserCoordinateSystem;
CoordinateSystem3d ucs = ucsmtx.CoordinateSystem3d;
Plane ucsplane = new Plane(ucs.Origin, ucs.Xaxis, ucs.Yaxis);
Vector3d vec = pt2 - pt1;
double ang = vec.AngleOnPlane(ucsplane);
return ang;
}