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

    Default

    Registered forum members do not see this ad.

    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 .

    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)) "inch" "feet") 2 4) o)
               ))
            -1)
          (close o)
          )
        )           
      (princ)
    )
    Awww, ok. That is much better, I had to change the "mm" to "inch" and that cleared it up.
    One more thing, is there a way to have it open the excel file automatically without having it save anywhere? Or possibly export the data into an autocad table instead of excel?

  2. #12
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,720

    Default

    Here is a table version, works for me as metric may need mods for inches re row sizes etc. Will only work in modelspace see curspace.

    Tharwat stuffed up lambda please help any other suggestions welcome.

    Code:
    (defun c:Test (/ s x y doc objtable numrows rowheight pt1 colwidth curspace)
    ;; Tharwat 26. 08. 2015 ;
    ;; mods by BIGAL 29.08.2015 now as table
    
    (vl-load-com)
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (setq curspace (vla-get-modelspace doc))
    (setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table:  "))) 
    (princ "\nSelect LWpolylines to export to a Table :")
    (setq s (ssget '((0 . "LWPOLYLINE"))))
    (if (/= s nil)
        (progn
      ; now do table 
        (setq numrows (+ 2 (sslength s)))
        (setq numcolumns 2)
        (setq rowheight 7)
        (setq colwidth 25)
        (setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))
        (vla-settext objtable 0 0 "Pline lengths")
        (vla-setcolumnwidth objtable 0 10)
        (vla-setcolumnwidth objtable 1 25)
        (vla-settext objtable 1 0 "Pline") 
        (vla-settext objtable 1 1 "Length") 
        (vla-SetTextHeight Objtable (+ acDataRow acHeaderRow acTitleRow) 2.5)
        (vla-SetAlignment Objtable acDataRow acMiddleCenter)
    
        (setq x 1)
        (SETQ Y 2)
        (setq r -1)
        ;((lambda (r / e)
             (while (setq e (vlax-ename->vla-object(ssname s (setq r (1+ r)))))
             (vla-settext objtable Y 0 (rtos x 2 0))        
             (vla-settext objtable Y 1 (rtos (cvunit (vla-get-length e) "inch" "feet") 2 4))
             (setq x (1+ x ))
             (setq y (1+ Y ))
    	 ); while
         ; )) ;lambda
          )   ;progn
        (alert "You have not picked any plines run again")
        )     ; if      
      (princ)
    
    ) ; defun
    (c:test)
    A man who never made mistakes never made anything

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

    Default

    Quote Originally Posted by BIGAL View Post
    Here is a table version, works for me as metric may need mods for inches re row sizes etc. Will only work in modelspace see curspace.

    Tharwat stuffed up lambda please help any other suggestions welcome.
    Thanks, it worked great! Thanks Tharwat and BIGAL.

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

    Default

    Quote Originally Posted by BIGAL View Post
    Here is a table version, works for me as metric may need mods for inches re row sizes etc. Will only work in modelspace see curspace.

    Tharwat stuffed up lambda please help any other suggestions welcome.

    BIGAL, I was testing the lisp and came across 3 issues. If you have time can you check them out below?

    1.) When the lisp loads it wants to run immediately. Is there a way to have it only run when you enter the command for it?

    2.) Is there a way to change the format of the table to have zero precision and show the length in feet. Example = 42'

    3.) Is there a way to edit the text font and size the table uses?

  5. #15
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,720

    Default

    Registered forum members do not see this ad.

    1 remove last line (c:test)
    2 rtos ... 2 0
    3 vla-SetTextHeight ..... 2.5 change this & rowheight 7. mm settings
    A man who never made mistakes never made anything

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