+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Aug 2009
    Posts
    14

    Default Help with Polyline Lisp (Export All Lengths to Table)

    Registered forum members do not see this ad.

    Hello, I am searching for a lisp that can export the lengths of all selected polylines and export them to either Excel or an AutoCad table.

    I have found and tested around 20 lisps but so far cannot find the right one.
    There were only 2 that look promising, maybe they could be modified?
    One was by Lee Mac and the other Jimmy Bergmark. I can post the 2 Lisp if needed.

    The lisp would need to have you select multiple polylines and give the total lengths of each polyline in the order that they were selected in. Then the data would either appear on an AutoCad table or Excel.

    Thanks for any help that can be provided.

  2. #2
    Super Member Commandobill's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Raleigh, NC
    Posts
    538

    Default

    The lengths of each individual polyline or the total length?
    ***Commandobill***
    Abusing AutoCad Since 1999
    "Caddatude... Do you has it?"
    Sorry for my poor English, I'm American...

  3. #3
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Aug 2009
    Posts
    14

    Default

    Quote Originally Posted by Commandobill View Post
    The lengths of each individual polyline or the total length?
    The lengths of each individual polyline.
    Total is really not needed or can be added at the end of the table or excel if it is not to much trouble.

  4. #4
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,050

    Default

    Try this program to export LWpolylines to Excel file with format csv.

    Code:
    (defun c:Test (/ s f o)
      ;; Tharwat 26. 08. 2015 ;
      (princ "\nSelect LWpolylines to export to Excel file :")
      (if (and (setq s (ssget '((0 . "LWPOLYLINE"))))
               (setq f (getfiled "Specify File Name" (getvar 'DWGPREFIX) "csv" 1))
               (setq o (open f "w"))
               )
        (progn
          ((lambda (r / e)
             (while (setq e (ssname s (setq r (1+ r))))
               (write-line (rtos (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2 4) o)
               ))
            -1)
          (close o)
          )
        )           
      (princ)
    )

  5. #5
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Aug 2009
    Posts
    14

    Default

    Quote Originally Posted by Tharwat View Post
    Try this program to export LWpolylines to Excel file with format csv.
    Looks good so far. I do have a few tweaks if possible.
    Is there a way to have the values show up in feet only?
    Is there a also a way to have it load up excel without having to save location first and then open?

  6. #6
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,050

    Default

    Quote Originally Posted by gordon_Gjs View Post
    Is there a way to have the values show up in feet only?
    Is there a also a way to have it load up excel without having to save location first and then open?
    Add the complete path of the Excel file and be aware that each time you run the program , the new data would replace the old once .

    Code:
    (defun c:Test (/ s f o)
      ;; Tharwat 26. 08. 2015 ;
      (princ "\nSelect LWpolylines to export to Excel file :")
      (if (and (setq s (ssget '((0 . "LWPOLYLINE"))))
               (setq f "C:\\New Folder\\Example.csv") ;; path of Excel path
               (setq o (open f "w"))
               )
        (progn
          ((lambda (r / e)
             (while (setq e (ssname s (setq r (1+ r))))
              (write-line (rtos (cvunit (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) "mm" "feet") 2 4) o)
               ))
            -1)
          (close o)
          )
        )           
      (princ)
    )
    Last edited by Tharwat; 28th Aug 2015 at 07:55 pm.

  7. #7
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Aug 2009
    Posts
    14

    Default

    Quote Originally Posted by Tharwat View Post
    Add the complete path of the Excel file and be aware that each time you run the program , the new data would replace the old once .
    I could only get it to save to my thumb drive. It would not save to the local drive C:. Any idea of why this would be? Maybe trust issues? Does it have to save at all or can it just open excel?
    Also, could you have the values show up in feet?

    Thanks for all your help!

  8. #8
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,050

    Default

    Quote Originally Posted by gordon_Gjs View Post
    I could only get it to save to my thumb drive. It would not save to the local drive C:. Any idea of why this would be? Maybe trust issues? Does it have to save at all or can it just open excel?
    Yeah , it might be a matte of security issue , anyway right click on the folder that you wan to safe the excel file in , then go to properties then from the show up dialog go to security tab and edit the group / user name to have a full access.

    Quote Originally Posted by gordon_Gjs View Post
    Also, could you have the values show up in feet?
    If the program did not change the value to feet format from the latest posted program , and replace the number 3 to 4 and try again.

  9. #9
    Junior Member
    Using
    AutoCAD 2010
    Join Date
    Aug 2009
    Posts
    14

    Default

    Quote Originally Posted by Tharwat View Post
    Yeah , it might be a matte of security issue , anyway right click on the folder that you wan to safe the excel file in , then go to properties then from the show up dialog go to security tab and edit the group / user name to have a full access.

    If the program did not change the value to feet format from the latest posted program , and replace the number 3 to 4 and try again.
    It is still not showing up in feet. Do you have any other ideas to get it to feet?

  10. #10
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,050

    Default

    Registered forum members do not see this ad.

    I updated the codes above , try it and let me know .

Similar Threads

  1. Pline lengths organized in a table
    By Caderious Jackson in forum AutoCAD LT
    Replies: 3
    Last Post: 12th Mar 2015, 01:47 pm
  2. Export table to PDF using lisp
    By rodrigo_sjc_sp in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 28th Jan 2014, 03:53 pm
  3. Export table using lisp, keeping style, and block cells
    By rodrigo_sjc_sp in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 22nd Jan 2014, 10:21 pm
  4. lisp to export the handles and the x, y coordinates for a polyline
    By tiny_21_2003 in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 12th Jul 2013, 02:38 pm
  5. Polyline lengths
    By happyunited in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 23rd Jan 2007, 11:06 am

Tags for this Thread

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