(defun c:pinchia ()
(setvar "cmdecho" 0)
(setq Selectedfile(getfiled "Select File name .txt" "" "txt" 1))
(setq filename(open Selectedfile "w"))
(write-line (strcat "id X1 Y1 Z1 X2 Y2 Z2 X3 Y3 Z3 X4 Y4 Z4") filename)
(setq ss1 (ssget "x" '((0 . "3DFACE"))))
(setq i 0)
(repeat (sslength ss1)
     (setq EntData (entget (ssname ss1 i)))
     (setq pt1 (cdr (assoc 10 EntData)))
     (setq X1 (rtos (car pt1) 2 4))
     (setq Y1 (rtos (cadr pt1) 2 4))
     (setq Z1 (rtos (cadr (cdr pt1)) 2 4))
     (setq pt2 (cdr (assoc 11 EntData)))
     (setq X2 (rtos (car pt2) 2 4))
     (setq Y2 (rtos (cadr pt2) 2 4))
     (setq Z2 (rtos (cadr (cdr pt2)) 2 4))
     (setq pt3 (cdr (assoc 12 EntData)))
     (setq X3 (rtos (car pt3) 2 4))
     (setq Y3 (rtos (cadr pt3) 2 4))
     (setq Z3 (rtos (cadr (cdr pt3)) 2 4))
     (setq pt4 (cdr (assoc 13 EntData)))
     (setq X4 (rtos (car pt4) 2 4))
     (setq Y4 (rtos (cadr pt4) 2 4))
     (setq Z4 (rtos (cadr (cdr pt4)) 2 4))
     (write-line (strcat (itoa (1+ i)) " " X1 " " Y1 " " Z1 " " X2 " " Y2 " " Z2 " " X3 " " Y3 " " Z3 " " X4 " " Y4 " " Z4) filename)
     (setq i(1+ i))
)
(close filename)
(princ)
)