Text Justify and Position

Text Justify and Position

odoshi
Collaborator Collaborator
3,653 Views
2 Replies
Message 1 of 3

Text Justify and Position

odoshi
Collaborator
Collaborator
Hi,

I am setting text fine until I try to set the Justify property. Then it places the text at 0,0.

Can anyone point me where I am going wrong?

Thanks,


using (Transaction tr = doc.Database.TransactionManager.StartTransaction())
{
Point3d loc = new Point3d();
foreach (ObjectId Id in res.Value.GetObjectIds())
{
MText mtxt = (MText)tr.GetObject(Id, OpenMode.ForRead);
loc = mtxt.Location;
string strAllLines = mtxt.Text;
StringReader reader = new StringReader(strAllLines);
string strRooomId = reader.ReadLine();

DBText txt = new DBText();
txt.Justify = AttachmentPoint.MiddleCenter;
txt.Height = mtxt.TextHeight;
txt.TextString = strRooomId;
txt.Position = loc;


BlockTableRecord btr = (BlockTableRecord)tr.GetObject(doc.Database.CurrentSpaceId, OpenMode.ForWrite);
btr.AppendEntity(txt);
tr.AddNewlyCreatedDBObject(txt, true);
}
tr.Commit();
Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
0 Likes
3,654 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Try the AlignmentPoint property instead of the Position property.
Message 3 of 3

odoshi
Collaborator
Collaborator
Yep - that did it. Thanks!
Mike Caruso
Autodesk Certified Instructor 2014
AutoCAD/Civil 3D Autodesk Certified Professional 2014, 2015, 2018
www.whitemountaincad.com
0 Likes