Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I've been working on a function that will insert text into the active document and I wanted to edit the attachment point. I've tried it two different ways, but I am still seeing the eInvalidInput error. The function that I have written is as follows:
internal static void AddSomeText(string txt, double txtHeight ,Point3d txtLoc, string layerName)
{
//call func to create layer name, in case it's not in there yet
AssignLayer(layerName);
//document and database
acAppServ.Document acDoc = acAppServ.Application.DocumentManager.MdiActiveDocument;
Database acCurDB = acDoc.Database;
//transaction
using (Transaction acTr = acCurDB.TransactionManager.StartTransaction())
{
using (DocumentLock docLock = acDoc.LockDocument())
{
//block table and block table record
BlockTable acBlkTbl = acTr.GetObject(acCurDB.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord acBlkTblRec = acTr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
//create multiline text object
using (MText acMText = new MText())
{
acMText.Location = txtLoc;
acMText.TextHeight = txtHeight;
acMText.Layer = layerName;
//acMText.Attachment = AttachmentPoint.MiddleAlign;
acMText.SetAttachmentMovingLocation(AttachmentPoint.MiddleAlign);
acMText.Contents = txt;
acBlkTblRec.AppendEntity(acMText);
acTr.AddNewlyCreatedDBObject(acMText, true);
}
}
acTr.Commit();
}
acAppServ.Application.DocumentManager.MdiActiveDocument.Editor.Regen();
}Where acAppServ is Autodesk.AutoCAD.ApplicationServices
I would really appreciate any help on how to properly set this this property!
Solved! Go to Solution.