Check if attribute exists in the block table

Check if attribute exists in the block table

Anonymous
Not applicable
1,350 Views
1 Reply
Message 1 of 2

Check if attribute exists in the block table

Anonymous
Not applicable
I know how to check if a block in the drawing has a specific attribute, but how do I find if the block definition (in block table) has the attribute?
0 Likes
Accepted solutions (1)
1,351 Views
1 Reply
Reply (1)
Message 2 of 2

hmsilva
Mentor
Mentor
Accepted solution

@Anonymous wrote:
... but how do I find if the block definition (in block table) has the attribute?

One way

 

;; (attdef-p "YoutBlockName" "YourAttTag")
;; If true returns T otherwise nil
(defun attdef-p (blkname tag / a b e)
  (if (setq b (tblobjname "block" blkname))
    (while
      (and
        (setq b (entnext b))
        (setq e (entget b))
      )
       (if (and (= (cdr (assoc 0 e)) "ATTDEF")
                (= (cdr (assoc 2 e)) tag)
           )
         (setq a T)
       )
    )
  )
  a
  )

 

Hope that helps

Henrique

EESignature