Jump to content

Save the data as "SDR" and "GSI" not csv


Recommended Posts

Posted (edited)

Hello All,

 

Can you please help to edit this code to save the data as "SDR" and "GSI" not csv 

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

(defun c:EXP (/       *error* convert file    GetLayers       typs
               str     num     layers  lyr     3dpoly  fltr    head
               ss      no      sn      en      pt      ty      end
               dis     arcs    circles lines   points  blocks  splines
               stexts  mtexts  lst     lws     pls     rtn     sep
               nos
              )
  (defun *error* (msg)
    (if (and file (< 0 file))
      (unload_dialog file)
    )
    (if (and opn (= (type opn) 'FILE))
      (close opn)
    )
    (if (and msg
             (not (wcmatch (strcase msg) "*CANCEL*,*EXIT*,*BREAK*"))
        )
      (princ (strcat "\nError =>: " msg))
    )
    (princ)
  )
  ;;                ;;
  (defun convert (value)
    (if (= (type value) 'STR)
      value
      (rtos value 2 3)
    )
  )
  ;;                ;;
  (cond
    ; ((not (findfile "Data Extraction.dcl"))
     ; (alert
       ; "Dialog file < Data Extraction.dcl > was not found in search path !"
     ; )
    ; )
    ((not
       (and (setq file (load_dialog "Data Extraction")) (< 0 file))
     )
     (alert "Can't load Main file <!>")
    )
    ((not (new_dialog "tmp" file))
     (alert "Can't load dialog <!>")
    )
    (t
     (defun GetLayers (/ lay name lst)
       (while (setq lay (tblnext "LAYER" (not lay)))
         (or (wcmatch (setq name (cdr (assoc 2 lay))) "*|*")
             (setq lst (cons name lst))
         )
       )
       (acad_strlsort lst)
     )
     (setq typs '("arc"       "circle"    "line"      "spline"
                  "lwpolyline"            "point"     "insert"
                  "text"      "mtext"
                 )
     )
     (setq str ""
           num 0
     )
     (setq layers (GetLayers))
     (start_list "lay")
     (foreach layer layers (add_list layer))
     (end_list)
     (action_tile
       "bylay"
       "(mode_tile \"lay\" (if (= (get_tile \"bylay\") \"1\") 0 1))"
     )
     (action_tile
       "ok"
       "(setq lyr (if (= (get_tile \"bylay\") \"1\") (nth (atoi (get_tile \"lay\")) layers) \"*\"))
                          (foreach ky '(\"ar\" \"cr\" \"ln\" \"sp\" \"lw\" \"pt\" \"bk\" \"st\" \"mt\")
                            (if (= (get_tile ky) \"1\") (setq str (strcat str (strcase (nth num typs)) \",\")))
                            (setq num (1+ num)))
                          (if (= (get_tile \"pl\") \"1\") (setq 3dpoly t))
                          (if (or 3dpoly (/= str \"\")) (done_dialog)
                            (progn (setq str \"\" num 0 3dpoly nil) (alert \"Must check out one toggle at least to continue!\")))"
     )
     (action_tile
       "ex"
       "(setq str \"\" 3dpoly nil) (done_dialog)"
     )
     (start_dialog)
     (unload_dialog file)
    )
  )
  (if (or 3dpoly (/= str ""))
    (progn
      (cond ((and (/= str "") 3dpoly)
             (setq fltr (list '(-4 . "<OR")
                              (cons 0 str)
                              '(-4 . "<AND")
                              '(0 . "POLYLINE")
                              '(-4 . "&=")
                              '(70 . 8/)
                              '(-4 . "AND>")
                              '(-4 . "OR>")
                        )
             )
            )
            ((/= str "") (setq fltr (list (cons 0 str))))
            (3dpoly
             (setq fltr '((0 . "POLYLINE") (-4 . "&=") (70 . 8)))
            )
      )
      (setq head '("Point No."      "Easting"        "Northing"
                   "Elevations"     "Point Number (Into AutoCAD)"    "Object Type"
                  )
      )
    (setq non 0)
      (if (setq ss (ssget ))
        (repeat (setq no (sslength ss))
          (setq sn (ssname ss (setq no (1- no))))
          (setq en (entget sn))
          (setq pt (cdr (assoc 10 en)))
          (setq ty (cdr (assoc 0 en)))
          (setq rtn nil)
          (cond
            ((= ty "ARC")
             (setq pt  (vlax-curve-getstartpoint sn)
                   end (vlax-curve-getendpoint sn)
                   rtn (cons (list (car pt) (cadr pt) (caddr pt) ty) rtn)
                   rtn (cons (list (car end)
                                   (cadr end)
                                   (caddr end)
                                   ty
                                   ""
                                   (cdr (assoc 40 en))
                                   (vlax-curve-getarea sn)
                             )
                             rtn
                       )
             )
             (setq arcs (cons rtn arcs))
            )
            ((= ty "CIRCLE")
             (setq circles (cons (list (car pt)
                                       (cadr pt)
                                       (caddr pt)
                                       ty
                                       ""
                                       (cdr (assoc 40 en))
                                       (vlax-curve-getarea sn)
                                 )
                                 circles
                           )
             )
            )
            ((= ty "LINE")
             (setq end (cdr (assoc 11 en))
                   dis (distance pt end)
                   rtn (cons (list (car pt) (cadr pt) (caddr pt) ty) rtn)
                   rtn (cons (list (car pt) (cadr pt) (caddr pt) ty dis)
                             rtn
                       )
             )
             (setq lines (cons (reverse rtn) lines))
            )
            ((= ty "SPLINE")
             (foreach itm en
               (if (= (car itm) 11)
                 (setq pt  (cdr itm)
                       rtn (cons
                             (list (car pt) (cadr pt) (caddr pt) "Spline")
                             rtn
                           )
                 )
               )
             )
             (setq splines (cons rtn splines))
            )
            ((= ty "LWPOLYLINE")
             (foreach itm en
               (if (= (car itm) 10)
                 (setq pt  (cdr itm)
                       rtn (cons (list (car pt)
                                       (cadr pt)
                                       (cdr (assoc 38 en))
                                       "Polyline"
                                 )
                                 rtn
                           )
                 )
               )
             )
             (foreach itm (cdr rtn) (setq lst (cons itm lst)))
             (setq lws (cons
                         (reverse
                           (append
                             (list
                               (append (car rtn)
                                       (list (vlax-curve-getdistatparam
                                               sn
                                               (vlax-curve-getendparam sn)
                                             )
                                             ""
                                             (vlax-curve-getarea sn)
                                       )
                               )
                             )
                             lst
                           )
                         )
                         lws
                       )
                   lst nil
             )
            )
            ((= ty "POLYLINE")
             (while (/= "SEQEND" (cdr (assoc 0 (setq en (entget sn)))))
               (setq pt  (cdr (assoc 10 en))
                     rtn (cons
                           (list (car pt) (cadr pt) (cadr pt) "3dPolyline")
                           rtn
                         )
                     sn  (entnext sn)
               )
             )
             (setq pls (cdr (reverse rtn)))
            )
       ((= ty "POINT")
             (setq
               points (cons (list (car pt) (cadr pt) (caddr pt)(ITOA (setq non (1+ non))) ty)
                            points
                      )
             )
         (COMMAND "_.TEXT" (list (car pt) (cadr pt) (caddr pt) ) 0.2 "0" non)
            )
            ((= ty "INSERT")
             (setq blocks (cons (list (car pt)
                                      (cadr pt)
                                      (caddr pt)
                                      "BlockReference"
                                )
                                blocks
                          )
             )
            )
            ((= ty "TEXT")
             (setq
               stexts (cons (list (car pt) (cadr pt) (caddr pt) ty)
                            stexts
                      )
             )
            )
            ((= ty "MTEXT")
             (setq
               mtexts (cons (list (car pt) (cadr pt) (caddr pt) ty)
                            mtexts
                      )
             )
            )
          )
        )
      )
      (if (and (or arcs circles lines points blocks splines lws pls)
               (setq csv (getfiled "Specify name of the Excel file"
                                   (getvar 'DWGPREFIX)
                                   "csv"
                                   1
                         )
               )
               (setq opn (open csv "w"))
               (setq rtn ""
                     nos 0
                     sep (cond
                           ((vl-registry-read
                              "HKEY_CURRENT_USER\\Control Panel\\International"
                              "sList"
                            )
                           )
                           (",")
                         )
               )
          )
        (progn
          (foreach itm head
            (setq rtn (strcat rtn itm sep))
          )
          (write-line rtn opn)
          (setq rtn "")
          (if arcs
            (foreach itm arcs
              (foreach val (reverse itm)
                (foreach st val
                  (setq rtn (strcat rtn (convert st) sep))
                )
                (write-line
                  (strcat (itoa (setq nos (1+ nos))) sep rtn)
                  opn
                )
                (setq rtn "")
              )
            )
          )
          (if circles
            (foreach itm circles
              (foreach st itm (setq rtn (strcat rtn (convert st) sep)))
              (write-line
                (strcat (itoa (setq nos (1+ nos))) sep rtn)
                opn
              )
              (setq rtn "")
            )
          )
          (if lines
            (foreach itm lines
              (foreach val itm
                (foreach st val
                  (setq rtn (strcat rtn (convert st) sep))
                )
                (write-line
                  (strcat (itoa (setq nos (1+ nos))) sep rtn)
                  opn
                )
                (setq rtn "")
              )
            )
          )
          (if splines
            (foreach itm splines
              (foreach val itm
                (foreach st val
                  (setq rtn (strcat rtn (convert st) sep))
                )
                (write-line
                  (strcat (itoa (setq nos (1+ nos))) sep rtn)
                  opn
                )
                (setq rtn "")
              )
            )
          )
          (if lws
            (foreach itm lws
              (foreach val itm
                (foreach st val
                  (setq rtn (strcat rtn (convert st) sep))
                )
                (write-line
                  (strcat (itoa (setq nos (1+ nos))) sep rtn)
                  opn
                )
                (setq rtn "")
              )
            )
          )
          (if pls
            (foreach itm pls
              (foreach st itm (setq rtn (strcat rtn (convert st) sep)))
              (write-line
                (strcat (itoa (setq nos (1+ nos))) sep rtn)
                opn
              )
              (setq rtn "")
            )
          )
          (if points
            (foreach itm points
              (foreach st itm (setq rtn (strcat rtn (convert st) sep)))
              (write-line
                (strcat (itoa (setq nos (1+ nos))) sep rtn)
                opn
              )
              (setq rtn "")
            )
          )
          (if blocks
            (foreach itm blocks
              (foreach st itm (setq rtn (strcat rtn (convert st) sep)))
              (write-line
                (strcat (itoa (setq nos (1+ nos))) sep rtn)
                opn
              )
              (setq rtn "")
            )
          )
          (if stexts
            (foreach itm stexts
              (foreach st itm (setq rtn (strcat rtn (convert st) sep)))
              (write-line
                (strcat (itoa (setq nos (1+ nos))) sep rtn)
                opn
              )
              (setq rtn "")
            )
          )
          (if mtexts
            (foreach itm mtexts
              (foreach st itm (setq rtn (strcat rtn (convert st) sep)))
              (write-line
                (strcat (itoa (setq nos (1+ nos))) sep rtn)
                opn
              )
              (setq rtn "")
            )
          )
          (close opn)
        )
      )
    )
  )
  (princ)
)
(vl-load-com)

 

Edited by SLW210
Added Code Tags
Posted

SDR is Sokkia and GSI is Leica ??

 

Your question is a big ask. Contact the relevant Survey instrument company for help.

 

I am ex Topcon.

Posted (edited)
4 hours ago, BIGAL said:

SDR is Sokkia and GSI is Leica ??

 

Your question is a big ask. Contact the relevant Survey instrument company for help.

 

I am ex Topcon.

Yes for sokkia and leica

 

I know is a big ask, but I'm sure their lots of geniuses here can edit it.

Edited by Kalsefar
Posted

My first thought is that since the data points are just really a list of numbers, why not use a spreadsheet like Excel to do the conversion? Spreadsheets are great at manipulate numbers, CAD is great at drawing lines. For  example, google gave me this: http://www.engineeringsurveyor.com/utilities/#Excel - part way down there is CSV2GSI converter. I don't do surveying but this might be a way to go?

  • SLW210 changed the title to Save the data as "SDR" and "GSI" not csv
Posted

I changed the thread title and added code tags. Please use relevant thread titles.

  • Like 2
Posted

Nice response Steven P most survey  instruments will accept a csv file.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...