Distinguishing Annotative Blocks with Vanilla LISP

Distinguishing Annotative Blocks with Vanilla LISP

davinatkins
Advocate Advocate
386 Views
3 Replies
Message 1 of 4

Distinguishing Annotative Blocks with Vanilla LISP

davinatkins
Advocate
Advocate

I'm working on some code that inserts blocks when you click. No biggie.

 

Everything works fine - so long as the user is using a non-annotative block - I'd like to check to see if the block being inserted is annotative or not. So I can adjust my code accordingly.

 

I figured it'd be something along the lines of 

 

(entget (tblobjname "BLOCK" "nameofblock"))

 

The problem is, there is no difference between what I get out of that for a block is is annotative and one that isn't.

 

Annotative Block Entget
((-1 . <Entity name: 24345b509a0>) (0 . "BLOCK") (330 . <Entity name: 24345b50990>) (5 . "37A") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockBegin") (70 . 2) (10 0.0 0.0 0.0) (-2 . <Entity name: 24345b509c0>) (2 . "testyes") (1 . ""))
\
Non Annotative Block Entget
((-1 . <Entity name: 24345b50910>) (0 . "BLOCK") (330 . <Entity name: 24345b50900>) (5 . "371") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockBegin") (70 . 2) (10 0.0 0.0 0.0) (-2 . <Entity name: 24345b50930>) (2 . "testnon") (1 . ""))

 

I tried to use the function that I found here: https://www.cadtutor.net/forum/topic/78681-check-if-block-is-annotative/  but I'm struggling with it because a Block definition doesn't have a Group Code 360, only 330. (Also I don't fully understand dictsearch yet) Passing that function the entity name I get from TBLOBJNAME only returns nil.

 

If I do a DXF dump of the file, I can clearly see that I'm looking for Group Codes 1070.  But that's not being retrieved with an entget.

 

Does anyone have any insight on where I'm being ignorant?

0 Likes
Accepted solutions (2)
387 Views
3 Replies
Replies (3)
Message 2 of 4

johnyDFFXO
Advocate
Advocate
Accepted solution

How about use a simple getpropertyvalue

(getpropertyvalue (car (entsel)) "Annotative")

0 Likes
Message 3 of 4

davinatkins
Advocate
Advocate
Accepted solution

That got me really close!

 

The code you suggested seems to only work with inserted blocks. But... changing it around a bit worked great! Thank you for your assistance 😊

 

(getpropertyvalue (cdr (assoc 330 (entget (tblobjname "block" "newtag")))) "isannotative")

 

0 Likes
Message 4 of 4

davinatkins
Advocate
Advocate

This is just a note for myself and anyone else who has a similar problem.

 

The way I was able to figure out the correct syntax was to use DumpAllProperties. When using this you needed to grab 330, not -1. Here is the code (replace my block name with your block name)

 

(dumpallproperties (cdr (assoc 330 (entget (tblobjname "block" "newtag")))))

 

This returns a TON of information about the block that you can use to pull data about a block definition.

0 Likes