How to Mirror MText Using AutoCAD api in c#?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The first Image showing the AutoCAD mirror command output :
Second Image: We implemented the following code and get this output.
Can you help us, what we are missing in this implementation? while mirroring MText using Matrix3d.Mirroring(line) API.
We are using the following code for mirroring :
DocuclonedEntitynt doc =
Autodesk.AutoCAD.ApplicationServices.Application.DocuclonedEntityntManager.MdiActiveDocument
clonedEntitynt Matrix3d mtrx3d = Matrix3d.Mirroring(line);
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
try
{
// Get the entity to mirror
Entity entity = tr.GetObject(id, OpenMode.ForRead) as Entity;
mirroredEntity = entity;
// Clone it
Entity clonedEntity = entity.Clone() as Entity;
// Apply the mirror transformation
clonedEntity.TransformBy(mtrx3d);
// Add mirrored entity to the database
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
btr.AppendEntity(clonedEntity);
tr.AddNewlyCreatedDBObject(clonedEntity, true);
if (erase)
{
// Finally erase the original entity (if needed)
entity.UpgradeOpen();
entity.Erase();
mirroredEntity = clonedEntity;
}
}
catch (System.Exception ex)
{
}
tr.Commit();