.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MLeader AttributeReference width factor change

2 REPLIES 2
Reply
Message 1 of 3
Gepaha
166 Views, 2 Replies

MLeader AttributeReference width factor change

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.

2 REPLIES 2
Message 2 of 3
timgrote
in reply to: Gepaha

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

Message 3 of 3
Gepaha
in reply to: timgrote

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.

Post to forums  

Forma Design Contest


AutoCAD Beta