Flip_73 Posted November 2, 2014 Posted November 2, 2014 Hello I would like to have a simple lisp routine that divide all the numbers in a given layer by 20, can anybody help me? Thx Quote
Lee Mac Posted November 3, 2014 Posted November 3, 2014 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) Quote
Flip_73 Posted November 3, 2014 Author Posted November 3, 2014 Thank you very much. It works perfectly. Quote
ajay11 Posted February 26, 2016 Posted February 26, 2016 i want a lisp to divide many text values number by a perticular value????? please help 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.