Message 1 of 2
Can't set MTextAttributeDefinition.Width
Not applicable
07-22-2016
01:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I want to change the MTextAttributeDefinition.Width by code, but it does not work, the code is here:
public static void UpdateMTextAttribute(this Database db, string blockName, string attName, ObjectId textStyleId, double height, double widthFactor, double width)
{
BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead);
ObjectId btrID = bt[blockName];
BlockTableRecord btr = (BlockTableRecord)btrID.GetObject(OpenMode.ForRead);
foreach (ObjectId id in btr)
{
AttributeDefinition attDef = id.GetObject(OpenMode.ForRead) as AttributeDefinition;
if (attDef != null && attDef.Tag == attName)
{
attDef.UpgradeOpen();
attDef.TextStyleId = textStyleId;
attDef.Height = height;
attDef.WidthFactor = widthFactor;
attDef.MTextAttributeDefinition.Width = width;
attDef.DowngradeOpen();
}
}
}During debugging I can see the TextStyleId, Height and WidthFactor all changed, but MTextAttributeDefinition.Width still has the original value.
How can I change it by code? Thanks very much?