ptexport problem

Discussion of other Lisp dialects (Arc, Clojure, AutoLisp, XLISP, etc.)
Post Reply
laverdasfc
Posts: 1
Joined: Sun Feb 19, 2012 12:08 pm

ptexport problem

Post by laverdasfc » Sun Feb 19, 2012 12:41 pm

Dear lisp-professionals! I have the following problem:
I'd like to use ptexport.lsp to export the coordinates of polylines (water distribution system nodes) from my acad file and it works, but there is no blank row between the coordinates of each polylines so I can't identify them (I can't separate the polylines from each other).
Could you tell me how I can manage to get the txt with blank rows between coordinate-groups polylines, please? Thank you very much!

The code of ptexport.lsp is the following:

Code: Select all

(defun c:ptexport ()
  (setq sset (ssget '((-4 . "<OR")(0 . "POINT")
                      (0 . "LWPOLYLINE")(-4 . "OR>"))))
  (if sset
    (progn
      (setq itm 0 num (sslength sset))
      (setq fn (getfiled "Point Export File" "" "txt" 1))
      (if (/= fn nil)
        (progn
          (setq fh (open fn "w"))
          (while (< itm num)
            (setq hnd (ssname sset itm))
            (setq ent (entget hnd))
            (setq obj (cdr (assoc 0 ent)))
            (cond
              ((= obj "POINT")
                (setq pnt (cdr (assoc 10 ent)))
                (princ (strcat (rtos (car pnt) 2 8) ","
                               (rtos (cadr pnt) 2 8) ","
                               (rtos (caddr pnt) 2 8)) fh)
                (princ "\n" fh)
              )
              ((= obj "LWPOLYLINE")
                (if (= (cdr (assoc 38 ent)) nil)
                  (setq elv 0.0)
                  (setq elv (cdr (assoc 38 ent)))
                )
                (foreach rec ent
                  (if (= (car rec) 10)
                    (progn
                      (setq pnt (cdr rec))
                      (princ (strcat (rtos (car pnt) 2 8) ","
                                     (rtos (cadr pnt) 2 8) ","
                                     (rtos elv 2 8)) fh)
                      (princ "\n" fh)
                    )
                  )
                )
              )
              (t nil)
            )
            (setq itm (1+ itm))
          )
          (close fh)
        )
      )
    )
  )
  (princ)
)

(princ "\nPoint Export loaded, type PTEXPORT to run.")
(princ)

Post Reply