In AutoCad when the text is aligned with "MiddleCenter" has two points, but in C #, I only managed to capture one of the points using: myText_DBText.Position.
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
AlignmentPoint will always be (0,0,0) for Left justified text. For any other justification it will have a value. Note the return of a simple test command:
Select normal left justified Text object:
Select MiddleCenter justified text:
First text object's Position & alignment points: (782.848598480457,5330.0457627218,0), (0,0,0)
Second text object's Position & alignment points: (782.539234103324,5326.01723791071,0), (784.372567436658,5326.51723791071,0)
And here is the example code:
[CommandMethod("TextTest")] public void texttest() { ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect normal left justified Text object:"); entOpts.SetRejectMessage("...not a Text object."); entOpts.AddAllowedClass(typeof(DBText), true); PromptEntityResult entRes = ed.GetEntity(entOpts); if (entRes.Status != PromptStatus.OK) return; using (Transaction tr = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { DBText text1 = (DBText)tr.GetObject(entRes.ObjectId, OpenMode.ForRead); entOpts.Message = "\nSelect MiddleCenter justified text:"; entRes = ed.GetEntity(entOpts); if (entRes.Status != PromptStatus.OK) return; DBText text2 = (DBText)tr.GetObject(entRes.ObjectId, OpenMode.ForRead); ed.WriteMessage("\nFirst text object's Position & alignment points: {0}, {1}", text1.Position.ToString(), text1.AlignmentPoint.ToString()); ed.WriteMessage("\nSecond text object's Position & alignment points: {0}, {1}", text2.Position.ToString(), text2.AlignmentPoint.ToString()); tr.Commit(); } }