TheSwamp

Code Red => .NET => Topic started by: latour_g on October 03, 2019, 09:37:27 AM

Title: Edit attributes on closed drawing
Post by: latour_g on October 03, 2019, 09:37:27 AM
This might be a little tricky .. or not but I can't figure out the solution  :uglystupid2:

I have a command that edit attributes on closed drawing.  It only change the content. It works fine for changing the content but it does not adjust at the right justification.  It keep the actual insertion point so it is offset. 

Any idea ?

Thank you !

Code - C++: [Select]
  1. BlockTableRecord bDef = (BlockTableRecord)tr.GetObject(blkTable[cNomBlk], OpenMode.ForWrite, false);
  2. ObjectIdCollection objColl = bDef.GetBlockReferenceIds(false, true);
  3.  
  4. foreach (ObjectId objId in objColl)
  5. {
  6.     BlockReference br = (BlockReference)tr.GetObject(objId, OpenMode.ForWrite, true);
  7.     if (br.AttributeCollection.Count > 0)
  8.     {
  9.          foreach (ObjectId id in br.AttributeCollection)
  10.          {
  11.               AttributeReference att = (AttributeReference)tr.GetObject(id, OpenMode.ForWrite);
  12.               if (attValLst.Contains(att.Tag.ToUpper()))
  13.               {
  14.                     att.TextString = attValueLst[att.Tag.ToUpper()].ToString();
  15.               }
  16.          }
  17.          br.RecordGraphicsModified(true);
  18.     }
  19. }
Title: Re: Edit attrbiutes on closed drawing
Post by: n.yuan on October 03, 2019, 09:57:38 AM
I assume "closed drawing" means opened side database, in which you update attributes of certain blockreferences.

This is a know issue and have been discussed in AutoCAD discussion forum, and maybe also in this forum, a few times; such as this:

https://forums.autodesk.com/t5/net/changed-attribute-text-in-sidedb-does-not-re-align-when/m-p/8665044 (https://forums.autodesk.com/t5/net/changed-attribute-text-in-sidedb-does-not-re-align-when/m-p/8665044)

HTH
Title: Re: Edit attributes on closed drawing
Post by: latour_g on October 03, 2019, 11:21:03 AM
You are absolutely right, I needed to use HostApplicationServices.WorkingDatabase
Thank you so much !