For an MText that is annotative, its positions can be changed using its grip. The position is specific to the current annotative scale of the drawing. The API to set the position of an annotative entity for each scale programmatically is not available at present as part of the public API. A way to workaround this is to set the drawing annotation scale before changing the position. Here is a sample code to iterate the object context collection of the database and set the position of an MText for each scale.
Document doc =
Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions peo
= new PromptEntityOptions("\\nSelect an MText : " );
peo.SetRejectMessage("\\nMust be an MText ..." );
peo.AddAllowedClass(typeof (MText), true );
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
return ;
ObjectId mtId = per.ObjectId;
ObjectContextManager ocm = db.ObjectContextManager;
ObjectContextCollection occ
= ocm.GetContextCollection("ACDB_ANNOTATIONSCALES" );
if (ocm == null )
return ;
foreach (ObjectContext oc in occ)
{
using (Transaction tr
= db.TransactionManager.StartTransaction())
{
MText mt
= tr.GetObject(mtId, OpenMode.ForRead) as MText;
Point3d pos = mt.Location;
if (mt.HasContext(oc))
{
AnnotationScale annoScale
= oc as AnnotationScale;
if (annoScale != null )
db.Cannoscale = annoScale;
mt.UpgradeOpen();
mt.Location = pos
+ Vector3d.XAxis * 3
+ Vector3d.YAxis * 3;
}
tr.Commit();
}
}
Here are two screenshots showing the scale specific positions before and after the change