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
Solved! Go to Solution.
Solved by fenton.webb. Go to Solution.
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
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