How to capture the point "node" of a text line by "MiddleCenter."?

How to capture the point "node" of a text line by "MiddleCenter."?

Anonymous
Not applicable
802 Views
4 Replies
Message 1 of 5

How to capture the point "node" of a text line by "MiddleCenter."?

Anonymous
Not applicable



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.

 

 
How to capture or calculate the other point?

 
Thank you for your help!

0 Likes
Accepted solutions (1)
803 Views
4 Replies
Replies (4)
Message 2 of 5

Jeff_M
Consultant
Consultant

DBText.AlignmentPoint 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 5

Anonymous
Not applicable

I tried but it always comes (0,0,0) Smiley Sad

0 Likes
Message 4 of 5

Jeff_M
Consultant
Consultant
Accepted 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();
            }
        }

 

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 5

Anonymous
Not applicable

Thank you. I was having problems with the creation of a text.

0 Likes