My case is that I need to check the validity of shapes in .shx-files. My first thought was to insert them into a drawing with the "shape" -command but it might not be the best way.
What I'm asking is:
Why I'm asking is because we use some special linetypes and there is a fear that some of the shx-files have faulty definitions. Atm I am not aware of a method of doing this efficiently.
I was thinking of doing this
I'm open to other suggestions and all help is appreciated 😃
- F
http://cadpanacea.com/_misc/downloads/fndshape.zip
This nice little lisp is probably half the answer.
;; ------------------------------------------------------------------
;; FNDSHAPE.LSP Copyright 2006 R.K. McSwain all rights reserved
;;
;; Author: R.K. McSwain
;;
;; Initial Release [27 FEB 2005]
;;
;; Feel free to copy, and modify as desired, just
;; retain this header and append as necessary.
;;
;;
;; ------------------------------------------------------------------
(defun c:fndshape
(/ ENT
LT OUTPUT
SHPNST ST
FN FP
I INS
ITEM LTENT
LTNAME LTOBJ
OBJ OSTR
REF SHAPENM
SHAPENO
SHPN STENT
STNAME STOBJ
TMP
)
(vl-load-com)
(setq output '())
; Step 1 - Find complex linetypes that reference a SHAPE
(while (setq lt (tblnext "ltype" (not lt)))
(setq ltname (cdr (assoc 2 lt)))
(setq ltObj (tblobjname "ltype" ltname))
(setq ltEnt (entget ltObj))
(setq i 0)
(while (< i (length ltEnt))
(setq item (nth i ltEnt))
(if (and
(eq (car item) 74)
(eq (cdr item) 4)
)
(progn
(setq shapeno (itoa (cdr (nth (1+ i) ltEnt))))
(setq
shapenm (cdr (assoc 3 (entget (cdr (nth (+ i 2) ltEnt)))))
)
(setq ostr
(strcat "LINETYPE [" ltname
"] uses SHAPE # ["
shapeno "] in the file ["
shapenm "]"
)
)
(setq output (cons ostr output)
i 10000
)
)
)
(setq i (1+ i))
)
)
; Step 2 - Find loaded SHAPE FILES
(while (setq st (tblnext "style" (not st)))
(setq stname (cdr (assoc 2 st)))
(setq stObj (tblobjname "style" stname))
(setq stEnt (entget stObj))
(if (eq 1 (logand (cdr (assoc 70 stEnt)) 1))
(setq ostr
(strcat "The following SHAPE FILE is loaded: ["
(vl-princ-to-string (cdr (assoc 3 st)))
"]"
)
output (cons ostr output)
)
)
(setq i (1+ i))
)
; Step 3 - Find inserted SHAPES
(setq tmp (ssget "X" '((0 . "SHAPE"))))
(if tmp
(progn
(setq i 0)
(while (< i (sslength tmp))
(setq obj (ssname tmp i))
(setq ent (entget obj))
(setq shpn (cdr (assoc 2 ent)))
(if (not shpn)
(setq shpnST "An unknown shape ")
(setq shpnST (strcat "SHAPE named " shpn "] "))
)
(setq ins (cdr (assoc 10 ent)))
(setq ref (cdr (assoc 2 (entget (cdr (assoc 330 ent))))))
(setq ostr (strcat shpnST
"is INSERTED in "
ref
" at "
(vl-princ-to-string ins)
)
)
(setq output (cons ostr output))
(setq i (1+ i))
)
)
)
(if output
(progn
(setq output (reverse output))
(setq fn (strcat (getenv "temp") "\\fndshape.txt"))
(setq fp (open fn "w"))
(foreach item output
(write-line item fp)
)
(close fp)
(startapp "notepad" fn)
)
(alert "Nothing found")
)
(princ)
)
(princ "\n Type FNDSHAPE to run...")
(princ)
Pretty sure have to find but there is a shx ->shp its old and not to be confused with Esri shp files.
shp to shx is in Express.
Good morning [at least where I am it's morning 😃 ]!
The tool @Sea-Haven is talking about is dumpshx.exe* and can be found in eg. C:\Program Files\Autodesk\AutoCAD 2020\Express. It is run as an independent tool.
In my original post I was aware that I talked about "shapes" when I actually meant shapes compiled in autocad (.shx). If I would be able to get my .shx files to .shp how would I go on to inspect all the shapes in a neat and tidy way?
*Sidenote: Imho it is not clearly documented or then the information I need is really well hidden. I have tried to use it before but it has never succeeded and only crashed.
You can run dumpshx from within autocad using "shell"
(command "shell" "c:\\program files\\........\\dumpshx c:\\myfiles\\Custom.shx >c:\\myfiles\\dumpshx.txt")
note the \\ needed for lisp.
You can open the text file created c:\myfiles\dumpshx.txt and read it line by line not sure if it helps.
Can't find what you're looking for? Ask the community or share your knowledge.