Come scalare oggetti su una dimensione
- Details
- Category: Lisp
- Published on Tuesday, 06 December 2011 11:02
- Hits: 644
Con questo file lisp si introduce una funzione per scalare, cioè ingrandire o rimpiciolire un oggetto rispetto una sola dimensione. Insomma una funzione ibrida tra lo scalare e lo stirare.
;;;SCALEAXIS.LSP ;-------------------------------------------------- ; ERROR TRAPPING ;-------------------------------------------------- (defun errtrap (msg) (cond ((not msg)) ( (member msg '("Function cancelled" "quit / exit abort")) (command "undo" "") ) ( (princ (strcat "\nError: " msg)) (command "undo" "") ) );cond );defun ;-------------------------------------------------- ; MAIN ROUTINE ;-------------------------------------------------- (defun c:scaleaxis (/ *error* *ss1 bspt ax mult refpt refdx newdx) (command "._undo" "end" "._undo" "begin") (setq *error* errtrap) (setq ss1 (ssget)) (setq bspt (getpoint "\nSeleziona il punto base: ")) (initget "X Y Z") (if (not (setq ax (getkword "\nSpecifica l'asse da scalare: ")) );not (setq ax "X") );if (if (not (setq mult (getreal "\nInserire il fattore di scala o : ")) );not (progn (setq refpt1 (getpoint "\nSpecificare la lunghezza di riferimento: ")) (setq refdx (getdist refpt1 "\nSpecificare il secondo punto: ")) (setq newdx (getdist refpt1 "\nSpecificare la nuova lunghezza: ")) (setq mult (/ newdx refdx)) );progn );if (setvar "expert" 2) (setvar "explmode" 1) (command "._-block" "SCALETEMP" bspt ss1 "") (command "._-insert" "SCALETEMP" ax mult bspt "0") (command "._explode" "last" "") (command "._-purge" "blocks" "SCALETEMP" "n") (setvar "expert" 1) (command "._undo" "end") (princ) (*error* nil) )

