Jump to content

copy multiline attribute data to command line


Recommended Posts

Posted

Hello,

iàm looking for a lisp that copies multiline attribute data from TAG1 from a block and paste it to the command line/promt.

 

thanks,

 

JM

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    9

  • pmxcad

    8

  • Lee Mac

    7

  • pBe

    3

Top Posters In This Topic

Posted

Here is a function to return the textstring from an MText Attribute, Attribute, MText, or Text entity:

 

(defun _gettextstring ( ename )
   (apply 'strcat
       (apply 'append
           (mapcar
               (function
                   (lambda ( pair )
                       (if (member (car pair) '(1 3))
                           (list (cdr pair))
                       )
                   )
               )
               (entget ename)
           )
       )
   )
)

 

Use the 'command' function to submit text to the command line.

Posted

Maybe ....

 

(defun c:test (/ acdoc ss sset nme)
 (vl-load-com)
 (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
 (if (setq ss (ssget "+.:S" '((0 . "INSERT")(66 . 1))))
   (progn
     (setq sset (ssname ss 0))
     (setq nme (cdr (assoc 2 (entget sset))))
     (vlax-for x (vla-item (vla-get-blocks acdoc) nme)
       (if (eq (vla-get-objectname x) "AcDbAttributeDefinition")
         (princ (vla-get-tagstring x))
       )
     )
   )
   (princ)
 )
 (princ)
)

Tharwat

Posted

One more for multiple tags ..... :)

 

(defun c:test (/ acdoc ss strngs)
 (vl-load-com)
 (setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
 (if (setq ss (ssget "+.:S" '((0 . "INSERT") (66 . 1))))
   (vlax-for x (vla-item (vla-get-blocks acdoc)
                         (cdr (assoc 2 (entget (ssname ss 0))))
               )
     (if (eq (vla-get-objectname x) "AcDbAttributeDefinition")
       (setq strngs (cons (vla-get-tagstring x) strngs))
     )
   )
   (princ)
 )
 (print strngs)
 (princ)
)

 

Tharwat

Posted
Why are you digging through the Block Definition Tharwat? :?

 

Hi Lee .

 

I am digging through Block because the OP mentioned that the ( TAG1 from a Block ) . Did I get them wrong or missed the point ? :unsure:

Posted

Sorry this not what i had in mind.

I want to store a script (txt) in a block in attribute with te tag "TAG1". Run the lisp, select a that block and runs the script. The attribute "TAG1" is invisible.

So run the lisp, select the block with the script in it, en it runs that script due pasting the txt data from multiline attribute "TAG1" to the command promt.

 

JM

Posted

Does it mean that you want to replace TAG1 with a text that you already have after selecting attributed block ?

Posted

TAG1 is a attribute from the block. Ok, lets name the attribute SCR. After inserting the block in the drawing (block is a square), fill in the SCR attribute with text (=script) and fill in other attributes from that block, like description from that block. I want to create a sort of button that can run a script, placet in the SCR attribute from that block. SCR attribute is not visiable.

 

JM

Posted
I am digging through Block because the OP mentioned that the ( TAG1 from a Block )

 

Yes, but you are accessing the Attribute Definition (ATTDEF) not the Attribute object (ATTRIB), hence you will not have access to the attribute value [since this value would be different for each Block Reference (INSERT)].

 

Use either the GetAttributes method on the Block Reference, or the (entnext) function on the INSERT entity.

Posted
So run the lisp, select the block with the script in it, en it runs that script due pasting the txt data from multiline attribute "TAG1" to the command promt.

 

I have provided a function to return the value stored in an Attribute, you will need to construct a function to make a selection of block, access the Attributes, then submit the value to the command line.

Posted

Do you mean that I should have used the function *vla-get-textstring* instead of *vla-get*tagstring* ?

 

Am I missing something else also here ! :)

Posted
Do you mean that I should have used the function *vla-get-textstring* instead of *vla-get*tagstring* ?

 

Try using vla-get-textstring and you will see your error.

Posted

Yeah..... that would get the default value and not text string one ....

 

And I guess that's why I have used the vla-get-tagstring . Agree ?

Posted
And I guess that's why I have used the vla-get-tagstring . Agree ?

 

No. The TagString property returns the TagString, not the TextString. Re-read post#11.

Posted

I guess that I do not know much about the differences between (ATTDEF) and (ATTRIB) , and this is the main issue of knowing

to use the correct function or the correct way to get the proper needed value (tag or text string ).

 

Thanks .

Posted
can you upload a dwg shows before and after process ?

 

 

This is the block i wanna use..............

 

JM

BUTTON.dwg

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