Author Topic: Edit attributes on closed drawing  (Read 165 times)

0 Members and 1 Guest are viewing this topic.

latour_g

  • Newt
  • Posts: 143
Edit attributes on closed drawing
« 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. }
« Last Edit: October 03, 2019, 11:19:02 AM by latour_g »

n.yuan

  • Bull Frog
  • Posts: 277
Re: Edit attrbiutes on closed drawing
« Reply #1 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

HTH

latour_g

  • Newt
  • Posts: 143
Re: Edit attributes on closed drawing
« Reply #2 on: October 03, 2019, 11:21:03 AM »
You are absolutely right, I needed to use HostApplicationServices.WorkingDatabase
Thank you so much !