;----------------------------------------------------------------------------- ; CHGSCA.LSP v2.0 - Jason Osgood 03/01/90 ; ~~~~~~~~~~ ; Change the scale of the linetype for selected entities. ; ; Notice ; ~~~~~~ ; CHGSCA.LSP was created solely by Me in response to a need expressed by Ron ; Lloyd on Alacrity BBS sometime in January 1990. ; ; CHGSCA.LSP is being placed into the public domain out of the kindness of My ; eternally generous heart. If you modify/enhance/cripple CHGSCA.LSP, I would ; like to hear about your efforts. Feedback is a RARE commodity. But the ; occasional AutoDude who does take the effort to say "Gee, neat program! I ; made it even neater by adding..." makes it all worthwhile. ; ; Oh yea, please note: USE AT YOUR OWN RISK! ; ; The Author is not responsible for the following (but not limited to): ; the Federal Deficit, rising medical costs, accidental erasure of random ; files on your hard disk, missed deadlines, illiteracy, illegal dumping of ; toxins in the enviroment, legal dumping of toxins in the enviroment, ; overexposure to VDT radiation, endless games of "telephone tag", your ; morgage payments, the shortage of common sense, and T.V. game shows. ; ; Whodunnit? ; ~~~~~~~~~~ ; Jason Osgood ; Alacrity ; 12405 SE 25th St ; Bellevue, WA 98005 ; ; CompuServe: 73417,1756 ; Alacrity BBS: (206)643-LISP ; Voice phone: (206)746-0680 <-- Call while I'm in bed and you DIE! ; ; Revisions ; ~~~~~~~~~ ; 02/10/90 - Original release ; ; 03/01/90 - Updates by J. Osgood ; ; - Writes scaled linetype definition to dummy file instead of ACAD.LIN. ; - Enhanced linetype name entry. Allows "picking" of linetype or ; keyboard entry. ; - Will determine original (unscaled) linetype name, even if you pick an ; entity that uses a scaled linetype. ; - Allows changing of linetype scale factor back to 1.0. ; - Allows selection of multiple entities to modify. ; ; Comments ; ~~~~~~~~ ; Linetype to be scaled must be loaded into drawing for CHGSCA.LSP to use it. ; Linetypes scaled by CHGSCA.LSP are not written to file. There is no way ; to directly transfer a scaled linetype to another drawing. ; ; CHGSCA.LSP adds the scale factor to the name of the linetype using the ; following format: ; ; OriginLinetypeName$$XX-XXXX ; | | | || ; | | | |+- Fractional portion of scale (to 4 decimal places) ; | | | +-- Hyphen in place of a decimal point ; | | +---- Whole units portion of scale ; | +------ Two dollar signs denoting beginning of scale info ; +------------------------ Original linetype definition name ; ; Prompts ; ~~~~~~~ ; Linetype (or Pick): ; Select object: <--- When "picking" linetype ; Scale factor for linetype? <1.0>: ; Select objects: ; XX entities changed. ; ; Error Messages ; ~~~~~~~~~~~~~~ ; No object selected, try again. ; Linetype is ByLayer or not available for selected entity. ; Linetype is ByBlock. ; Linetype not found, try again. ; ; Obnoxious Advertisement ; ~~~~~~~~~~~~~~~~~~~~~~~ ; All Truly Cool AutoDudes Call Alacrity BBS (206)643-LISP 8N1 12/2400 24hrs ; ;----------------------------------------------------------------------------- ; Get keyed value from assoc list (defun _GET (a b) (cdr (assoc a b))) ; New name for scaled linetype (defun _LTNAME (ltype scale) (strcat ltype "$$" ; Replace decimal point with hyphen (rtos (fix scale) 2 0) "-" (substr (rtos (rem scale (fix scale)) 2 4) 3) ) ) ; Get string input, returns Nil for null input (defun _GETSTR (temp) (if (not (eq (setq temp (getstring temp)) "")) temp) ) ; Determine if linetype was created by CHGSCA.LSP (defun _SCALT? (temp) (setq i (strlen temp)) (while (and (not (zerop (setq i (1- i)))) (not (eq "$$" (substr temp i 2))) ) ) (if (not (zerop i)) (1- i)) ) (defun C:CHGSCA (/ ename edata scale temp table ltype codes ss) (setvar "CmdEcho" 0) ; Get linetype name (while (cond ((not (setq temp (_getstr "\nLinetype (or Pick): "))) nil) ((eq (strcase (substr temp 1 1)) "P") (while (cond ; Must pick an object ((not (setq temp (entsel))) (princ "\nNo object selected, try again.") ) ( (not (setq ename (car temp) edata (entget ename) temp (_get 6 edata) ) ) (prompt "\nLinetype is ByLayer or not available for selected entity.") ) ((eq temp "BYBLOCK") (prompt "\nLinetype is ByBlock.") ) (T (setq ltype temp) (prompt ltype) nil) ) ) (not ltype) ) ((tblsearch "LTYPE" temp) (setq ltype temp) nil) (T (princ "\nLinetype not found, try again.")) ) ) (cond ( (and ltype (progn (initget 6) (setq scale (getreal (strcat "\nScale factor for linetype? <" (rtos 1.0) ">: ")) ) (cond (scale) (t)) ) (setq ss (ssget)) ) ; Remove CHGSCA.LSP modifier to linetype name, if present (if (setq temp (_scalt? ltype)) (setq ltype (substr ltype 1 temp))) ; Get linetype definition (setq table (tblsearch "LTYPE" ltype)) ; If scale is not 1.0, add modifier to name (if scale (setq ltype (_ltname ltype scale))) (cond ((tblsearch "LTYPE" ltype)) (T (foreach temp table (if (eq (car temp) 49) (setq codes (append codes (list (rtos (* scale (cdr temp)) 2 4) ",")) ) ) ) (command ".LINETYPE" "C" ltype "CHGSCA" (_get 3 table) (apply 'strcat codes) "L" ltype "" "" "DEL" "CHGSCA.LIN" ) ) ) (command ".CHPROP" ss "" "LT" ltype "") (prompt (strcat "\n" (itoa (sslength ss)) " entities changed.")) ) ) (princ) ) ;---< End Of File >---