Jump to content

Recommended Posts

Posted

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

Posted

To clarify: is the attribute a multline attribute, or are you referring to MText within the block definition?

Posted

Hi Lee,

 

It's a multiline attribute.

 

Thanks,

Losinski

Posted

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)
 )
)

Posted

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)?

Posted

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.

Posted

Nevermind, got it. My lisp knowledge is fairly basic :)

 

 

Thanks!

Posted
Nevermind, got it. My lisp knowledge is fairly basic :)

 

Thanks!

 

It's okay, we all started somewhere ;)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...