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

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

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
NayaraFJ
434 Views, 4 Replies

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



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!

4 REPLIES 4
Message 2 of 5
Jeff_M
in reply to: NayaraFJ

DBText.AlignmentPoint 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 5
NayaraFJ
in reply to: Jeff_M

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

Message 4 of 5
Jeff_M
in reply to: NayaraFJ

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
NayaraFJ
in reply to: Jeff_M

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

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