TheSwamp

Code Red => .NET => Topic started by: latour_g on August 26, 2021, 01:43:53 PM

Title: Blocktablerecord, access visibily
Post by: latour_g on August 26, 2021, 01:43:53 PM
Hi,

I would like to access visibility grip property.  So far, I can access object but it's not there.  Thank you !

Code - C#: [Select]
  1.         private void xtract_btnScaleBlkNew_Click(object sender, EventArgs e)
  2.         {
  3.             Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
  4.             Database db = doc.Database;
  5.  
  6.             using (doc.LockDocument())
  7.             {
  8.                 using (Transaction tr = db.TransactionManager.StartTransaction())
  9.                 {
  10.                     BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
  11.  
  12.                     foreach (ObjectId id in bt)
  13.                     {
  14.                         BlockTableRecord btRecord = (BlockTableRecord)tr.GetObject(id, OpenMode.ForWrite);
  15.  
  16.                         foreach (ObjectId objID in btRecord)
  17.                         {
  18.                             DBObject obj = tr.GetObject(objID, OpenMode.ForWrite) as DBObject;
  19.  
  20.                             if (obj is AttributeDefinition)
  21.                             {
  22.                                 //
  23.                             }
  24.  
  25.                             if (obj is Entity)
  26.                             {
  27.                                 //
  28.                             }
  29.                         }
  30.                     }
  31.                     tr.Commit();
  32.                 }
  33.             }
  34.             ed.Regen();
  35.         }
  36.  
Title: Re: Blocktablerecord, access visibily
Post by: n.yuan on August 27, 2021, 08:01:20 AM
You may want to explain what do you exactly mean by "...access visibility grip property...". Do you mean the Visibility defined with the block definition, or the DynamicBlockReferenceProperty in a block reference, identified by its property name, be it a Visibility property, or other type of properties?

If you want to get to the properties defined with a block definition, then you cannot: there is no API exposed to define/change the dynamic properties, and they are not some kind of Entity/DBObject that you can loop through a BlockTableRecord to reach them.

If you want to read/change the dynamic property in a BlockReference, you loop through BlockRedernce.DynamicBlockReferencePropertyCollection and identify the one in interest by its property name.
Title: Re: Blocktablerecord, access visibily
Post by: latour_g on August 27, 2021, 09:01:37 AM
Yes I mean the visibility defined with the block definition.  I have a command that scale block definition in batch and I wanted to change the location of the visibility grip at the same time.

But I will do it manually then.  Thank you !