Author Topic: Run ATTSYNC only when block with attributes are present  (Read 1766 times)

0 Members and 1 Guest are viewing this topic.

w64bit

  • Newt
  • Posts: 78
Run ATTSYNC only when block with attributes are present
« 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" "*"))
« Last Edit: September 08, 2021, 07:41:13 AM by w64bit »

mhupp

  • Bull Frog
  • Posts: 250
Re: Run ATTSYNC only when block with attributes are present
« Reply #1 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)
)

w64bit

  • Newt
  • Posts: 78
Re: Run ATTSYNC only when block with attributes are present
« Reply #2 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.
« Last Edit: September 08, 2021, 11:05:35 AM by w64bit »

Lonnie

  • Newt
  • Posts: 169
Re: Run ATTSYNC only when block with attributes are present
« Reply #3 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" "*")
?
« Last Edit: September 08, 2021, 03:02:08 PM by Lonnie »

w64bit

  • Newt
  • Posts: 78
Re: Run ATTSYNC only when block with attributes are present
« Reply #4 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.
« Last Edit: September 08, 2021, 11:33:50 AM by w64bit »

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Run ATTSYNC only when block with attributes are present
« Reply #5 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. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

w64bit

  • Newt
  • Posts: 78
Re: Run ATTSYNC only when block with attributes are present
« Reply #6 on: September 08, 2021, 12:15:28 PM »
Yes! Thank you very much.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Run ATTSYNC only when block with attributes are present
« Reply #7 on: September 08, 2021, 01:36:12 PM »
Yes! Thank you very much.
Glad to help!

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC