
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I found a Lisp here in the forum and I can not edit it, lisp works as follows, it exports the X, Y, Z coordinates of a Polyline and transforms it into a .txt file, except I do not want it to export the polyline , but rather a clickable place of instead of selecting the polyne to be the coordinate of the point that I clicked, Ex: I clicked at any point it generates the XYZ coordinates of the point that I clicked.
;..........................
(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 (eval 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
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 F1 (close F1))
) ;_ write-it
(defun WRITE-HEADER (/ STR)
(setq STR " POLYLINE VERTEX POINTS")
(write-line STR F1)
(setq STR (strcat " X " " Y " " Z") ;_ 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 4)
YSTR (rtos (nth 1 ITEM) 2 4)
ZSTR (rtos (nth 2 ITEM) 2 4)
STR (strcat XSTR (SPACES XSTR) YSTR (SPACES YSTR) ZSTR) ;_ strcat
) ;_ setq
(write-line STR F1)
) ;_ foreach
) ;_ write-vertices
(defun SPACES (STR / FIELD NUM CHAR SPACE)
(setq FIELD 15
NUM (- FIELD (strlen STR))
CHAR " "
SPACE ""
) ;_ setq
(repeat NUM (setq SPACE (strcat SPACE CHAR))) ;_ repeat
) ;_ spaces
(defun C:VTX ()
(SETTING)
(VERTEXT)
(RESETTING)
(princ)
) ;_ c:vtx
(prompt "\nEnter VTX to start")
Solved! Go to Solution.