+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 20 of 20
  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
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,588

    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
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,588

    Default

    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

  6. #16
    Forum Newbie
    Discipline
    Civil
    Sabarinathan's Discipline Details
    Occupation
    Quantity surveyor (Quantity take off only)
    Discipline
    Civil
    Details
    Quantity surveyor (Quantity take off only) Using AutoCAD and civil 3d
    Using
    AutoCAD 2016
    Join Date
    May 2018
    Location
    I am in Chennai, tamilnadu in India.
    Posts
    3

    Default

    Hi, i have the following code


    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)

    This code is used to extract the polyline length in autocad table.
    I want to additionally add layers and polyline length in meter.
    How can i add that please give some ideas...
    Last edited by SLW210; 4th Jun 2018 at 01:36 pm. Reason: Added Code Tags

  7. #17
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,588

    Default

    Not to hard look for matching lines in code above in most cases its add to the number an extra 1.

    Code:
    (setq numcolumns 3)
    ............
    (vla-setcolumnwidth objtable 2 25)
    .......
    (vla-settext objtable 1 2 "Layer") 
    ........
    (vla-settext objtable Y 1 (rtos (vla-get-length e) 2 3))
    (vla-settext objtable Y 2 (vla-get-layer e) )
    A man who never made mistakes never made anything

  8. #18
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    711

    Default

    Quote Originally Posted by Sabarinathan View Post
    Hi, i have the following 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
    hi welcome, friendly msg , the code should be included in code tags

    before
    [CODE]your code here[/CODE]

    after
    Code:
    your code here
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  9. #19
    Forum Newbie
    Discipline
    Civil
    Sabarinathan's Discipline Details
    Occupation
    Quantity surveyor (Quantity take off only)
    Discipline
    Civil
    Details
    Quantity surveyor (Quantity take off only) Using AutoCAD and civil 3d
    Using
    AutoCAD 2016
    Join Date
    May 2018
    Location
    I am in Chennai, tamilnadu in India.
    Posts
    3

    Default

    Hi Bigal

    Thank you for your quick reply & its worked awsome...
    Once again thank you so much...

  10. #20
    Forum Newbie
    Discipline
    Civil
    Sabarinathan's Discipline Details
    Occupation
    Quantity surveyor (Quantity take off only)
    Discipline
    Civil
    Details
    Quantity surveyor (Quantity take off only) Using AutoCAD and civil 3d
    Using
    AutoCAD 2016
    Join Date
    May 2018
    Location
    I am in Chennai, tamilnadu in India.
    Posts
    3

    Default

    Registered forum members do not see this ad.

    Next time i will do correctly...

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