Results 1 to 3 of 3

Thread: Small Modification Required, In Existing Lisp

  1. #1
    Member
    Join Date
    2016-01
    Posts
    46
    Login to Give a bone
    0

    Question Small Modification Required, In Existing Lisp

    Dear Masters,

    I have one Lisp, with help of my existing lisp generating notepad file. i need CSV file format instead of notepad as a shown image format.

    Kindly make a modification in my existing Lisp.
    Code:
    ;; gc:distinct (gilles chanteau)
    ;; Suprime tous les doublons d'une liste
    ;;
    ;; Argument
    ;; l : une liste
    (defun gc:distinct (l)
        (if l
            (cons (car l) (gc:distinct (vl-remove (car l) l)))
        )
    )
    (defun l-coor2l-pt (lst flag / )
        (if lst
            (cons
                (list
                    (car lst)
                    (cadr lst)
                    (if flag
                        (+ (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0) (caddr lst))
                        (if (vlax-property-available-p ename 'Elevation) (vlax-get ename 'Elevation) 0.0)
                    )
                )
                (l-coor2l-pt (if flag (cdddr lst) (cddr lst)) flag)
            )
        )
    )
    (defun c:ptdef2notepad ( / js dxf_cod mod_sel n lremov str_sep oldim ename l_pt l_pr pr l_x l_y tmp1 f_openx tmp2 f_openy)
      (princ "\nSelect model object for filtering: ")
      (while
        (null
          (setq js
            (ssget "_+.:E:S"
              (list
                '(0 . "*LINE,POINT,ARC,CIRCLE,ELLIPSE,INSERT")
                (cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
                (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
              )
            )
          )
        )
        (princ "\nIsn't an available object!")
      )
      (vl-load-com)
      (setq dxf_cod (entget (ssname js 0)))
      (foreach m (foreach n dxf_cod (if (not (member (car n) '(0 67 410 8 6 62 48 420 70))) (setq lremov (cons (car n) lremov))))
        (setq dxf_cod (vl-remove (assoc m dxf_cod) dxf_cod))
      )
      (initget "Single All Manual")
      (if (eq (setq mod_sel (getkword "\nSelect mode, [Single/All/Manual]<Manual>: ")) "Single")
        (setq n -1)
        (if (eq mod_sel "All")
            (setq js (ssget "_X" dxf_cod) n -1)
            (setq js (ssget dxf_cod) n -1)
        )
      )
      (setq
        str_sep " "  ;-> **** YOU CAN CHANGE THIS STRING BY WHAT YOU WONT ! **** <-
        oldim (getvar "dimzin")
      )
      (setvar "dimzin" 0)
      (repeat (sslength js)
        (setq ename (vlax-ename->vla-object (ssname js (setq n (1+ n)))))
        (setq l_pr (list 'StartPoint 'EndPoint 'Center 'InsertionPoint 'Coordinates 'FitPoints))
        (foreach pr l_pr
          (if (vlax-property-available-p ename pr)
            (setq l_pt
              (if (or (eq pr 'Coordinates) (eq pr 'FitPoints))
                (append
                  (if (eq (vla-get-ObjectName ename) "AcDbPolyline")
                    (l-coor2l-pt (vlax-get ename pr) nil)
                    (if (and (eq pr 'FitPoints) (zerop (vlax-get ename 'FitTolerance)))
                      (l-coor2l-pt (vlax-get ename 'ControlPoints) T)
                      (l-coor2l-pt (vlax-get ename pr) T)
                    )
                  )
                  l_pt
                )
                (append (l-coor2l-pt (vlax-get ename pr) T) l_pt)
              )
            )
          )
        )
      )
      (setq l_x (gc:distinct (mapcar '(lambda (x) (rtos (/ x 1.0) 2 2)) (vl-sort (mapcar 'car l_pt) '<))))  ;-> **** YOU CAN CHANGE UNIT AND PREC (rtos x unit prec) ! **** <-
      (setq l_y (gc:distinct (mapcar '(lambda (x) (rtos (/ x 1.0) 2 2)) (vl-sort (mapcar 'cadr l_pt) '<))))  ;-> **** YOU CAN CHANGE UNIT AND PREC (rtos x unit prec) ! **** <-
      (setq
        tmp1 (vl-filename-mktemp "tmp_x.csv")
        f_openx (open tmp1 "w")
      )
      (write-line (apply 'strcat (mapcar '(lambda (x) (strcat x str_sep)) l_x)) f_openx)
      (close f_openx)
      (startapp "notepad" tmp1)
      (setq
        tmp2 (vl-filename-mktemp "tmp_y.csv")
        f_openy (open tmp2 "w")
      )
      (write-line (apply 'strcat (mapcar '(lambda (x) (strcat x str_sep)) l_y)) f_openy)
      (close f_openy)
      (startapp "notepad" tmp2)
      (setvar "dimzin" oldim)
      (prin1)
    )
    Please find sample drawing and sample CSV Format.
    Thanking you,
    Best regards.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by prasadcivil; 2016-10-11 at 05:45 AM.

  2. #2
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Small Modification Required, In Existing Lisp

    use DATAEXTRACTION


    UNZIP POINTDATA , and use it at the DATAEXTRACTION
    Attached Files Attached Files
    Last edited by devitg.89838; 2016-10-11 at 12:10 AM. Reason: no one

  3. #3
    Member
    Join Date
    2016-01
    Posts
    46
    Login to Give a bone
    0

    Default Re: Small Modification Required, In Existing Lisp

    Quote Originally Posted by devitg.89838 View Post
    use DATAEXTRACTION


    UNZIP POINTDATA , and use it at the DATAEXTRACTION
    Dear sir,
    Thank you for your kind reply.i know about DATA EXTRACTION. but i am looking for lisp routine. and major draw back of DATA EXTRACTION coordinates are not sorted and repeated values ex:1200.00 is repeated twice @Position, X but i need not repeated and time taking process and developed un necessary symbols like " ' " these symbols are creating problems while calculation and pasting. with help of my example lisp my coordinates are developed as 0.00 600.00 1200.00 2200.00 for X coordinates sorted with space separator side by side and same as developed for Y coordinates sorting too.

    so now i need modification as below one under one coordinate instead of "side by side and space separator":

    0.00
    600.00
    1200.00
    2200.00

    and same as Y coordinates too. by CSV file as shown in Post#1 image. if not possible by CSV file format kindly modify for same notepad file format by example lisp with one under one coordinate value instead of "side by side and space separator".

    Thanking you,
    with best regards.
    Attached Images Attached Images
    Last edited by prasadcivil; 2016-10-11 at 06:06 AM.

Similar Threads

  1. select result lisp modification
    By chad.beussink in forum AutoLISP
    Replies: 10
    Last Post: 2023-10-24, 09:55 AM
  2. Replies: 4
    Last Post: 2009-01-31, 05:26 AM
  3. Modification to a LISP routine
    By cwjean76 in forum AutoLISP
    Replies: 2
    Last Post: 2008-05-19, 06:32 PM
  4. Brick Lisp modification requested
    By BCrouse in forum AutoLISP
    Replies: 0
    Last Post: 2008-04-17, 08:15 PM
  5. Co-Ordinate Lisp Required
    By rob.fryer in forum AutoLISP
    Replies: 3
    Last Post: 2006-08-09, 12:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •