Losinski Posted February 18, 2016 Posted February 18, 2016 Hi all, I need a LISP that will look at a block, extract it's attribute value, and set it to a variable. This is all to happen behind the scenes (no prompts). The catch: The value of the attribute is multiline text (MTEXT). In the block the attribute may look as follows: " This is a demonstration showing how the attribute looks " ______________________________________________________________________________________ Assuming the following names: BLK123 (block) ATT123 (attribute) VAR123 (variable) I need the value of ATT123 (from BLK123) stored in VAR123. !VAR123 will then read "This is a demonstration showing how the attribute looks." I have been researching and testing different codes for about an hour and can't seem to find one that works with MTEXT. Any ideas? Thanks, Losinski Quote
Lee Mac Posted February 18, 2016 Posted February 18, 2016 To clarify: is the attribute a multline attribute, or are you referring to MText within the block definition? Quote
Losinski Posted February 18, 2016 Author Posted February 18, 2016 Hi Lee, It's a multiline attribute. Thanks, Losinski Quote
Losinski Posted February 19, 2016 Author Posted February 19, 2016 Sure, here you go. dwg123.dwg Quote
Tharwat Posted February 19, 2016 Posted February 19, 2016 Give this a play: (if (setq s (ssget "_+.:S:E" '((0 . "INSERT")(66 . 1)))) (vl-some '(lambda (x) (and (= (vla-get-tagstring x) "ATT123") (setq ATT123 (vla-get-textstring x)) ) ) (vlax-invoke (vlax-ename->vla-object (ssname s 0)) 'getattributes) ) ) Quote
Losinski Posted February 19, 2016 Author Posted February 19, 2016 Worked just fine in that test drawing. I just modified it to take that manual selection out: (if (setq s (ssget [b]"X"[/b] '((0 . "INSERT")(66 . 1)))) (vl-some '(lambda (x) (and (= (vla-get-tagstring x) "ATT123") (setq [b]VAR123[/b] (vla-get-textstring x)) ) ) (vlax-invoke (vlax-ename->vla-object (ssname s 0)) 'getattributes) ) ) What would happen if I had two attributes with the same name (two different blocks?) Can the search be block specific (search for ATT123 in BLK123)? Quote
Tharwat Posted February 19, 2016 Posted February 19, 2016 In your example you codes would check ONLY one block although you have selected all Attributed Blocks that you have in your drawing. So you need to cycle through each block and you can have the outcome as a list since you would need to get all attribute values with the same tag name. Quote
Losinski Posted February 19, 2016 Author Posted February 19, 2016 Nevermind, got it. My lisp knowledge is fairly basic Thanks! Quote
Tharwat Posted February 19, 2016 Posted February 19, 2016 Nevermind, got it. My lisp knowledge is fairly basic Thanks! It's okay, we all started somewhere Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.