pmxcad Posted September 21, 2011 Posted September 21, 2011 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 Quote
Lee Mac Posted September 21, 2011 Posted September 21, 2011 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. Quote
Tharwat Posted September 21, 2011 Posted September 21, 2011 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 Quote
Tharwat Posted September 21, 2011 Posted September 21, 2011 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 Quote
Lee Mac Posted September 21, 2011 Posted September 21, 2011 Why are you digging through the Block Definition Tharwat? Quote
Tharwat Posted September 22, 2011 Posted September 22, 2011 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 ? Quote
pmxcad Posted September 22, 2011 Author Posted September 22, 2011 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 Quote
Tharwat Posted September 22, 2011 Posted September 22, 2011 Does it mean that you want to replace TAG1 with a text that you already have after selecting attributed block ? Quote
pmxcad Posted September 22, 2011 Author Posted September 22, 2011 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 Quote
Tharwat Posted September 22, 2011 Posted September 22, 2011 can you upload a dwg shows before and after process ? Quote
Lee Mac Posted September 22, 2011 Posted September 22, 2011 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. Quote
Lee Mac Posted September 22, 2011 Posted September 22, 2011 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. Quote
Tharwat Posted September 22, 2011 Posted September 22, 2011 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 ! Quote
Lee Mac Posted September 22, 2011 Posted September 22, 2011 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. Quote
Tharwat Posted September 22, 2011 Posted September 22, 2011 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 ? Quote
Lee Mac Posted September 22, 2011 Posted September 22, 2011 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. Quote
Tharwat Posted September 22, 2011 Posted September 22, 2011 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 . Quote
Lee Mac Posted September 22, 2011 Posted September 22, 2011 My examples: http://lee-mac.com/attributefunctions.html Quote
pmxcad Posted September 22, 2011 Author Posted September 22, 2011 Here is the block i want to use. JM BUTTON.dwg Quote
xcad Posted September 23, 2011 Posted September 23, 2011 can you upload a dwg shows before and after process ? This is the block i wanna use.............. JM BUTTON.dwg 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.