Kinda off topic here .. but has anyone found a way to access the mtext object within an mleader without exploding?
Kinda off topic here .. but has anyone found a way to access the mtext object within an mleader without exploding?
As far as I know, the MText content of an MLeader is not stored as a separate MText entity, but rather defined by the various DXF groups enclosed within the (300 . "CONTEXT_DATA{") section of the MLeader DXF data. I would assume that the MText entity is automatically generated using this data when the EXPLODE command is used.
FWIW -
Stemming from my work on
this... There is actually a separate MText Property Object within an MLeader Typed entity (
given ContentType == ContentType.MTextContent enum), it just has not been exposed to LISP... Which is where my appreciation for an MLeader's
TextString Property stems from, as the code-behind this Property handles the necessary
Transaction to access, and get/set the MText Object's
TextString Property, without any additional end-user code... Just as compared to the same in .NET API get/set the string... It's really quite elegant.
Here's a small snippet from the linked project (
which accepts DBText, MLeader, MText, etc., hence the switch case):
// <snip>
try
{
using (DocumentLock docLock = doc.LockDocument())
{
using (Transaction tr =
db.TransactionManager.StartOpenCloseTransaction())
{
foreach (ObjectId id in ids)
{
switch (id.ObjectClass.Name)
{
case "AcDbMLeader":
mleader =
(MLeader)tr.GetObject(id, OpenMode.ForWrite);
ContentType contentType = mleader.ContentType;
if (contentType == ContentType.MTextContent)
{
mtext = mleader.MText;
// use the texteditor where possible
if (strCase.Equals((int)StringCase.Lower) |
strCase.Equals((int)StringCase.Upper)
)
ChangeCaseUsingTextEditor(mtext, strCase);
// texteditor does not support sentence, title, or toggle
else
mtext.Contents = mtext.Contents.ToCase(strCase);
mleader.MText = mtext;
}
//// nested block attributes:
//else if (contentType == ContentType.BlockContent)
//{
//}
break;
case "AcDbMText":
mtext =
(MText)tr.GetObject(id, OpenMode.ForWrite);
// use the texteditor where possible
if (strCase.Equals((int)StringCase.Lower) |
strCase.Equals((int)StringCase.Upper)
)
ChangeCaseUsingTextEditor(mtext, strCase);
// texteditor does not support sentence, title, or toggle
else
mtext.Contents = mtext.Contents.ToCase(strCase);
break;
case "AcDbText":
text =
(DBText)tr.GetObject(id, OpenMode.ForWrite);
text.TextString = text.TextString.ToCase(strCase);
break;
default:
break;
}
}
tr.Commit();
}
}
}
catch
{
}
// <snip>
For those who may be interested... The
System.String Extension Methods used above can be found
here.
Cheers
/OffTopic