.NET

Reply
Valued Contributor
54 Posts
5 Kudos
Registered: ‎09-18-2006
Post 1 of 3
Accepted Solution

MLeader ConvertFieldToText() method

186 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

 

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

ADN Support Specialist
352 Posts
27 Kudos
Registered: ‎07-24-2007
Post 2 of 3

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
761 Posts
100 Kudos
Registered: ‎03-21-2011
Post 3 of 3

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
                                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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!