TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Marc'Antonio Alessi on November 09, 2016, 10:59:03 AM

Title: AttSync in ODBX doc
Post by: Marc'Antonio Alessi on November 09, 2016, 10:59:03 AM
In a ODBX doc I can "insert" a block with (vlax-invoke DbxDoc 'copyobjects ObjLst BlkObj) from other ODBX doc to update existing block.
Question: if the block has attributes in different number, name or position is there any way to update the block as with AttSync command?
Title: Re: AttSync in ODBX doc
Post by: gile on November 09, 2016, 01:32:52 PM
Hi,

I do not code so much with AutoLISP these days, but I have reproduced the process executed by the ATTSYNC command with .NET (http://www.acadnetwork.com/index.php?topic=361.0).

Pseudo code:

Get the block definition
Get all the attribute definitons in the block definition
Foreach block reference inserted in the drawing
  Store the attributes values in an assoc list (tag . value)
  Erase the all attribute references
  Foreach attribute definition
    Add a new attribute reference to the block reference attribute collection
    Set the attribute reference properties according to the attribute definition ones
    Set the attribute reference geometry according to the block reference one (insertion point, scale, rotation)
    Set the attribute reference value according to the stored ones
Title: Re: AttSync in ODBX doc
Post by: Marc'Antonio Alessi on November 09, 2016, 03:01:55 PM
Hi,

I do not code so much with AutoLISP these days, but I have reproduced the process executed by the ATTSYNC command with .NET (http://www.acadnetwork.com/index.php?topic=361.0).

Pseudo code:

Get the block definition
Get all the attribute definitons in the block definition
Foreach block reference inserted in the drawing
  Store the attributes values in an assoc list (tag . value)
  Erase the all attribute references
  Foreach attribute definition
    Add a new attribute reference to the block reference attribute collection
    Set the attribute reference properties according to the attribute definition ones
    Set the attribute reference geometry according to the block reference one (insertion point, scale, rotation)
    Set the attribute reference value according to the stored ones
Thanks for answer, I try to translate your code in Lisp... maybe it will be also useful for this problem: https://www.theswamp.org/index.php?topic=52209.0
Buona notte.