Have a play with this Mick.
There is a lot more here than you need, but ... too bad

Note that there are a lot of verbose calls to explicit namespaces.class's that could be trimmed. I Used those 'cause they help my visualisation and understanding.
I have the solution split into 2 files, one for the problem, and one Utility Helper. .. as I mentioned there is more here than needed, so lurkers needn't get too frightened by the amount of code.
Some of the functionality is based on Jim's MgdDbg Samples.
This was developed in VSC#2005 and tested in AC2006
The solution seems to work for me ..
You will see that I have been separating the type declaration and initialiser onto separate lines .. similarly the Method declarations.
This is just a formatting preference to try and keep the displayed code block at about 80 characters wide. .. just personal style, easily changed without affecting functionality ..
The Main :..
using System;
using System.Diagnostics;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using kwbAC.Utils;
public class TestXMent
{
[CommandMethod("xment", CommandFlags.Modal)]
public static void
MoveEntity()
{
//Set up some tools
Editor
ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
try
{
//get user input
PromptEntityResult
entityRes = ed.GetEntity("Select entity to translate/move:\n");
if (entityRes.Status != PromptStatus.OK)
return;
//----------------------------
PromptPointResult
fromPointRes = ed.GetPoint("Move From point...");
if (fromPointRes.Status != PromptStatus.OK)
return;
//----------------------------
PromptPointOptions
PPOptions = new PromptPointOptions("\nTo point or <use first point as displacement>");
PPOptions.UseBasePoint = true;
PPOptions.BasePoint = fromPointRes.Value;
PPOptions.UseDashedLine = true;
PPOptions.AllowNone = true;
PromptPointResult
toPointRes = ed.GetPoint(PPOptions);
Vector3d transVec = new Vector3d();
if (toPointRes.Status == PromptStatus.OK)
transVec = toPointRes.Value - fromPointRes.Value;
else if (toPointRes.Status == PromptStatus.None)
transVec = toPointRes.Value.GetAsVector();
else
return;
//----------------------------
OutputPoints(fromPointRes.Value, toPointRes.Value);
Mover(entityRes.ObjectId, Matrix3d.Displacement(Db.UcsToWcs(transVec)));
}
catch (System.Exception ex)
{
// rethrow it for now
throw ex;
}
finally
{
//
}
}
public static void
OutputPoints(Point3d fromPoint, Point3d toPoint)
{
AUi.PrintToCmdLine("\nFrom Point in UCS: "
+ (AUi.PointToString(fromPoint)));
AUi.PrintToCmdLine("\nFrom Point in WCS: "
+ (AUi.PointToString(Db.UcsToWcs(fromPoint))) + "\n");
AUi.PrintToCmdLine("\nTo Point in UCS: "
+ (AUi.PointToString(toPoint)));
AUi.PrintToCmdLine("\nTo Point in WCS: "
+ (AUi.PointToString(Db.UcsToWcs(toPoint))) + "\n");
}
public static void
Mover(ObjectId id, Matrix3d m)
{
Database
db = (id.Database);
Autodesk.AutoCAD.DatabaseServices.TransactionManager
tm = db.TransactionManager;
using (Transaction
tr = tm.StartTransaction())
{
Entity
ent = (Entity)tm.GetObject(id, OpenMode.ForWrite, true);
ent.TransformBy(m);
tr.Commit();
}
}
}
The Helpers : ..
using System;
using System.Diagnostics;
using System.Collections;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace kwbAC.Utils
{
public class AUi
{
// User Interface Helper Constructor
AUi()
{
}
//----------------------------
public static void
PrintToCmdLine(string str)
{
Autodesk.AutoCAD.EditorInput.Editor
ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage(str);
}
public static string
PointToString(Point3d pt, DistanceUnitFormat unitType, int prec)
{
string x = Autodesk.AutoCAD.Runtime.Converter.DistanceToString(pt.X, unitType, prec);
string y = Autodesk.AutoCAD.Runtime.Converter.DistanceToString(pt.Y, unitType, prec);
string z = Autodesk.AutoCAD.Runtime.Converter.DistanceToString(pt.Z, unitType, prec);
return string.Format("({0}, {1}, {2})", x, y, z);
}
public static string
PointToString(Point3d pt)
{
return PointToString(pt, Autodesk.AutoCAD.Runtime.DistanceUnitFormat.Current, -1);
}
}
//------------------------------------------------------------------------
public class Db
{
// DataBase Helper Constructor
public Db()
{
}
//----------------------------
public static Database
GetCurDatabase()
{
Database
db = AcadApp.DocumentManager.MdiActiveDocument.Database;
return db;
}
public static Autodesk.AutoCAD.DatabaseServices.TransactionManager
GetTransactionManager(Database db)
{
Autodesk.AutoCAD.DatabaseServices.TransactionManager
tm = db.TransactionManager;
return tm;
}
//----------------------------
public static bool
IsPaperSpace(Database db)
{
Debug.Assert(db != null);
if (db.TileMode)
return false;
Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
if (db.PaperSpaceVportId == ed.CurrentViewportObjectId)
return true;
return false;
}
public static Matrix3d
GetUcsMatrix(Database db)
{
Debug.Assert(db != null);
Point3d origin;
Vector3d xAxis, yAxis, zAxis;
if (IsPaperSpace(db))
{
origin = db.Pucsorg;
xAxis = db.Pucsxdir;
yAxis = db.Pucsydir;
}
else
{
origin = db.Ucsorg;
xAxis = db.Ucsxdir;
yAxis = db.Ucsydir;
}
zAxis = xAxis.CrossProduct(yAxis);
return Matrix3d.AlignCoordinateSystem(Ge.kOrigin,
Ge.kXAxis, Ge.kYAxis, Ge.kZAxis,
origin, xAxis, yAxis, zAxis);
}
public static Point3d
UcsToWcs(Point3d pt)
{
Matrix3d m = GetUcsMatrix(GetCurDatabase());
return pt.TransformBy(m);
}
public static Vector3d
UcsToWcs(Vector3d vec)
{
Matrix3d m = GetUcsMatrix(GetCurDatabase());
return vec.TransformBy(m);
}
public static Point3d
WcsToUcs(Point3d pt)
{
Matrix3d m = GetUcsMatrix(GetCurDatabase());
return pt.TransformBy(m.Inverse());
}
}
//------------------------------------------------------------------------
public class Ge
{
// predefined constants for common angles
public const double kPi = 3.14159265358979323846;
public const double kHalfPi = 3.14159265358979323846 * 0.50;
public const double kTwoPi = 3.14159265358979323846 * 2.00;
public const double kRad0 = 0.0;
public const double kRad45 = 3.14159265358979323846 * 0.25;
public const double kRad90 = 3.14159265358979323846 * 0.50;
public const double kRad135 = 3.14159265358979323846 * 0.75;
public const double kRad180 = 3.14159265358979323846;
public const double kRad270 = 3.14159265358979323846 * 1.5;
public const double kRad360 = 3.14159265358979323846 * 2.0;
// predefined values for common Points and Vectors
public static readonly Point3d kOrigin = new Point3d(0.0, 0.0, 0.0);
public static readonly Vector3d kXAxis = new Vector3d(1.0, 0.0, 0.0);
public static readonly Vector3d kYAxis = new Vector3d(0.0, 1.0, 0.0);
public static readonly Vector3d kZAxis = new Vector3d(0.0, 0.0, 1.0);
// Geometry Helper Constructor
public Ge()
{
}
public static double
RadiansToDegrees(double rads)
{
return rads * (180.0 / kPi);
}
public static double
DegreesToRadians(double degrees)
{
return degrees * (kPi / 180.0);
}
}
}