Author Topic: add attribute to blocks on screen  (Read 2909 times)

0 Members and 1 Guest are viewing this topic.

fxcastil

  • Guest
add attribute to blocks on screen
« on: September 11, 2005, 08:55:10 PM »
I want to add attributes to blocks already in the autocad drawing
I attached the following file which will prompt you to select a block on the Autocad screen,
It then adds an attribute to the block definition selected .
However the blocks in the drawing are not updated with the new/added attribute.

If I insert a new block it will have the added attribute. I tried using the "attsync" command in VBA and from the
Autocad command line but the blocks in the drawing before I added the attributes are not updated.
I am using AutoCad 2002 and windows XP

To test this routine just create a simple block without attributes in the autocad drawing .

Fred Castillo




Glenn R

  • Guest
Re: add attribute to blocks on screen
« Reply #1 on: September 11, 2005, 10:20:48 PM »
Your SendCommand is failing...change it to this:

ThisDrawing.SendCommand "ATTSYNC" & vbCr & "Name" & vbCr & objBlock.Name & vbCr

Cheers,
Glenn.
« Last Edit: September 11, 2005, 10:24:43 PM by Glenn R »

Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: add attribute to blocks on screen
« Reply #2 on: September 11, 2005, 10:34:37 PM »
Fred,
I have tried this and can verify that ATTSYNC fails if it encounters an Insert that originally had no attributes. I beleive that you will need to gather the attributes, if any, and reinsert each block, making sure to reset all properties to match the existing blockref, and delete the existing.

Jeff

Glenn R

  • Guest
Re: add attribute to blocks on screen
« Reply #3 on: September 11, 2005, 11:07:58 PM »
Jeff,

More than likely on the older releases as the Attribute Follows dxf code is not set.
I tested Fred's code on 2006 and with the change of the sendcommand, it works fine.

Glenn.

fxcastil

  • Guest
Re: add attribute to blocks on screen
« Reply #4 on: September 13, 2005, 04:59:04 PM »
Jeff & Glen,

I know I can't update attributes of blocks references in drawing if I used VBA to add attribute to  blocks definition in 2002
If I use the attsync command in Autocad 2002 and then do an"F2" to see the reults of this command .
I get an error message "Error collecting attribute data. ATTSYNC complete. "

I wasn't sure this would work in newer versions of AutoCad.


Thanks for response .