Dayananda Posted December 11, 2024 Posted December 11, 2024 (defun c:retext () (setq ent (entsel "\nSelect a text object: ")) (if ent (progn (setq text (cdr (assoc 1 (entget (car ent))))); absorbed value of text (setq alist(entget(car(entsel "\nSelect a dim object to replace: ")))); list of enties of selected dim (if alist (progn (setq alist (subst (cons 42 (read text)) (assoc 42 alist) alist)); added text value to dim entity list (entmod alist ) ) ) ) ) ) Why this code not functioning Quote
EnM4st3r Posted December 11, 2024 Posted December 11, 2024 (edited) since dxf 42 is the distance of the dimension, i guess you want to replace the dimension text with your selected one? You cannot use your text in 42 tough. But you can use dxf 1 for the textoverride. Also you do not need to 'read' the string as you need your text value as a string. Edited December 11, 2024 by EnM4st3r Quote
Steven P Posted December 11, 2024 Posted December 11, 2024 (edited) Adding to EnM4st3r comments, For the dimension text you'll also need to use nested entsel (nentsel) otherwise you'll just return the dimension entity and not the parts of it... however you might need to add some error warning if the user selects say one of the lines or arrows. There are ways round this but for a simple LISP like this a simple warning might be enough "Dimension Text Not Selected Ending Command", something like that. (defun c:retext ( / ent text alist) (setq ent (nentsel "\nSelect a text object: ")) ;; Select an text entity (if ent ;; If an entity is selected (progn (setq text (cdr (assoc 1 (entget (car ent))))) ;; absorbed value of text (setq alist (entget (car (nentsel "\nSelect a dim object to replace: "))));; Selected DIM 'nested' entity (if alist (progn (setq alist (subst (cons 1 text) (assoc 1 alist) alist)); added text value to dim entity list (entmod alist ) ) ;; End progn ) ;; End if alist ) ;; End progn ) ;; End if ent ) However I would recommend Lee Macs Copy Swap Text LISP (CTX), from his website which will do this for you but adds in functions to copy text to any text object. 1 command to do many things and less specific Edited December 11, 2024 by Steven P Quote
BIGAL Posted December 11, 2024 Posted December 11, 2024 If you use VL can use the Textoverride property. (defun c:wow ( / obj str) (setq obj (vlax-ename->vla-object (car (entsel "\nPick text object ")))) (setq str (vlax-get obj 'textstring)) (setq obj (vlax-ename->vla-object (car (entsel "\nPick Dim object ")))) (vlax-put obj 'Textoverride str) (princ) ) ; (vlax-put obj 'Textoverride (strcat "<> " str)) 1 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.