For transferring data to a cadastre application, I use a LISP that extracts data from a DWG to an XML. It works with AutoCAD but it does not work with ProgeCAD: it generates identical XML files but lacking coordinates of poligons. Can anyone help me modify the lisp so it will work with ProgeCAD? I think that the vlax-get Obj 'coordinates could be the problem so maybe getting the coordinates by another method would work in ProgeCAD too. I am no LISP programmer, only user.
Many thanks!
Here is a comparison image:
comparison.jpg
Here is the LISP:
Code:
(vl-load-com) ; initialization
(defun c:cgdata (/ xml file)
(setq fname (getstring "\nNume fisier (ex: filename.xml):"))
(setq file (open fname "w"))
(write-line "<?xml version="1.0" encoding="ANSI"?>" file)
(write-line "<CADDATA>" file)
(cgpoly)
(cgtext)
(write-line "</CADDATA>" file)
(close file)
(startapp "notepad.exe" fname)
(princ "--->>>The file "")
(princ fname)
(princ "" has been created.<<<----")
(princ "\nGeotop, (2018)")
(print)
) ;_ end of defun
(defun cgpoly (/ lst ss i en obj)
(and (setq ss (ssget "X"
'((0 . "LWPOLYLINE") ; object Name
(-4 . "&=") ; bit coded
(70 . 1) ; polyline is closed
)
)
)
(repeat (setq i (sslength ss))
(setq en (ssname ss (setq i (1- i)))
obj (vlax-ename->vla-object en)
)
(write-line "<LWPOLYGON>" file)
(write-line (strcat "<LAYER>" (vlax-get obj 'Layer) "</LAYER>") file)
(write-line (strcat "<HANDLE>" (vlax-get obj 'Handle) "</HANDLE>") file)
(write-line (strcat "<AREA>" (rtos (vlax-get obj 'Area) 2 4) "</AREA>") file)
;----
(setq lst (vlax-get obj 'Coordinates) idx -1 xy "")
(repeat (/ (length lst) 2)
(setq xy (strcat xy (rtos (nth (+ 2 idx) lst) 2 3) " " (rtos (nth (1+ idx) lst) 2 3) ", "))
(setq idx (+ 2 idx))
)
(write-line (strcat "<LOCATION>POLYGON((" (vl-string-trim ", " xy) "))</LOCATION>") file)
;----
(write-line "</LWPOLYGON>" file)
)
)
) ;_ end of defun 'cgpoly'
(defun cgtext (/ lst ss i en obj)
(and (setq ss (ssget "_X" '((0 . "TEXT,MTEXT"))))
(repeat (setq i (sslength ss))
(setq en (ssname ss (setq i (1- i)))
obj (vlax-ename->vla-object en)
)
(write-line "<TEXT>" file)
(write-line (strcat "<LAYER>" (vlax-get obj 'Layer) "</LAYER>") file)
(write-line (strcat "<HANDLE>" (vlax-get obj 'Handle) "</HANDLE>") file)
(write-line (strcat "<VALUE>" (vlax-get obj 'textstring) "</VALUE>") file)
;----
(setq lst (vlax-get obj 'insertionpoint) idx -1 xy "")
(write-line (strcat "<LOCATION>POINT(" (rtos (nth (+ 2 idx) lst) 2 3) " " (rtos (nth (1+ idx) lst) 2 3) ")</LOCATION>") file)
;----
(write-line "</TEXT>" file)
)
)
) ;_ end of defun 'cgtext'