See the top rated post in this thread. Click here

Results 1 to 3 of 3

Thread: Help with LISP file in ProgeCAD

  1. #1
    Login to Give a bone
    0

    Default Help with LISP file in ProgeCAD

    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'
    Last edited by Opie; 2023-02-13 at 02:29 PM. Reason: [code] tags added

  2. #2
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Help with LISP file in ProgeCAD

    For me for the xml to be generated under Autocad, I had to modify the cgdata function to this.
    Code:
    (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
    And for your problem, I thought of replacing at line 49

    Code:
    (vl-string-trim ", " xy)
    by

    Code:
    (substr xy 1 (- (strlen xy) 2))
    Another form of writing for the same result. See if that solves the problem for you.

  3. #3
    Login to Give a bone
    1

    Default Re: Help with LISP file in ProgeCAD

    I tried, it's not working.
    But I solved it another way with help from another forum. The problem was with vlax-get obj 'coordinates. It appears that progecad does not know that.
    Thanks for your time.

Similar Threads

  1. Need a help in modification of lisp. Please update the lisp code as required.
    By brahmanandam.thadikonda762224 in forum AutoLISP
    Replies: 0
    Last Post: 2018-09-20, 04:12 AM
  2. Help with autolisp (2 lisp programs in one lisp execution)
    By javier-perez1956746375 in forum AutoLISP
    Replies: 1
    Last Post: 2017-06-15, 07:40 PM
  3. NEED HELP WITH LISP ROUTINE - PURGE linetype lisp
    By ECASAOL350033 in forum AutoLISP
    Replies: 6
    Last Post: 2013-06-21, 01:13 AM
  4. LISP Debug Broken - Need Lisp to VBA Convert Help
    By bsardeson in forum VBA/COM Interop
    Replies: 4
    Last Post: 2010-10-06, 05:37 PM
  5. Replies: 1
    Last Post: 2007-03-26, 08:14 AM

Posting Permissions

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