changing Mtext value of a selected MultiLeader

changing Mtext value of a selected MultiLeader

mehdi-guida
Advocate Advocate
581 Views
4 Replies
Message 1 of 5

changing Mtext value of a selected MultiLeader

mehdi-guida
Advocate
Advocate

Hi, How can I change Mtext value of a selected MultiLeader by .NET ?

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

Jeff_M
Consultant
Consultant
Accepted solution

Quick example:

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                var ml = (MLeader)tr.GetObject(entId, OpenMode.ForWrite);
                if (ml.ContentType == ContentType.MTextContent)
                {
                    var mtext = ml.MText;
                    var txt = mtext.Contents;
                    mtext.Contents = txt.Replace("x", "XX");
                    ml.MText = mtext;
                    tr.Commit();
                }
            }
Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 5

mehdi-guida
Advocate
Advocate

Thank you So much Jeff

You have always helped me.

another quick question,  Can we change Mtext rotation of a mleader by your code as well? 

 

0 Likes
Message 4 of 5

_gile
Consultant
Consultant
Accepted solution

You could have found it yourself (if you'd tried).

var ml = (MLeader)tr.GetObject(entId, OpenMode.ForWrite);
if (ml.ContentType == ContentType.MTextContent)
{
    var mtext = ml.MText;
    var txt = mtext.Contents;
    mtext.Contents = txt.Replace("x", "XX");
    mtext.Rotation += Math.PI / 2.0;
    ml.MText = mtext;
}
tr.Commit()


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 5

mehdi-guida
Advocate
Advocate
Thank You Gile, 🙂
0 Likes