rajapower Posted June 7, 2015 Posted June 7, 2015 Hi, i have the text in model space and i have attribute block. i want the model space text to copy the attribute value tag of "ID" Ex. model text is "L00-314-00-EPC-6ELI-01" this is text copy to attribute tag of "ID" Please help me raja Quote
Tharwat Posted June 7, 2015 Posted June 7, 2015 You want to copy single text value to one attributed block and to replace the value in the ID tag name ? This seems to be a completion of your last thread but copy a single text's value instead of writing it from the user , right ? Quote
rajapower Posted June 7, 2015 Author Posted June 7, 2015 thks for reply please find the attached for reference in that i have the text in model space i want to copy the text and paste to the attribute tag "ID" (tag "Id" remain same) to paste the text (value area) copy to attibute block.dwg Quote
Tharwat Posted June 7, 2015 Posted June 7, 2015 This ? (defun c:Test (/ st e ss) ;; Tharwat 07.06.2015 ;; (if (and (setq st (car (entsel "\nSelect Single text :"))) (eq (cdr (assoc 0 (setq e (entget st)))) "TEXT") (princ "\nSelect Attributed blocks :") (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1)))) ) ((lambda (i / sn) (while (setq sn (ssname ss (setq i (1+ i)))) (mapcar '(lambda (x) (if (eq (strcase (vla-get-tagstring x)) "ID") (vla-put-textstring x (cdr (assoc 1 e))))) (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)) )) -1) ) (princ) )(vl-load-com) Quote
rajapower Posted June 8, 2015 Author Posted June 8, 2015 thanks I'll test it. this works properly thanks a lot. Quote
Tharwat Posted June 8, 2015 Posted June 8, 2015 this works properly thanks a lot. Good, you're welcome. Quote
BIGAL Posted June 9, 2015 Posted June 9, 2015 This idea can be expanded fairly significantly we have a drainage schedule in a layout and pick text values from all over the place different layouts, model space and updates the correct line of the schedule, only trick is schedule must exist once only. We just use a simple pick id so it knows which line to update. Quote
rajapower Posted June 11, 2015 Author Posted June 11, 2015 Good, you're welcome. If incase I need to copy the text some there tag in attributes that means same block attributes instead of to mention tag where to copy the text to be very use to me Quote
Olaf Posted November 17, 2021 Posted November 17, 2021 Thank you very much. This works great for me. Quote
kidznok Posted June 13, 2023 Posted June 13, 2023 On 6/7/2015 at 12:34 PM, Tharwat said: This ? (defun c:Test (/ st e ss) ;; Tharwat 07.06.2015 ;; (if (and (setq st (car (entsel "\nSelect Single text :"))) (eq (cdr (assoc 0 (setq e (entget st)))) "TEXT") (princ "\nSelect Attributed blocks :") (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1)))) ) ((lambda (i / sn) (while (setq sn (ssname ss (setq i (1+ i)))) (mapcar '(lambda (x) (if (eq (strcase (vla-get-tagstring x)) "ID") (vla-put-textstring x (cdr (assoc 1 e))))) (vlax-invoke (vlax-ename->vla-object sn) 'getattributes)) )) -1) ) (princ) )(vl-load-com) Hi, Thank you ery much for this LSP. Is it possible to change code to: - select 1 text - select 2 text - select 3 text - select 4 text - select block done I add that I can select 2,3, and 4 text to change 4 attributes but I have select block after each selected text. And is it possible to select text from xref? All best Once again, thank You Quote
Steven P Posted June 13, 2023 Posted June 13, 2023 (edited) To select xref text, you will want to use nentselp instead of entsel to select the text objects - I am not sure of your ability and if this makes sense ? Try this in a LISP or paste into the command line as an example: (princ (cdr (assoc 1 (entget (car (nentselp "Select text: ")))))) ) Then all you need to do is make a loop to select the texts one after another, and paste them into the block.... To paste to a block how is the LISP to know which text to paste to which attribute? I tend to select each text in a block one after another to update, but to do it with one click you'll maybe need to specify the attribute tag names The rest of what you want should all be copy and paste from somewhere, just need to know how to do pasting to attributes EDIT and a bit long winded way to do it, copy and paste, will select texts (up to something like 255 characters long) until you hit enter or space. Just need to know about the blocks EDIT 2: Added dotted pair list for output, just as an idea for copying / pasting many many texts (either use a foreach loop or an assoc search... not decided yet). Commented that part out for now (defun c:txtmg ( / MyTexts EndLoop MyText acount) (setq MyTexts (list)) (setq EndLoop "No") ;;(setq acount 0) (while (= EndLoop "No") (setq MyText (gettext)) (if (= (type MyText) 'ENAME) (progn ;;(setq acount (+ acount 1)) (setq MyTexts (append MyTexts (list (cdr (assoc 1 (entget Mytext)) ) ) ;;(list (cons acount (cdr (assoc 1 (entget Mytext))) )) )) ; end append, end setq (princ (last MyTexts)) ) ; end progn (progn (setq EndLoop "Yes") ) ) ; end if ) ; end while (princ MyTexts) ) (defun gettext ( / endloop enta entb pt result LP) (setvar "errno" 0) (setq endloop "No") (while (and (= endloop "No")(/= 52 (getvar "errno")) ) (setq LP (getvar "lastpoint")) (setq result (nentselp "\nSelect Text: ")) (cond ((= 'list (type result)) ;;do stuff with ENT (if (not (wcmatch (cdr (assoc 0 (entget (car result)))) "TEXT,MTEXT,ATTRIB") ) (progn (princ "\nThats not Text...\n") ) ; end progn (progn (princ "I thank you, that is selected OK: ") (setq enta (car result)) (setq pt (cdr (assoc 10 (entget enta))) ) ;;;;fix for nenset or entsel requirements (setq entb (last (last (nentselp pt)))) (if (and (/= entb nil) (/= (type entb) 'real) ) (if (wcmatch (cdr (assoc 0 (entget entb))) "ACAD_TABLE,*DIMENSION,*LEADER")(setq enta entb)) ) (setq endloop "Yes") ) ; end progn ) ; end if ) ( (or (= "Exit" result)(= "E" result)) (princ "\n-Cancel or Exit- ") ) ( (= nil result) ;; Missed (if (= LP (getvar "lastpoint"))(princ)(princ (strcat "\nMissed: Select text, do try again. "))); ) (t (setq enta "Ended") (setvar "errno" 52) ) ) ; end conds ) ; end while enta ;;Entity name ) Edited June 14, 2023 by Steven P 1 Quote
CAD_Noob Posted June 13, 2023 Posted June 13, 2023 Hi @Tharwat, can this me modified a bit to copy multiple lines and paste it as combined attribute value? in relation to my thread here. 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.