;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; Converter.lsp By Michael Bulatovich September 3rd, 2001 ; ; www.michaelbulatovich.ca ; ; ; ; Makes a copy of a selected text entity containing a real ; ; number and converts the original value to Metric or ; ; Imperial units in the copy. Concieved for labels or tables. ; ; Must have sqm and sqft defined as units in the acad.unt file ; ; in order to work. ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:converter (/ item itemlist itemstring itemvalue newvalue newstring newtext newlist ) (setvar "cmdecho" 0) (if (equal conversiontype nil) (progn (prompt "\nMakes Metric/Imperial Converted Copies of Numbers") (initget 1 "1 2") (setq conversiontype (getkword "\nSpecify conversion type: <1> Sq.m-->Sq.ft. | <2> Sq.ft.-->Sq.m" ) ) ) (progn (if (equal conversiontype "1") (progn (prompt "\n Sq. Ft.?>/") (setq cont (getstring)) (if (= cont (or "n" "N")) (setq conversiontype "2") ) ) ) (if (equal conversiontype "2") (progn (prompt "\n Sq. M.?>/") (setq cont (getstring)) (if (= cont (or "n" "N")) (setq conversiontype "1") ) ) ) ) ) (setq item (car (entsel "\n<<<<< Pick number to convert:>>>>>")) ) (setq itemlist (entget item)) (setq itemstring (cdr (assoc 1 itemlist))) (setq itemvalue (atof itemstring)) (if (equal conversiontype "1") (progn (setq newvalue (cvunit itemvalue "sqm" "sqft") ) ) (progn (setq newvalue (cvunit itemvalue "sqft" "sqm") ) ) ) (setq newstring (rtos newvalue 2 3)) (prompt "\nCopy converted number from original number to new location:(Base point/Second point)" ) (command "copy" item "" pause pause) (setq newtext (entlast)) (setq newlist (entget newtext)) (setq newlist (subst (cons 1 newstring) (assoc 1 newlist) newlist)) (entmod newlist) (princ) )