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

MLeader ConvertFieldToText() method

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Allen_Hart
483 Views, 2 Replies

MLeader ConvertFieldToText() method

Having trouble with MLeader.MText.ConvertFieldToText() method.
No error is thrown, but the field is not converted.
- Is there an extra step required?
 
Also having trouble with fields in dimension text.
Oddly, when I pick a dim text it seems nothing happens (like with MLeader text).
While the command is still running, pick the same text again and it has no fields.
Exit the command, edit the dim text normally and  the field is still there.
- Is there an extra step required to convert dim text?
 
My code is attached. Comments are welcome.
Thanks, Allen

 

2 REPLIES 2
Message 2 of 3
fenton.webb
in reply to: Allen_Hart

If the contents of MText contains fields, this function converts them to text and removes the fields. It does not evaluate the fields before converting them




Fenton Webb
AutoCAD Engineering
Autodesk

Message 3 of 3
Balaji_Ram
in reply to: Allen_Hart

Hi Allen,

 

As my colleague mentioned, the field is not evaluated during this conversion.

 

If you want the updated text, you can set the MText content by evaluating the field on your own.

 

Here is a sample code snippet to evaluate a field from the MText :

 

                                Dim myML As MLeader = myTrans.GetObject(mySelObj.ObjectId, OpenMode.ForWrite)
                                Dim myMLT As MText = myML.MText
                                myMLT.GetField()

                                Dim fieldId As ObjectId
                                fieldId = myMLT.GetField()

                                Dim fld As Field = myTrans.GetObject(fieldId, OpenMode.ForWrite)
                                fld.Evaluate()
                                Dim fldValue As String
                                fldValue = fld.Value.ToString()

                                ' Set the MLeader text based on evaluated field value

 



Balaji
Developer Technical Services
Autodesk Developer Network

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