Jump to content

Recommended Posts

Posted
(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

Posted (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 by EnM4st3r
Posted (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 by Steven P
Posted

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

 

  • Thanks 1

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