TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: w64bit on September 08, 2021, 07:13:06 AM

Title: Run ATTSYNC only when block with attributes are present
Post by: w64bit on September 08, 2021, 07:13:06 AM
Hello,
I am trying to run ATTSYNC only when blocks with attributes are present.
Tried with this but it's not working.
Can anyone help, please.
Code: [Select]
(if (and (setq ent (entnext ent))
         (eq "ATTRIB" (cdr (assoc 0 (entget ent)))))
    (command "ATTSYNC" "N" "*"))
Title: Re: Run ATTSYNC only when block with attributes are present
Post by: mhupp on September 08, 2021, 09:38:22 AM
You will need to set blkname

Code: [Select]
(if (= 2 (cdr (assoc 70 (tblsearch "block" blkname))))
  (vl-cmdf "ATTSYNC" "N" blkname)
)
Title: Re: Run ATTSYNC only when block with attributes are present
Post by: w64bit on September 08, 2021, 10:48:06 AM
Thank you but I need to check if any attribute blocks exists in the drawing, not a specific one.
Title: Re: Run ATTSYNC only when block with attributes are present
Post by: Lonnie on September 08, 2021, 11:18:30 AM
I'm pretty sure ATTSYNC ignores all blocks without attributes.
is there any reason you could not just use
(command "ATTSYNC" "N" "*")
?
Title: Re: Run ATTSYNC only when block with attributes are present
Post by: w64bit on September 08, 2021, 11:23:48 AM
I receive the message: "This drawing contains no attributed blocks" (this message I want to avoid in order that ATTSYNC to continue).

If the drawing contains at least one attribute block, indeed ATTSYNC is ignoring blocks without attribute.
Title: Re: Run ATTSYNC only when block with attributes are present
Post by: ronjonp on September 08, 2021, 11:49:01 AM
I receive the message: "This drawing contains no attributed blocks" (this message I want to avoid in order that ATTSYNC to continue).

If the drawing contains at least one attribute block, indeed ATTSYNC is ignoring blocks without attribute.
Perhaps:
Code - Auto/Visual Lisp: [Select]
  1. (if (ssget "_X" '((0 . "insert") (66 . 1)))
  2.   (command "ATTSYNC" "N" "*")
  3. )
Title: Re: Run ATTSYNC only when block with attributes are present
Post by: w64bit on September 08, 2021, 12:15:28 PM
Yes! Thank you very much.
Title: Re: Run ATTSYNC only when block with attributes are present
Post by: ronjonp on September 08, 2021, 01:36:12 PM
Yes! Thank you very much.
Glad to help!