Jump to content

Help with Polyline Lisp (Export All Lengths to Table)


gordon_Gjs

Recommended Posts

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.

 

so far I cannot find the right one.

 

The lisp would need to have you select multiple polylines and give the total lengths of each polyline with auto labeling in the order that they were selected in. Then the data would either appear on an AutoCad table or Excel with autolabel number, Layer name and Length.

Link to comment
Share on other sites

  • 1 month later...

hi, was looking for this lisp routine. made some tweaks to match my requirement.

1. added additional column to get area of polyline 

2. changed units from imperial to metric. i was working on a drawing in millimeters. and i wanted the length output to be in meters and area in sq meters. edited the cvunit thing in the code for that.

 

thank you all, i am completely beginner in this. and this thread was a great help

test area length.lsp

 

additionally, is there a way to add one more column with some sort of identifier for the polylines?

Edited by Farsin
Link to comment
Share on other sites

  • 1 year later...
On 5/31/2018 at 2:31 PM, BIGAL said:

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

 

 

(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) )
 

 

Hi, Bigal
I would like to add a polyline coordinate for X, Y, and Z.
Would it be possible to add a polyline coordinate?

 

Link to comment
Share on other sites

Need more info a pline has multiple xyz co-ords not sure what you want need to dummy up an example.

Edited by BIGAL
Link to comment
Share on other sites

  • 2 years later...
On 8/29/2015 at 8:47 AM, BIGAL said:

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.

 

 

(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)
 

 

Dear Bigal, 
Can you add a column show the layer names of the polyline, please?
Phuc Le

Link to comment
Share on other sites

Sorry Bigal

I found your instructions and it worked, thank you very much !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...