I am using auto2006 with .net.
Now I want to move entity.
there is a my code. something wrong.
can any body tell me the solution.
many thanks
static public void Move()
{
//Start Transaction-----------------------------------
Database acadDB =HostApplicationServices.WorkingDatabase;
Autodesk.AutoCAD.DatabaseServices.TransactionManager
acadTransmgr= acadDB.TransactionManager;
Transaction acadTrans = acadTransmgr.StartTransaction();
Editor ed = acadApp.DocumentManager.MdiActiveDocument.Editor ;
try
{
//Start Transaction-----------------------------------
PromptSelectionOptions selOpts = new PromptSelectionOptions();
PromptSelectionResult res;
selOpts.MessageForAdding = "Select an entity";
res = ed.GetSelection();
Autodesk.AutoCAD.EditorInput.SelectionSet SS=res.Value;
Point3d fromPt;
Point3d toPt;
PromptPointResult ptRes;
PromptPointResult ptTo;
ptRes = ed.GetPoint("Pick a from point");
fromPt = ptRes.Value;
ptTo = ed.GetPoint("Pick a to point");
toPt = ptTo.Value;
Vector3d moveVec = new Vector3d(toPt.X - fromPt.X, toPt.Y - fromPt.Y, toPt.Z - fromPt.Z);
ObjectId [] idarray = SS.GetObjectIds();
foreach (ObjectId id in idarray)
{
Entity ent = (Entity)acadTrans.GetObject(id, OpenMode.ForWrite, true);
Matrix3d moveMat = Matrix3d.Displacement(moveVec);
ent.TransformBy(ent.Ecs.PostMultiplyBy(moveMat));
}//end foreach
//end Transaction-----------------------------------------
acadTrans.Commit();
}catch(System.Exception ex)
{
ed.WriteMessage(ex.ToString());
acadTrans.Abort();
}
finally
{
acadTrans.Dispose();
}
//end Transaction-------------------------------
}//end move