Lisp »Tips 'n Tricks
»CXYZ »1 »2 »3
CXYZ v4
Questa variante del lisp usa solo 2 variabili.
;|
CXYZ.LSP (variante 4)
Copyright (C) 2005 Claudio Piccini.
All rights reserved
www.cg-cad.com
|;
(defun myerror (s)
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
)
(ripVar)
(princ)
)
(defun salVar ()
(setq orto (getvar "orthomode"))
(setq snapp (getvar "osmode"))
(setq snm (getvar "snapmode"))
)
(defun ripVar ()
(command "_redraw")
(setvar "cmdecho" 1)
(setvar "osmode" snapp)
(setvar "snapmode" snm)
(setvar "orthomode" orto)
(setq *error* olderr)
(setq CooXYZ nil)
(princ)
)
(defun CooXYZ ( / pQ p1)
(command "osnap" "_non")
(command "osnap" "_int")
(while (setq pQ (getpoint "\n Seleziona il punto da quotare: "))
(command "osnap" "_non")
(initget 1)
(setq p1 (getpoint "\n Punto inserimento coordinate: ")) ; punto ins. stringa Y
; disegna una parentesi quadra aperta
(command "_pline" (list
(car p1)
(- (cadr p1) (* 4 (/ (getvar "textsize") 2)))
)
"_w" 0.0 0.0
(list
(- (car p1)(/ (getvar "textsize") 2))
(- (cadr p1)(* 4 (/ (getvar "textsize") 2)))
)
(list
(- (car p1)(/ (getvar "textsize") 2))
(+ (cadr p1)(* 5 (/ (getvar "textsize") 2)))
)
(list
(car p1)
(+ (cadr p1)(* 5 (/ (getvar "textsize") 2)))
)
""
)
(foreach coo (list
(cons
(list
(car p1)
(+ (cadr p1)(+ (getvar "textsize")(/ (getvar "textsize") 2)))
0.0
)
(strcat "x = " (rtos (car pQ) 2 2))
)
(cons p1 (strcat "y = " (rtos (cadr pQ) 2 2)))
(cons
(list
(car p1)
(- (cadr p1)(+ (getvar "textsize")(/ (getvar "textsize") 2)))
0.0
)
(strcat "z = " (rtos (caddr pQ) 2 2))
)
)
(command "_text" (car coo) (getvar "textsize") 0.0 (cdr coo))
)
(command "osnap" "_int")
)
)
(defun C:CXYZ (/ olderr snapp snm orto)
(setq olderr *error* *error* myerror)
(setvar "cmdecho" 0)
(salVar)
(CooXYZ)
(ripVar)
)
;;;eof
|
CXYZ v5
Questa variante del lisp usa solo una variabile (la posizione nel disegno del punto da quotare), e questo si ottiene sostituendo la variabile p1 con l'istruzione: (list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)), cioè scrivi il testo della coordinata Y a destra del punto quotato e ad una distanza di 2 volte l'altezza del testo contenuto nella variabile di sistema TEXTSIZE.
;|
CXYZ.LSP (variante 5)
Copyright (C) 2005 Claudio Piccini.
All rights reserved
www.cg-cad.com
|;
(defun myerror (s)
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
)
(ripVar)
(princ)
)
(defun salVar ()
(setq orto (getvar "orthomode"))
(setq snapp (getvar "osmode"))
(setq snm (getvar "snapmode"))
)
(defun ripVar ()
(command "_redraw")
(setvar "cmdecho" 1)
(setvar "osmode" snapp)
(setvar "snapmode" snm)
(setvar "orthomode" orto)
(setq *error* olderr)
(setq CooXYZ nil)
(princ)
)
(defun CooXYZ ( / pQ)
(command "osnap" "_non")
(command "osnap" "_int")
(while (setq pQ (getpoint "\n Seleziona il punto da quotare: "))
; disegna una parentesi quadra aperta
(command "osnap" "_non")
(command "_pline" (list
(car
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)
(- (cadr
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)(* 4 (/ (getvar "textsize") 2)))
)
"_w" 0.0 0.0
(list
(- (car
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)(/ (getvar "textsize") 2))
(- (cadr
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)(* 4 (/ (getvar "textsize") 2)))
)
(list
(- (car
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)(/ (getvar "textsize") 2))
(+ (cadr
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)(* 5 (/ (getvar "textsize") 2)))
)
(list
(car
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)
(+ (cadr
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)(* 5 (/ (getvar "textsize") 2)))
)
""
)
(foreach coo (list
(cons
(list
(car
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)
(+ (cadr
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)(+ (getvar "textsize")(/ (getvar "textsize") 2)))
0.0
)
(strcat "x = " (rtos (car pQ) 2 2))
)
(cons
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
(strcat "y = " (rtos (cadr pQ) 2 2)))
(cons
(list
(car
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)
(- (cadr
(list (+ (car pQ)(* (getvar "textsize") 2))(cadr pQ)) ; p1
)(+ (getvar "textsize")(/ (getvar "textsize") 2)))
0.0
)
(strcat "z = " (rtos (caddr pQ) 2 2))
)
)
(command "_text" (car coo) (getvar "textsize") 0.0 (cdr coo))
)
(command "osnap" "_int")
)
)
(defun C:CXYZ (/ olderr snapp snm orto)
(setq olderr *error* *error* myerror)
(setvar "cmdecho" 0)
(salVar)
(CooXYZ)
(ripVar)
)
;;;eof
|
Lisp »Tips 'n Tricks
Ultimo Aggiornamento_Last Update: 30 Marzo 2005
|