Valued Contributor
Posts: 52
Registered: ‎09-18-2006
Message 1 of 3 (161 Views)
Accepted Solution

MLeader ConvertFieldToText() method

161 Views, 2 Replies
08-04-2013 09:09 AM

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


ADN Support Specialist
Posts: 352
Registered: ‎07-24-2007
Message 2 of 3 (127 Views)

Re: MLeader ConvertFieldToText() method

08-05-2013 02:46 PM 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

Developer Technical Services

Autodesk Developer Network

ADN Support Specialist
Posts: 669
Registered: ‎03-21-2011
Message 3 of 3 (112 Views)

Re: MLeader ConvertFieldToText() method

08-06-2013 03:54 AM 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

                                Dim fieldId As ObjectId
                                fieldId = myMLT.GetField()

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

                                ' Set the MLeader text based on evaluated field value


Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community