Jump to content

routine dimension and text roulette...help


Recommended Posts

Posted

hello all:

I use this code that was provided to me here:

;;----------------------------------------------------------------------------;;
;; Copy dimension value to another location
(defun C:foo (/ dim BP LastEnt  en first2 first txt name f f2 tx nam )
  (vl-load-com)
  (setvar 'cmdecho 0)
  (command "_UCS" "W")
  (while (setq dim (car (entsel "\nSelect Dimension: ")))
    (setq obj (vlax-ename->vla-object dim))
    (setq BP (vlax-get obj 'TextPosition))
    (setq LastEnt (entlast))
    (command "_.Copy" dim "" "_non" BP (getpoint BP "\nCopy to: "))
    (command "_Explode" (entlast))
    (if (setq en (entnext LastEnt))
      (while en
        (cond
          ((= "MTEXT" (cdr (assoc 0 (entget en))))
            (command "_Explode" en) ;convert mtext to text
          )
          ((= "TEXT" (cdr (assoc 0 (entget en))))
            (progn)
          )
          (t
            (entdel en)
          )          
        )
        (setq en (entnext en))
      )
    )
)
  (princ)
)

extracts text from a dimension and places it at a point that the user selects,

I would like you to do something additional in addition to this...

that when you select the end point for the text position

could I give "enter" and that the text created now changes its content

for example to "text1" and as long as you continue giving "enter"

change to "text2" and so on cyclically

until the text that interests me appears

the idea is to add more texts

 

image.thumb.png.5a1cb061f49db175126fea13249d9d43.pngimage.thumb.png.443621ab415fd785ac8995991ed1ddbe.png

 

 

Posted

I can't get the point. Copy the dimension text, but change it? I would use a routine to cycle the texts, and once the text is created, change it's properties as needed.

Posted

Here is my... text roulette.

(defun c:pp()
  (setq tx (list
	     "text0"
	     "text1"
	     "text2"
	     "text3"
	     ))
  (setq i -1
	el (entget (car (entsel "select text")))
	next T)
  (while next
    (setq i (rem (1+ i) (length tx))
	  el (subst (cons 1 (nth i tx)) (assoc 1 el) el)
	  el (entmod el)
	  st (getstring)
	  next (= "" st))
    )
  (setq el (if (> (strlen st) 0) (subst (cons 1 st) (assoc 1 el) el) el)
	el (entmod el))
  (princ)
  )

Start the program, select a text and press the space bar to cycle the text through the predefined values. Press ESC to break the cycle. Or start the program, select a text and enter your own text from the keyboard -but this text can't contain spaces.

At the beginning of the program, replace those "text0..." strings with the desired ones, you are not limited to 4 lines.

  • Thanks 1
Posted
8 hours ago, leonucadomi said:

Text roulette

 

^^^^ Nice expression. I like it! ^^^^

  • Thanks 1
Posted
8 hours ago, fuccaro said:

^^^^ Nice expression. I like it! ^^^^

 

this helps me a lot

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