(defun c:HT () (setq HTesti nil) ) (defun c:ScriviDP () (setq OSMODEprec(getvar "OSMODE")) (setq clay(getvar "CLAYER")) (setvar "OSMODE" 0) (setvar "CMDECHO" 0) (if (not HTesti)(setq HTesti(getreal "\n Altezza dei testi: "))) (princ "\n Seleziona le polilinee... ") (setq gruppoide(ssget)) (setq i 0) (if gruppoide (progn (repeat (sslength gruppoide) (if (or (= (cdr(assoc 0 (entget (ssname gruppoide i)))) "POLYLINE")(= (cdr(assoc 0 (entget (ssname gruppoide i)))) "LWPOLYLINE"))(vaivai (ssname gruppoide i))) (setq i(1+ i)) ) )) (setvar "OSMODE" OSMODEprec) (command "_layer" "_s" clay \r) (princ "\n Lavoro eseguito!") (princ) ) (defun vaivai (poly) ;;; (setq poly(entsel "\n Seleziona la polilinea: ")) (if (= iw nil)(setq iw 0)(setq iw(1+ iw))) (POLYListaPunti poly) (setq nome-f(open (strcat (getvar "dwgprefix") "Lunghezze.scr") "a")) (write-line (strcat "_pline") nome-f) (setq ii 0) (setq progr 0) (repeat (- (length lista-punti) 1) (setq cod1_10(nth ii lista-punti)) (setq cod2_10(nth (1+ ii) lista-punti)) (setq DDD(rtos(distance cod1_10 cod2_10) 2 2)) (setq pmedio(list (/ (+ (car cod1_10) (car cod2_10)) 2) (/ (+ (cadr cod1_10) (cadr cod2_10)) 2))) (setq angolo0(angle cod1_10 cod2_10)) ;;; (if (and (< angolo0 (* pi 1.5)) (> angolo0 (* 0.5 pi)))(setq angolo0(+ angolo0 pi))) (cond ((= (getvar "aunits") 0)(setq Agiro 360)) ((= (getvar "aunits") 1)(setq Agiro 360)) ((= (getvar "aunits") 2)(setq Agiro 400)) ((= (getvar "aunits") 3)(setq Agiro (* 2 pi))) ) (setq angolo(* angolo0 (/ Agiro (* 2 pi)))) (command "_layer" "_m" "Lunghezze_orientate" \r) (command "_text" "_c" (polar pmedio (+ angolo0 (/ pi 2)) HTesti) HTesti angolo DDD \r) (if (= ii 0)(setq Y(rtos (cadr cod1_10) 2 2))) (if (= ii 0)(write-line (strcat (rtos (car cod1_10) 2 2) "," Y) nome-f)) (if (= ii 0)(setq progr (car cod1_10))) (setq progr(+ progr (atof DDD))) (write-line (strcat (rtos progr 2 2) "," Y) nome-f) ;;; (scriviTXTtesti iw DDD) (setq ii(1+ ii)) ) (write-line (strcat "") nome-f) (close nome-f) ) ;--------------------------------------------------------------------- (defun POLYListaPunti (RF0) (setq lista-punti nil) (setq Xmin 100000000.00) (setq Ymin 100000000.00) (setq Xmax -100000000.00) (setq Ymax -100000000.00) (setq Ramo(entget RF0)) (if (= (cdr(assoc 0 Ramo)) "POLYLINE") (progn (setq 0ent0(entnext RF0)) (setq 0ent(entget 0ent0)) (setq 0entT(cdr(assoc 0 0ent))) (while (/= 0entT "SEQEND") (setq X(car (cdr(assoc 10 0ent)))) (setq Y(cadr (cdr(assoc 10 0ent)))) (setq Z(caddr (cdr(assoc 10 0ent)))) (setq lista-punti(cons (list X Y Z) lista-punti)) (setq 0ent0(entnext 0ent0)) (setq 0ent(entget 0ent0)) (setq 0entT(cdr(assoc 0 0ent))) (if (< X Xmin)(setq Xmin X)) (if (< Y Ymin)(setq Ymin Y)) (if (> X Xmax)(setq Xmax X)) (if (> Y Ymax)(setq Ymax Y)) ) ) ) (if (= (cdr (assoc 0 Ramo)) "LWPOLYLINE") (progn (setq lista-punti0(member (assoc 10 Ramo) Ramo)) (setq cont 0) (repeat (/ (- (length lista-punti0) 1) 4) (setq cod(nth cont lista-punti0)) (setq lista-punti(cons (list (cadr cod) (caddr cod) 0) lista-punti)) (if (< X Xmin)(setq Xmin X)) (if (< Y Ymin)(setq Ymin Y)) (if (> X Xmax)(setq Xmax X)) (if (> Y Ymax)(setq Ymax Y)) (setq cont(+ cont 4)) ) )) ) ;;;;--------------------------------------------------------------------- (defun scriviTXTtesti (polilinea testo) (setq nome-f(open (strcat (getvar "dwgprefix") "Lunghezze.scr") "a")) (write-line (strcat (rtos polilinea 2 0) ";" Testo ";0") nome-f) (close nome-f) ) ;;;;--------------------------------------------------------------------- (princ "\n ") (princ "\n Digitare ScriviDP per lanciare il programma!") (princ "\n Digitare HT per modificare l'altezza dei testi!") (princ)