MLeader AttributeReference width factor change

MLeader AttributeReference width factor change

Gepaha
Collaborator Collaborator
280 Views
2 Replies
Message 1 of 3

MLeader AttributeReference width factor change

Gepaha
Collaborator
Collaborator

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.

0 Likes
281 Views
2 Replies
Replies (2)
Message 2 of 3

timgrote
Enthusiast
Enthusiast

If you run attsync after you run this code, does it work?

0 Likes
Message 3 of 3

Gepaha
Collaborator
Collaborator

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.

0 Likes