Estrazione vertici da una polilinea
- Details
- Category: Lisp
- Published on Tuesday, 06 December 2011 21:10
- Hits: 448
Il seguente codice serve per estrarre il valore dei vertici di una polilinea e li salva in un file di testo.
(defun C:ScrivipolyXYZ () (setq Pol (Entsel "\n....... Seleziona La Polilinea: ")) (setq Separatore (Getstring "\n... Carattere Separatore Di Num X Y Z: ")) (setq Nomefile (getfiled "File Txt Con Le Coordinate Della Polilinea" (getvar "Dwgprefix") "Txt"1)) (if (And Pol Nomefile) (progn (if (= Separatore "") (setq Separatore " ") ) (setq Ff (Open Nomefile "W")) (if (= (Cdr (Assoc 0 (Entget (Car Pol)))) "LWPOLYLINE") (progn (setq Li-Crea Nil) (setq Conta 0) (setq I 0) (setq Z(Cdr (Assoc 38 (Entget (Car Pol))))) (repeat (Length (setq lwp(entget(car pol)))) (setq Lwele (Nth I Lwp)) (if (= (Car Lwele) 10) (progn (setq X (Cadr Lwele)) (setq Y (Caddr Lwele)) (setq Xconta (Itoa (setq Conta (+ Conta 1)))) (Write-Line (strcat Xconta Separatore (Rtos X 2 2) Separatore (Rtos Y 2 2) Separatore (Rtos Z 2 2) ) Ff ) ) ) (setq I (+ I 1)) ) (Close Ff) ) ) (if (= (Cdr (Assoc 0 (Entget (Car Pol)))) "POLYLINE") (progn (setq Li-Crea Nil) (setq Pol-princ (Entget (Car Pol))) (setq Vertice (Entnext (Car Pol))) (setq Vert (Entget Vertice)) (setq Conta 0) (While (/= (Cdr (Assoc 0 Vert)) "SEQEND") (setq X (Car (Cdr (Assoc 10 Vert)))) (setq Y (Cadr (Cdr (Assoc 10 Vert)))) (setq Z (Caddr (Cdr (Assoc 10 Vert)))) (setq Conta (+ Conta 1)) (setq Xconta (Itoa Conta)) (Write-Line (strcat XcontaSeparatore (Rtos X 2 2) Separatore (Rtos Y 2 2) Separatore (Rtos Z 2 2) ) Ff ) (setq Vertice (Entnext Vertice)) (setq Vert (Entget Vertice)) ) (Close Ff) ) ) (alert (strcat "Creato Il File: " Nomefile)) (princ) )) ) (princ "\n Digitare ScrivipolyXYZ Per Lanciare Il Programma!") (princ)

