Get value of specific attributes from selected block

Get value of specific attributes from selected block

DC-MWA
Collaborator Collaborator
1,265 Views
3 Replies
Message 1 of 4

Get value of specific attributes from selected block

DC-MWA
Collaborator
Collaborator

Hi all,

I have a little portion of code that i want to modify to instead of listing all attribute values from selected block,

to only list two:

COLOR_DESIG and MAT_DESIG

 

See attached sample code...

Thanks!

0 Likes
Accepted solutions (1)
1,266 Views
3 Replies
Replies (3)
Message 2 of 4

_gile
Consultant
Consultant
Accepted solution

Hi,

 

The simplest way is using getpropertyvalue.

 

(defun c:test3 (/ bnm blks i ent)
  (setq	bnm  (cdr (assoc 2 (entget (car (entsel "\nSelect Block: ")))))
	blks (ssget "_X" (list (cons 2 bnm) '(66 . 1)))
  )
  (repeat (setq i (sslength blks))
    (setq ent (ssname blks (setq i (1- i))))
    (print (strcat "\nCOLOR_DESIG: " (getpropertyvalue ent "COLOR_DESIG")))
    (print (strcat "\nMAT_DESIG: " (getpropertyvalue ent "MAT_DESIG")))
  )
  (princ)
)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 4

DC-MWA
Collaborator
Collaborator

That was exactly what I needed.

Thank you very much.

0 Likes
Message 4 of 4

DC-MWA
Collaborator
Collaborator

Hello,

Maybe you can assist me further?

I'm trying to use the information from the attributes to create hyperlinks. It works, but updates all the detail tag blocks in the drawing, not just the one selected???

I have attached the sample code and a sample drawing.

0 Likes