I'm trying to change the width factor of an attribute which is in a Mleader. I tested the code below and it doesn't work. But, if I use the same code to change the attribute value it works.
MLeader ml = tr.GetObject(id, OpenMode.ForWrite) as MLeader;
if (ml != null)
{
BlockTableRecord btrBlock = tr.GetObject(ml.BlockContentId, OpenMode.ForRead) as BlockTableRecord;
if (btrBlock.HasAttributeDefinitions)
{
foreach (ObjectId atId in btrBlock)
{
DBObject obj = tr.GetObject(atId, OpenMode.ForRead);
if (obj is AttributeDefinition)
{
AttributeDefinition adef = obj as AttributeDefinition;
if (adef.Tag.Equals(GhAcBubbleSettings.BubbleId))
{
AttributeReference aref = ml.GetBlockAttribute(adef.Id);
if (!aref.IsErased && aref.Tag.Equals(bid))
{
if (isWidhtAuto)
widthFactor = aref.GetBestFitWidthFactor();
aref.WidthFactor = widthFactor;
// force regen the entity?
aref.Visible = aref.Visible;
ml.SetBlockAttribute(adef.Id, aref);
break;
}
}
}
}
}
}
Thanks for any reply.
Firstly I only want to modify specific items and not all.
I tested it with ATTSYNC, BATTMAN changing the attribute width across the block. In the existing MLeader in the drawing it had no effect, in the existing blocks in the drawing it changed correctly. I exploded the Mleader so the attribute width in the block was displayed correctly.
The MLeader inserted after the attribute width in the block was changed works.
What I want is to have different attribute widths and this doesn't work with Mleader, but with the block itself it works.
Thanks for answering.
Can't find what you're looking for? Ask the community or share your knowledge.