Author Topic: Annotative lisp Block help  (Read 1977 times)

0 Members and 1 Guest are viewing this topic.

PPETROS

  • Newt
  • Posts: 27
Annotative lisp Block help
« on: December 10, 2019, 02:56:45 AM »
Hello to everyone,

I need a lisp routine which will change blocks with “Annotative property” to “Non-Annotative”.
I found the following lisp which does what I described before, but is not that “user-friendly”.

Can someone re-arrange it, in order to work as a “proper/normal” lisp?
for example: (defun c:test () …..)
In addition, I would be grateful if someone can add to this lisp routine the option to choose between a specific and a all drawing blocks (including nested blocks).

Thank you in advance,

Code: [Select]
(defun LM:annotativeblock ( blk flg )
   (and (setq blk (tblobjname "block" blk))
       (progn
           (regapp "AcadAnnotative")
           (entmod
               (append (entget (cdr (assoc 330 (entget blk))))
                   (list
                       (list -3
                           (list
                               "AcadAnnotative"
                              '(1000 . "AnnotativeData")
                              '(1002 . "{")
                              '(1070 . 1)
                               (cons 1070 (if flg 1 0))
                              '(1002 . "}")
                           )
                       )
                   )
               )
           )
       )
   )
)
Code: [Select]
examples:
(LM:annotativeblock "Div_A_BL_P_RoomTag" nil)
(LM:annotativeblock "Div_A_BL_M_DatumLevel_Plan" nil)
(LM:annotativeblock "Div_A_BL_M_ColumnGridMarker" nil)

Attaching example drawing:

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Annotative lisp Block help
« Reply #1 on: December 10, 2019, 04:42:27 AM »
Why don't you also show the author?
Code: [Select]
;; Annotative Block  -  Lee Mac
;; Sets the annotative property for a block definition
;; blk - [str] Block name
;; flg - [bol] Boolean flag (T=Annotative, nil=Not Annotative)
;; Returns: T if successful, else nil

PPETROS

  • Newt
  • Posts: 27
Re: Annotative lisp Block help
« Reply #2 on: December 10, 2019, 06:26:14 AM »
I agologize for that, my mistake.

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: Annotative lisp Block help
« Reply #3 on: December 11, 2019, 01:15:10 AM »
In very simple terms for pick pick, for all need to just go through the block table getting block names.

Code: [Select]
(defun c:test ( / ent obj n)
(vl-load-com)
(while (setq ent  (entsel "pick block Enter to exit"))
(setq obj (vlax-ename->vla-object (car ent)))
(setq n (vla-get-effectivename obj))
(LM:ANNOTATIVEBLOCK N nil)
)
)
A man who never made a mistake never made anything

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: Annotative lisp Block help
« Reply #4 on: December 11, 2019, 02:19:01 AM »
Another simple one Select all block in active layout

Code - Auto/Visual Lisp: [Select]
  1. (defun c:BUA nil (c:BlockUnAnnotative))
  2. (defun c:BlockUnAnnotative ( / blk blkn blkvl slct sset)
  3.  
  4. ;; Annotative Block  -  Lee Mac
  5. ;; Sets the annotative property for a block definition
  6. ;; blk - [str] Block name
  7. ;; flg - [bol] Boolean flag (T=Annotative, nil=Not Annotative)
  8. ;; Returns: T if successful, else nil
  9. (defun LM:annotativeblock ( blk flg )
  10.    (and (setq blk (tblobjname "block" blk))
  11.        (progn
  12.            (regapp "AcadAnnotative")
  13.            (entmod
  14.                (append (entget (cdr (assoc 330 (entget blk))))
  15.                    (list
  16.                        (list -3
  17.                            (list
  18.                                "AcadAnnotative"
  19.                               '(1000 . "AnnotativeData")
  20.                               '(1002 . "{")
  21.                               '(1070 . 1)
  22.                                (cons 1070 (if flg 1 0))
  23.                               '(1002 . "}")
  24.                            )
  25.                        )
  26.                    )
  27.                )
  28.            )
  29.        )
  30.    )
  31. )
  32.  
  33.   (initget "Select All")
  34.   (setq Slct (cond ((getkword "\nSelect Blocks to Convert [Select/All]] <All>: ")) ("All")))
  35.   (setq slst (list (cons 0 "INSERT") (cons 410 (getvar "ctab"))))
  36.  
  37.   (if (equal Slct "All")
  38.   (setq sset (ssget "X" slst))
  39.   (setq sset (ssget slst))  
  40.   )
  41. (repeat (setq cnt (sslength sset))
  42.   (setq blk (ssname sset (setq cnt (1- cnt))))
  43.   (setq blkVL (vlax-ename->vla-object blk))
  44.   (if (not (vlax-property-available-p blkVL 'path))
  45.     (progn
  46.       (setq BlkN (vla-get-effectivename blkVL))
  47.       ( LM:annotativeblock BlkN nil)
  48.       )))
  49.   )

PPETROS

  • Newt
  • Posts: 27
Re: Annotative lisp Block help
« Reply #5 on: December 11, 2019, 04:08:28 AM »
Thank you very much for the help. All the codes work perfectly. I totally agree with your comment.