Is there any way to change all annotative blocks to Non-annotative using lisp?

Is there any way to change all annotative blocks to Non-annotative using lisp?

Anonymous
Not applicable
2,036 Views
7 Replies
Message 1 of 8

Is there any way to change all annotative blocks to Non-annotative using lisp?

Anonymous
Not applicable

I am trying to change all the annotative blocks (not specific but any block) to non-annotative. Is there any way to do this using Lisp? 

Thanks

0 Likes
2,037 Views
7 Replies
Replies (7)
Message 2 of 8

cadffm
Consultant
Consultant

1. Sure, you can change this by Lisp

2. Ready codes? Search for it

    by using phrases: AutoCAD Lisp  Change annotation block

    or These Keyworgs: AutoCAD AcadAnnotative AnnotativeData

 

We can not know what you want in detail

- Current scale is 1:75, AnnoAllVisible is on, the blockreference1 doesn't suppuport 1:75, the other one supports 1:75.

 

  What should the program do with Blockref1 and what should the program do with Blockref2 in this sample case?

 

  What should the program do in the same case, bit AnnoAllVisible is set to off?

 

Hope the search hints are helpful

Sebastian

0 Likes
Message 3 of 8

Anonymous
Not applicable

I did a lot of searches and none of the lisp routines on file helped. I have attached a file here. There are a few blocks in it. In properties menu for any of those, the annotative property is set to yes now. I`d like to use a piece of code to run and make all those "Yes"s to "No"s so they won`t be annotative anymore.  

0 Likes
Message 4 of 8

gccdaemon
Collaborator
Collaborator

I'm looking for the same thing. I found a bug in AutoCAD and tested it. If you blockreplace (or change the source definition) an annotative block with a non-annotative block the X,Y,Z scale factors start going crazy when you change them in the properties palette. It appears that the annotative portion is tagged to the object ID and not the block definition? I just want something to find the annotative block definitions in the current drawing and change their definition from annotative Yes to Annotative No.

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes
Message 5 of 8

gccdaemon
Collaborator
Collaborator

OK, i'm an idiot and just found Lee's switch, But I still am not skilled enough to find all annotative blocks and pass them through this routine.

;; 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

(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 . "}")
                           )
                       )
                   )
               )
           )
       )
   )
)
Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 6 of 8

Sea-Haven
Mentor
Mentor

Maybe add this, vaguely tested.

(vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(LM:annotativeblock  (vla-get-name blk) nil )
(princ (strcat "\n" (vla-get-name blk)))
)

 

Message 7 of 8

vinceroux
Enthusiast
Enthusiast

@Sea-Haven wrote:

Maybe add this, vaguely tested.

 

(vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
(LM:annotativeblock  (vla-get-name blk) nil )
(princ (strcat "\n" (vla-get-name blk)))
)

 

 


I added this to the end, loaded the lisp, and it worked at converting all my annotative blocks to non-annotative. I believe replacing "nil" in line 2 with "T" would complete the opposite task. 

 

Thanks!

 

0 Likes
Message 8 of 8

gccdaemon
Collaborator
Collaborator

OK, so after much trial and error, I've found that switching the annotative flag off doesn't solve my problem. There is some form of embedded data the survey software puts in the block definition which causes XYZ scale to go haywire. Basically, if it comes in as annotative from the surveyor, it has this "Corruption" embedded. After doing BLOCKREPLACE on an instance of any annotative block that's been sourced from the survey software (regardless of the annotative flag being switched or not), when you try to change the X,Y, or Z scale in the properties palette, the other scales change to a larger or smaller number (+\- 1000 units). So far this routine I found (Can't honestly remember where) does what I need, but It puts new insertions on the current layer. What can I do to get this to put the blocks on the current layer of the objects it's replacing?

(defun C:BANNO ( / UCS CH BLKS BLST SS i ENT BLK BLKN INS RANG RANGD XS YS ZS SSENT YN )
	(vl-load-com)
	(if	(eq (getvar 'worlducs) 0)
		(progn	(command "_.UCS" "_W")
			(setq UCS t)
	)	)
	(initget 1 "Annotative Non-annotative")
	(setq CH (getkword "\nMake selected blocks Annotative or Non-annotative [A/N] : " ))
	(setq BLKS (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
	(vlax-for bl BLKS (setq BLST (cons (list (vla-get-name bl) bl (vla-get-isxref bl)) BLST)))
	(prompt "\nSelect blocks with or without attributes that reside on unlocked layer(s)...")
	(setq SS (ssget "_:L" '((0 . "INSERT"))))
	(if SS	(repeat	(setq i (sslength SS))
			(setq ENT (ssname SS (setq i (1- i))))
			(setq BLK (vlax-ename->vla-object ENT))
			(setq BLKN (vla-get-effectivename BLK))
			(setq INS (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint BLK))))
			(setq RANG (vla-get-rotation BLK))
			(setq RANGD (* (/ 180 PI) RANG))
			(setq XS (vla-get-Xeffectivescalefactor BLK)) ;Change to optional block scale
			(setq YS (vla-get-Yeffectivescalefactor BLK)) ;Change to optional block scale
			(setq ZS (vla-get-Zeffectivescalefactor BLK)) ;Change to optional block scale
			(if	(and	(assoc BLKN BLST) (eq (last (assoc BLKN BLST)) :vlax-false))
				(vla-put-explodable (cadr (assoc BLKN BLST)) :vlax-true))
			(command "_.EXPLODE" ENT)
			(while	(< 0 (getvar 'cmdactive))
				(command ""))
			(setq SSENT (ssget "_P"))
			(if	(= CH "Annotative")
				(progn	(setq YN "Yes")
					(command "_.ROTATE" SSENT "" "_non" INS (- RANGD))
					(command "_.BLOCK" BLKN "_Y" "_A" YN "_N" "_non" INS SSENT "")
					(command "_.INSERT" BLKN "_non" INS XS YS RANGD))
				(progn	(setq YN "No")
					(command "_.ROTATE" SSENT "" "_non" INS (- RANGD))
					(command "_.BLOCK" BLKN "_Y" "_A" YN "_N" "_non" INS SSENT "")
					(command "_.INSERT" BLKN "_non" INS XS RANGD))
		)	)
		(prompt "\nNo annotative blocks were selected.")
	)
	(if UCS (command "_.UCS" "_P"))
	(princ)
)
Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
0 Likes