Ajmal Posted May 11, 2020 Posted May 11, 2020 How can I convert all Text Strings from Millimeter to meter? Quote
Ajmal Posted May 11, 2020 Author Posted May 11, 2020 (defun c:Test (/ *error* dz ss f) ;; ================================================== ;; ;; Author : Tharwat Al Shoufi .Date: 22.Nov.2014 ;; ;; Converts conversely Text Strings from ;; ;; Millimeter to Inch ;; ;; ================================================== ;; (defun *error* (msg) (if dz (setvar 'DIMZIN dz) ) (if (not (wcmatch msg "*CANCEL*,*EXIT*,*BREAK*")) (princ (strcat "\n ** Error : " msg " **")) ) ) (princ "\n Select Texts that either start with numbers or X character :" ) (if (and (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT") (1 . "1*,2*,3*,4*,5*,6*,7*,8*,9*,x*,X*") ) ) ) (progn (initget 6 "Inch Millimeter") (setq *formula* (cond ((getkword (strcat "\n Specify convertion formula [inch/ Millimeter] < " (if *formula* *formula* (setq *formula* "Inch") ) " > :" ) ) ) (*formula*) ) ) ) (if (eq *formula* "Inch") (setq f (list (/ 1.0 25.4) 4 0)) (setq f (list 25.4 2 2)) ) ) (progn (setq dz (getvar 'DIMZIN)) (setvar 'DIMZIN 0) ((lambda (x / sn e s a) (while (setq sn (ssname ss (setq x (1+ x)))) (entmod (subst (cons 1 (if (wcmatch (setq a (strcase (substr (setq s (cdr (assoc 1 (setq e (entget sn)))) ) 1 1 ) ) ) "X*" ) (if (/= (atof (substr s 2)) 0.) (strcat a (rtos (* (atof (substr s 2)) (car f)) (cadr f) (caddr f) ) ) s ) (rtos (* (atof s) (car f)) (cadr f) (caddr f)) ) ) (assoc 1 e) e ) ) ) ) -1 ) (setvar 'DIMZIN dz) ) ) (princ) ) @Tharwat can you edit this one "mm to m" Quote
Jonathan Handojo Posted May 11, 2020 Posted May 11, 2020 Um... (rtos (cvunit 100 "mm" "m") 2 <number of decimal places>) Quote
BIGAL Posted May 11, 2020 Posted May 11, 2020 (edited) Are they only number text so 100 times into m would not work ? The wall length is 12234 and made of brick Test on line above. Edited May 11, 2020 by BIGAL 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.