Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Get value of specific attributes from selected block

DC-MWA
Collaborator

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
Reply
Accepted solutions (1)
1,207 Views
3 Replies
Replies (3)

_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

DC-MWA
Collaborator
Collaborator

That was exactly what I needed.

Thank you very much.

0 Likes

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

Type a product name