Jump to content

About SHAPES names


lido

Recommended Posts

Hello everyone!
After loading a SHX shape file with vla-loadshapefile function, I would like to know the names of shapes available (defined) in the file.
Does anyone know how to proceed?

 

Thanks in advance.

 

Link to comment
Share on other sites

@BIGAL Thank you for your answer.

The SHX file is at the client. I  do not have acces to it!

My program should read the data in the SHX file (defined shape names) and integrate the shape chosen by the user into the definition of a complex line.

Link to comment
Share on other sites

In the absence of a better solution, please accept this one which I propose. Any comments are welcome.

;;Read shape names defined inside a SHX file
;;lido 22.01.2121
(defun shpnames (SHX_file / $line EXE_file INN_file OPN_file OUT_file SHP_list TMP_file)
  (cond
    ( (not (setq INN_file (findfile SHX_file)))       (alert (strcat SHX_file " file not found.")))
    ( (not (setq EXE_file (findfile "dumpshx.exe")))  (alert "dumpshx.exe file not found."))
    ( T
      (setq OUT_file (vl-filename-mktemp (strcat (vl-filename-base SHX_file) ".SHP")))
      (if (> (startapp (strcat EXE_file " -o " OUT_file " " INN_file)) 2)
        (progn
          (while (< (vl-file-size OUT_file) 1)) ;;Delay, do not delete!
          (setq OPN_file (open OUT_file "r"))
          (while (setq $line (read-line OPN_file))
            (if (= (substr $line 1 1) "*")
              (setq SHP_list (cons (substr $line (- (strlen $line) (vl-position 44 (reverse (vl-string->list $line))) -1)) SHP_list))
            )
          )
          (close OPN_file)
          (if (setq TMP_file (findfile (strcat (vl-filename-directory OUT_file) "\\" (vl-filename-base OUT_file) ".TMP"))) (vl-file-delete TMP_file)) ;;Dumpshx.exe Version 1.3  make this file
          (while (findfile OUT_file) (vl-file-delete OUT_file)) ;;An other delay, do not delete!
        )
      )
    )
  )
  (vl-sort SHP_list (function (lambda (a b) (< a b))))
) ;;shpnames
(vl-load-com)

 

  • Thanks 1
Link to comment
Share on other sites

37 minutes ago, lido said:

In the absence of a better solution, please accept this one which I propose. Any comments are welcome.

 

Handy function. Added to my collection.

Link to comment
Share on other sites

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...