+ Reply to Thread
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 46
  1. #1
    Full Member
    Computer Details
    elfert's Computer Details
    Operating System:
    Windows XP
    Discipline
    Mechanical
    elfert's Discipline Details
    Occupation
    AutoCAD Supporter
    Discipline
    Mechanical
    Details
    AutoCAD Support of AutoCAD mechanical and AutoCAD 2011
    Using
    AutoCAD 2011
    Join Date
    Nov 2011
    Location
    Denmark, Esbjerg
    Posts
    63

    Default The never ending story: Polyline export to file

    Registered forum members do not see this ad.

    Hello Lisp forum!

    Can you help i found this thread:

    http://www.cadtutor.net/forum/showth...-Export-Points

    I need a lisp routine thats could export polylines to a file called infile and it should look the same as the attached one. the file should be placed in the folder C:\user\ and if the routines can't find the folder it should create it.

    Many many many thx in advance.
    Attached Files
    - Still a Novice Lisp programmer, but trying to learn....

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,102

    Default

    consider this:

    LOGFILEON
    LOGFILENAME
    LOGFILEPATH
    LOGFILEOFF
    QAFLAGS 2 [for a long list]

    command: list

    See what hapens

  3. #3
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Quote Originally Posted by elfert View Post
    Hello Lisp forum!

    the file should be placed in the folder C:\user\ and if the routines can't find the folder it should create it.
    Just a hint, sorry
    I had similar problem earlier on my machine
    Make sure you have user permissions to
    this folder "C:\user\" before
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  4. #4
    Full Member
    Computer Details
    elfert's Computer Details
    Operating System:
    Windows XP
    Discipline
    Mechanical
    elfert's Discipline Details
    Occupation
    AutoCAD Supporter
    Discipline
    Mechanical
    Details
    AutoCAD Support of AutoCAD mechanical and AutoCAD 2011
    Using
    AutoCAD 2011
    Join Date
    Nov 2011
    Location
    Denmark, Esbjerg
    Posts
    63

    Default

    Quote Originally Posted by fixo View Post
    Just a hint, sorry
    I had similar problem earlier on my machine
    Make sure you have user permissions to
    this folder "C:\user\" before
    Okay but i am not sure where to start changing the lisp routine ? I found this made by mfuccaro, thx mfuccaro. But i need it to make the file in C:\user\ and it should make the file similar to the one attached with the same filename. This about logname, logfilename ect. i am not sure how to use that? The problem is that we today use a VBA to do it but we change to 64 bit OS and AC and in the future VBA is not supported by AC. So thats why i need a lisp routine to be in a language that ac whould understand in the future. thx in advance.

    Code:
    ;export old style polyline vertex coords to a text file
    ;	mfuccaro@hotmail.com
    (defun c:pl2txt ( / en ask i a file)
      (while (not ask)
        (setq en (car (entsel)))
        (if en (setq ask (= "LWPOLYLINE" (cdr (assoc 0 (entget en))))))
        )
      (setq file (open (getfiled "Output file"
    			     (strcat (getvar "dwgprefix")
    			     (substr (getvar "DWGNAME") 1 (- (strlen (getvar "dwgname")) 4)))
    			     "txt"     ;file type
    			     1) "w"))
      (setq i 0 sep ";")	;sep=separator
      (while (or (zerop i) a)
        (setq a (mapcar 'rtos (cdr (assoc 10 (entget (setq en (entnext en)))))))
        (if a (write-line (strcat (car a) sep (cadr a) sep (caddr a)) file))
        (setq i (1+ i))
        )
      (close file)
      (princ (strcat "\n" (itoa (1- i)) " points exported"))
      (princ)
      )
    - Still a Novice Lisp programmer, but trying to learn....

  5. #5
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,102

    Default

    Quote Originally Posted by elfert View Post
    This about logname, logfilename ect. i am not sure how to use that?
    [/CODE]
    Dont worry about it effert, i'm just showing you the lazy way of exporting data. I'm in that mode now

    In any case .. Oleg got you covered.

  6. #6
    Full Member
    Computer Details
    elfert's Computer Details
    Operating System:
    Windows XP
    Discipline
    Mechanical
    elfert's Discipline Details
    Occupation
    AutoCAD Supporter
    Discipline
    Mechanical
    Details
    AutoCAD Support of AutoCAD mechanical and AutoCAD 2011
    Using
    AutoCAD 2011
    Join Date
    Nov 2011
    Location
    Denmark, Esbjerg
    Posts
    63

    Default How retrive the Z-coordinates and folder check.

    I found the code at afralisp and i want to retrive the z-coordinates but i can't make it do it correct can some body help , Please? Is it possible to make the file go in to the C:\user\ folder as it is now i always end up in the 'My document'. I the folder dosn't exist the will be okay report back to the user.

    http://www.afralisp.net/visual-lisp/...nes-part-1.php

    Code:
    (prompt "\nType \"vlplexport\" to run........")
    (defun c:vlplexport ( / theobj thelist n xval yval zval fname fn)
    ;load the visual lisp extensions
    (vl-load-com)
    ;get the entity and entity name
    (setq theobj (car (entsel "\nSelect a Polyline: ")))
    ;convert to vl object
    (setq theobj (vlax-ename->vla-object theobj))
    ;check if it's a polyline
    (if (= (vlax-get-property theobj 'ObjectName) "AcDbPolyline")
    ;if it is, do the following
    (progn
    ;retrieve the coordinates
    (setq thelist (vlax-get-property theobj 'coordinates))
    ;convert to a list
    (setq thelist (vlax-safearray->list  (variant-value thelist)))
    ;zero the counter
    (setq n 0)
    ;create a text file
    (setq fname "infile")
    ;open it to write
    (setq fn (open fname "w"))
    ;write the header
    (write-line "PolyLine X, Y and Z Coordinates" fn)
    ;underline the header
    (write-line "*****************************************" fn)
    ;start the loop
    (repeat (/ (length thelist) 3)
    ;get the x coordinate
    (setq xval (rtos (nth n thelist)))
    ;increase the counter
    (setq n (1+ n))
    ;get the y coordinate
    (setq yval (rtos (nth n thelist)))
    ;increase the counter
    (setq n (1+ n))
    ;get the z coordinate
    (setq zval (rtos (nth n thelist)))
    ;write the x coordinate to the file
    (write-line  (strcat "X-Value : " xval)  fn)
    ;write the y coordinate to the file
    (write-line  (strcat "Y-Value : " yval)  fn)
    ;write the z coordinate to the file
    (write-line  (strcat "z-Value : " zval)  fn)
    ;add a seperator
    (write-line "-----------------------------" fn)
    ;increase the counter
    (setq n (1+ n))
    );repeat
    ;close the file
    (close fn)
    );progn
    ;it's not a polyline, inform the user
    (alert "This is not a Polyline! - Please try again.")
    );if
    (princ)
    );defun
    ;------------------------
    ;clean loading
    (princ)
    ;---------------------------
    ;End of VL-POLY.LSP
    ;---------------------------
    Many txh in advance.
    - Still a Novice Lisp programmer, but trying to learn....

  7. #7
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    See these functions in the Help file:
    Code:
    ;check if folder exist
    (if (not (vl-file-directory-p "c:/User"))
      (progn
        (alert "Does not exist. Create one...")
        (vl-mkdir "c:/User")
      ;check again, who knows?
        (if (vl-file-directory-p "c:/User")
          (progn
     (alert "Now it was created. Go to write your data")
     ;;write data here
     (progn
       (alert "Exist. You can write your data")
       ;;write data here
     )
          )
        )
      )
    )

    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  8. #8
    Full Member
    Computer Details
    elfert's Computer Details
    Operating System:
    Windows XP
    Discipline
    Mechanical
    elfert's Discipline Details
    Occupation
    AutoCAD Supporter
    Discipline
    Mechanical
    Details
    AutoCAD Support of AutoCAD mechanical and AutoCAD 2011
    Using
    AutoCAD 2011
    Join Date
    Nov 2011
    Location
    Denmark, Esbjerg
    Posts
    63

    Default thx fixo

    Quote Originally Posted by fixo View Post
    See these functions in the Help file:
    Code:
    ;check if folder exist
    (if (not (vl-file-directory-p "c:/User"))
      (progn
        (alert "Does not exist. Create one...")
        (vl-mkdir "c:/User")
      ;check again, who knows?
        (if (vl-file-directory-p "c:/User")
          (progn
     (alert "Now it was created. Go to write your data")
     ;;write data here
     (progn
       (alert "Exist. You can write your data")
       ;;write data here
     )
          )
        )
      )
    )
    ~'J'~
    Thx. Fixo for that
    - Still a Novice Lisp programmer, but trying to learn....

  9. #9
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    You're welcome
    Cheers

    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  10. #10
    Full Member
    Computer Details
    elfert's Computer Details
    Operating System:
    Windows XP
    Discipline
    Mechanical
    elfert's Discipline Details
    Occupation
    AutoCAD Supporter
    Discipline
    Mechanical
    Details
    AutoCAD Support of AutoCAD mechanical and AutoCAD 2011
    Using
    AutoCAD 2011
    Join Date
    Nov 2011
    Location
    Denmark, Esbjerg
    Posts
    63

    Default

    Registered forum members do not see this ad.

    But i am still strugling to get the Z-coordinates correct txh in advance
    - Still a Novice Lisp programmer, but trying to learn....

Similar Threads

  1. Multiple polyline export challenge
    By yorke67 in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 22nd Dec 2011, 07:23 am
  2. select all closed polyline and export to excel file and mark
    By ectech in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 20th Dec 2009, 03:12 pm
  3. Export Bearings & Distances, Lat & Lon on 3D polyline
    By mtl2195 in forum Civil 3D & LDD
    Replies: 1
    Last Post: 15th Dec 2009, 02:45 am
  4. Replies: 2
    Last Post: 27th Apr 2007, 08:54 am
  5. export polyline areas to a spreadsheet
    By stycz in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 24th Oct 2005, 06:14 am

Bookmarks

Posting Permissions

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