You are on page 1of 3

;;; ;;; ;;; ;;; ;;; ;;;

12345678901234567890123456789012345678901234567890 POS2.LSP A program to extract the xy coordinates from any polyline and export them to an ascii file. Aug 30 2001 D.O. PDMS - In AutoCAD draw your plate with a pline in clockwise rotation, make sure the corner of plate is at 0, 0, 0. type appload and load plate

(defun ERR (S) (if (= S "Function cancelled") (princ "\nVERTEXT - cancelled: ") (progn (princ "\nVERTEXT - Error: ") (princ S) (terpri)) ;_ progn ) ; if (RESETTING) (princ "SYSTEM VARIABLES have been reset\n") (princ) ) ; err (defun SETV (SYSTVAR NEWVAL) (setq X (read (strcat SYSTVAR "1"))) (set X (getvar SYSTVAR)) (setvar SYSTVAR NEWVAL) ) ; setv (defun SETTING () (setq OERR *ERROR*) (setq *ERROR* ERR) (SETV "CMDECHO" 0) (SETV "BLIPMODE" 0) ) ; end of setting (defun RSETV (SYSTVAR) (setq X (read (strcat SYSTVAR "1"))) (setvar SYSTVAR (eva l X))) ; restv (defun RESETTING () (RSETV "CMDECHO") (RSETV "BLIPMODE") (setq *ERROR* OERR)) ; end of resetting (defun DXF (CODE ENAME) (cdr (assoc CODE (entget ENAME)))) ; dxf (defun VERTEXT (/ EN VLIST) (setq EN (GET-EN)) (if (= (DXF 0 EN) "LWPOLYLINE") (setq VLIST (GET-LWVLIST EN)) (setq VLIST (GET-PLVLIST EN)) ) ; if (WRITE-IT VLIST EN) ) ;_ vertext (defun GET-EN (/ NO-ENT EN MSG1 MSG2) (setq NO-ENT 1 EN NIL MSG1 "\nSelect a polyline: " MSG2 "\nNo polyline selected, try again." ) ; setq (while NO-ENT (setq EN (car (entsel MSG1))) (if (and EN (or (= (DXF 0 EN) "LWPOLYLINE") (= (DXF 0 EN) "POLYLINE")) ; or ) ; and (progn (setq NO-ENT NIL)) ; progn (prompt MSG2) ) ; if ) ; while

EN ) ; get-en (defun GET-LWVLIST (EN / ELIST NUM-VERT VLIST) (setq ELIST (entget EN) NUM-VERT (cdr (assoc 90 ELIST)) ELIST (member (assoc 10 ELIST) ELIST) VLIST NIL ) ; setq (repeat NUM-VERT (setq VLIST (append VLIST (list (cdr (assoc 10 ELIST)))) ; append ) ; setq (setq ELIST (cdr ELIST) ELIST (member (assoc 10 ELIST) ELIST) ) ; setq ) ; repeat VLIST ) ; get-lwvlist (defun GET-PLVLIST (EN / VLIST) (setq VLIST NIL item en items (entget (entnext (dxf -1 item))) vlist1 (list (car (list (dxf 10 en)))) ;vLIST (append VLIST (list (DXF 10 EN))) EN (entnext EN) ) ; setq (while (/= "SEQEND" (DXF 0 EN)) (setq VLIST (append VLIST (list (DXF 10 EN)))) (setq EN (entnext EN)) ) ; while VLIST ) ; get-plvlist (defun WRITE-IT (VLST EN / NEWVLIST MSG3 FNAME) (setq NEWVLIST (mapcar '(lambda (X) (trans X EN 0)) ;_ lambda VLST ) ;_ mapcar MSG3 "Polyline vertex file" FNAME (getfiled MSG3 "" "txt" 1) F1 (open FNAME "w") ) ; setq (WRITE-HEADER) (WRITE-VERTICES NEWVLIST) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;(SETQ STR (STRCAT PTS (CHR 32)(RTOS (CAR (CAR ITEM)) 2 2)(CHR 32)"W"(CHR 32) ; (RTOS (CADR (CAR ITEM)) 2 2))) ;(write-line STR F1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq F1 (close F1)) ) ;_ write-it (defun WRITE-HEADER (/ STR) (setq STR "NEW PANE POS AT PIN1");_ strcat ;NEW PLOO ;HEI 1/2 ;SJUST BOTT (write-line STR F1) (setq STR (strcat "NEW PLOO") ;_ strcat

) ;_ setq (write-line STR F1) (setq STR (strcat "HEI 1/2") ;_ strcat ) ;_ setq (write-line STR F1) (setq STR (strcat "SJUST BOTT") ;_ strcat ) ;_ setq (write-line STR F1) ) ;_ write-header (defun WRITE-VERTICES (NEWVLIST / XSTR YSTR ZSTR STR) (foreach ITEM NEWVLIST (setq XSTR (rtos (nth 0 ITEM) 2 2) YSTR (rtos (nth 1 ITEM) 2 2) pts (strcat "NEW PAVE POS N") STR (strcat pts (CHR 32) XSTR (CHR 32)"W"(CHR 32) YSTR) ;_ strcat ) ; setq (write-line STR F1) ) ; foreach ) ; write-vertices (defun SPACES (STR / FIELD NUM CHAR SPACE) (setq FIELD 10 NUM (- FIELD (strlen STR)) CHAR " " SPACE "" ) ;_ setq (repeat NUM (setq SPACE (strcat SPACE CHAR))) ;_ repeat ) ;_ spaces (defun C:XPL2 () (SETTING) (VERTEXT) (RESETTING) (princ)) ; c:vtx (prompt "\nEnter XPL2 to start")

You might also like