Jump to content

Change Text divinding it by a number


Flip_73

Recommended Posts

Here is a quickly-written solution:

(defun c:divtxt ( / d e i n s )
   (initget 2)
   (if
       (and
           (setq d (getreal "\nSpecify divisor: "))
           (setq e (car (entsel "\nSelect object on layer to process: ")))
           (setq s
               (ssget "_X"
                   (append '((0 . "TEXT,MTEXT")) (kg:ssgetfilternum)
                       (list
                           (assoc 8 (entget e))
                           (if (= 1 (getvar 'cvport))
                               (cons 410 (getvar 'ctab))
                              '(410 . "Model")
                           )
                       )
                   )
               )
           )
       )
       (repeat (setq i (sslength s))
           (if (setq e (entget (ssname s (setq i (1- i))))
                     n (distof (cdr (assoc 1 e)))
               )
               (entmod (subst (cons 1 (LM:num->str (/ n d))) (assoc 1 e) e))
           )
       )
   )
   (princ)
)

;; Number to String  -  Lee Mac
;; Converts a supplied numerical argument to a string

(defun LM:num->str ( x / dim rtn )
   (if (equal x (atof (rtos x 2 0)) 1e-
       (rtos x 2 0)
       (progn
           (setq dim (getvar 'dimzin))
           (setvar 'dimzin 
           (setq rtn (vl-catch-all-apply 'rtos (list x 2)))
           (setvar 'dimzin dim)
           (if (not (vl-catch-all-error-p rtn)) rtn)
       )
   )
)

(defun kg:ssgetfilternum ( ) ;; roy_043
  '(
       (1 . "~*[~-.0-9]*")
       (1 . "~*`.*`.*")
       (-4 . "<OR")
           (1 . "~*-*")
           (-4 . "<AND")
               (1 . "-*")
               (1 . "~*-*-*")
           (-4 . "AND>")
       (-4 . "OR>")
   )
)

(princ)

Link to comment
Share on other sites

  • 1 year later...

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