Hi,


Can anyone assist me with the following issue.


I have a dynamic block with multiple visibility states. (Vis1 to Vis5 for example)


In each visibilty I habe two unique attributes.


So in Vis1 has two attibute tags called Length1 & Width1

........Vis2 has two attibute tags called Length2 & Width2

......


I want to get the value of the attributes in the current visibility state and save them as variables Var1 and Var2.


The only joy in searching was what I found on Lee Mac's website but I have not been able to make any progress with his code. (see below)


Thanks for any help on this


Code:

Get Attribute Value




Select all ;;----------------=={ Get Attribute Value 
}==-----------------;;
;;                                                            
;;
;;  Returns the attribute value associated with the specified 
;;
;;  tag, within the supplied block, if 
present.               
;;
;;------------------------------------------------------------;;
;;  
Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       
;;
;;------------------------------------------------------------;;
;;  
Arguments:                                                
;;
;;  block - VLA Block Reference 
Object                        
;;
;;  tag   - Attribute 
TagString                               
;;
;;------------------------------------------------------------;;
;;  
Returns:  Attribute TextString, else 
nil                  
;;
;;------------------------------------------------------------;;




(defun LM:vl-GetAttributeValue ( block tag )
    (setq tag 
(strcase tag))
    
(vl-some
        
(function
            
(lambda ( attrib 
)
                
(if (eq tag (strcase (vla-get-Tagstring 
attrib)))
                    
(vla-get-TextString 
attrib)
                
)
            
)
        
)
        (vlax-invoke block 
'GetAttributes)
    )
)





(defun c:test ( / ss )  
    (if (setq ss (ssget 
"_+.:E:S" '((0 . "INSERT") (66 . 
1))))
        
(princ
            
(LM:vl-GetAttributeValue
                
(vlax-ename->vla-object (ssname ss 
0))
                
(getstring "\nSpecify Tag String: 
")
            
)
        )
    
)
    (princ)
)
(vl-load-com)





;;----------------=={ Get Visibility State 
}==----------------;;
;;                                                            
;;
;;  Returns the value of the Visibility Parameter of 
a        ;;
;;  Dynamic Block (if 
present)                                
;;
;;------------------------------------------------------------;;
;;  
Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       
;;
;;------------------------------------------------------------;;
;;  
Arguments:                                                
;;
;;  block  -  VLA (Dynamic) Block Reference 
Object            
;;
;;------------------------------------------------------------;;
;;  
Returns:  Value of Visibility Parameter, else 
nil         
;;
;;------------------------------------------------------------;;




(defun LM:GetVisibilityState ( block )
    
(
        (lambda ( name 
)
            
(vl-some
                
(function
                    
(lambda ( prop 
)
                        
(if (eq name (vla-get-propertyname 
prop))
                            
(vlax-get prop 
'value)
                        
)
                    
)
                
)
                
(vlax-invoke block 
'getdynamicblockproperties)
            
)
        
)
        (LM:GetVisibilityParameterName 
block)
    )
)