Get attribute values

Get attribute values

Anonymous
Not applicable
10,923 Views
4 Replies
Message 1 of 5

Get attribute values

Anonymous
Not applicable

Hello all, I was trying to extract an attribute value from a block, I used this function by Lee Mac, but for some reasons it is not working properly for me.

 

 

Here is the function

 

(defun LM:getattributevalue ( blk tag / enx )
     (if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))))
        (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
            (cdr (assoc 1 enx))

       )
   )
)

 

and Here is part of my code, I have a block with an attribute tag "DIMENSION"

 

....

(setq obj (car (entsel)) )  

(setq str (LM:GetAttributeValue obj "DIMENSION" ))  

 

;; I have three attributes in the block, it works with the first attribute tag, but it is not working with the rest of them

 

 

I appreciate any help, thanks in advance

Solomon Tessema

 

 

 

0 Likes
Accepted solutions (1)
10,924 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution

Never mind I got another function by Lee Mac, the iterative one,that works great.

 

http://www.lee-mac.com/attributefunctions.html#algetattributevalueit

 

Thank you all

Message 3 of 5

Ali_Amine
Enthusiast
Enthusiast

Hello there :- )

I am trying to use the lisp (attributefunctions), but I can not find the command to run it 😞

Any help ?

Thank you !

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

@Ali_Amine wrote:

.... I am trying to use the lisp (attributefunctions), but I can not find the command to run it .....


There is no command.  It defines a collection of functions that take arguments.  The header information at each function describes what arguments need to be supplied.   You use them in parentheses, starting with the function name and followed by the necessary argument(s).  For example, to use the first one, when you want to get the value of the Attribute with the Tag "MouseName" in an insertion of a Block called "DisneyCharacters", the usage would look like this:

 

(LM:vl-getattributevalue "DisneyCharacters" "MouseName")

 

which should presumably return either "Mickey" or "Minnie".

Kent Cooper, AIA
Message 5 of 5

Ali_Amine
Enthusiast
Enthusiast

Thank you  !

0 Likes