.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Text Justify and Position

2 REPLIES 2
Reply
Message 1 of 3
odoshi
3260 Views, 2 Replies

Text Justify and Position

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
2 REPLIES 2
Message 2 of 3
NathTay
in reply to: odoshi

Try the AlignmentPoint property instead of the Position property.
Message 3 of 3
odoshi
in reply to: odoshi

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost