TheSwamp

Code Red => .NET => Topic started by: chriskroll on January 15, 2015, 01:35:04 PM

Title: Overriding font on a block attribute
Post by: chriskroll on January 15, 2015, 01:35:04 PM
I need to override the font in a block attribute to be Arial.  I have tried the following code, but nothing seems to work.  Anyone have any insight?

Code - C#: [Select]
  1. if (attRef.IsMTextAttribute)
  2. {
  3.         // This method sets the attRef.MTextAttribute.Contents correctly,
  4.         // but leaves the attRef.TextString empty so that nothing shows
  5.         // up for this attribute in the drawing.
  6.         attRef.TextString = "{\\fArial|b0|i0|c0|p82;Hello Swamp!}"
  7.         attRef.UpdateMTextAttribute();
  8.        
  9.         // This does nothing at all.
  10.         attRef.MTextAttribute.Contents = "{\\fArial|b0|i0|c0|p82;Hello Swamp!}"
  11.        
  12.         // This causes AutoCAD to crash.
  13.         MText mt = new MText();
  14.         mt.Contents = "{\\fArial|b0|i0|c0|p82;Hello Swamp!}";
  15.         attRef.MTextAttribute = mt;
  16. }
  17.  
Title: Re: Overriding font on a block attribute
Post by: chriskroll on January 15, 2015, 02:38:19 PM
Nevermind, I found out that the string I was assigning to Contents was not properly formatted.  This was causing it to fail to update the TextString property.