+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Luminous Being StykFacE's Avatar
    Computer Details
    StykFacE's Computer Details
    Operating System:
    Windows 7 Ultimate 64bit
    Computer:
    Dell Precision T3500
    Discipline
    Multi-disciplinary
    StykFacE's Discipline Details
    Occupation
    BIM Manager & Design Specialist
    Discipline
    Multi-disciplinary
    Details
    Facilities engineering, involving mechanical piping, mechanical HVAC and electrical engineering.
    Using
    Revit 2013
    Join Date
    Mar 2006
    Location
    Dallas, TX - USA
    Posts
    6,483

    Question Lisp to add & total every line/pline on a layer??

    Registered forum members do not see this ad.

    Hey everyone, I have seen Lisp routines before where you can select multiple lines and/or plines and it will add up the total length. Tried doing a search on here but I guess I'm not having any luck.... can anyone point to one? Thanks in advance. If not, no worries, just thought of something that might be of interest to our estimators here in the office....
    Tannar Frampton | Facilities Engineering | Revit 2013
    Personal Projects | Fender Squier Stratocaster | Custom Smoker | Concrete Patio

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro 4000, 2GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,023

    Default

    Scroll down to Measurement and Dimensiong. It's called elen.lsp.

    http://www.asmitools.com/Files/Programs.html

    Thanks to ASMI!
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

  3. #3
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,925
    R12 (Dos) - A2K

  4. #4
    Super Member mdbdesign's Avatar
    Computer Details
    mdbdesign's Computer Details
    Operating System:
    XP PRO
    Computer:
    Homemade
    Motherboard:
    GIGABYTE G31M-ES2L
    CPU:
    INTEL CORE 2-QUAD-Q6600@2.4GHz
    RAM:
    4 GB
    Graphics:
    NVIDIA GeForce 9800 gt 1gb
    Primary Storage:
    WESTERN DIGITAL 500GB
    Monitor:
    2 - 21" COMPACQ
    Discipline
    Mechanical
    mdbdesign's Discipline Details
    Occupation
    Designing Engineer in Engineering Department
    Discipline
    Mechanical
    Details
    Pressure tanks Oil processing & storage equip. Steel mill equip. Telecom towers & equip. Wind turbine towers Power plant structures etc.
    Using
    AutoCAD 2012
    Join Date
    Jan 2007
    Location
    Courtice, Ontario, Canada
    Posts
    749

    Default

    Or this...
    Attached Files

  5. #5
    Senior Member Commandobill's Avatar
    Using
    AutoCAD 2008
    Join Date
    Oct 2008
    Location
    Massachusetts
    Posts
    268

    Default

    or this one extracts them to excel

    Code:
    (defun c:ple (/    layer layer_list leng row ss sumlen total xlApp xlCells)
      (vl-load-com)
      (if (setq ss (ssget "_X" (list (cons 0 "*POLYLINE"))))
        (progn
          (setq    xlApp (vlax-get-or-create-object "Excel.Application")
            xlCells       (vlax-get-property
                     (vlax-get-property
                       (vlax-get-property
                     (vlax-invoke-method
                       (vlax-get-property xlApp "Workbooks")
                       "Add")
                     "Sheets")
                       "Item" 1)
                     "Cells"))
          
          (vla-put-visible xlApp :vlax-true)
          (vlax-put-property xlCells "Item" 1 1 "Layer")
          (vlax-put-property xlCells "Item" 1 2 "Length")
          (setq row 2
            total 0)      
          (mapcar '(lambda (z)
             (if (not (member z layer_list))
               (setq layer_list (append (list z) layer_list))))
              (mapcar '(lambda (z) (cdr (assoc 8 (entget z)))) (mapcar 'cadr (ssnamex ss))))
          (repeat (length layer_list)
        (setq layer (car layer_list))
        (setq ss (ssget "_X" (list (cons 0 "*POLYLINE")(cons 8 layer))) sumlen 0)
        (mapcar '(lambda (z) (setq sumlen (+ sumlen (vla-get-length (vlax-ename->vla-object (cadr z)))))) (ssnamex ss))
        (vlax-put-property xlCells "Item" row 1 layer)
        (vlax-put-property xlCells "Item" row 2 (rtos sumlen 2 3))
        (setq total (+ total sumlen))
        (setq layer_list (cdr layer_list))
        (setq row (+ row 1))
        )
          (setq row (+ row 1))
          (vlax-put-property xlCells "Item" row 1 "Total:")
          (vlax-put-property xlCells "Item" row 2 (rtos total 2 3))
          
          (vlax-release-object xlApp)
          (alert "Close Excel file manually")
          (gc)(gc)
          (princ)
          ) (alert "There are no Polylines on your drawing!"))
      )
    ***Commandobill***
    Abusing AutoCad Since 1999
    "Caddatude... Do you has it?"
    Sorry for my poor English, I'm American...

  6. #6
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    5,985

    Default

    This is in desperate need of an update, but I've just been too lazy and don't use it much, but since everyone is posting theirs, I just thought I'd be part of the gang.

    TotalLength.gif
    Last edited by alanjt; 3rd Jun 2010 at 01:58 pm.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  7. #7
    Senior Member stevesfr's Avatar
    Computer Details
    stevesfr's Computer Details
    Operating System:
    Vista <ugh>
    Computer:
    HP Pavilion
    Monitor:
    Dell Trinitron
    Using
    AutoCAD 2008
    Join Date
    Jan 2009
    Location
    Central Illinois, USA
    Posts
    270

    Default

    Quote Originally Posted by alanjt View Post
    This is in desperate need of an update, but I've just been too lazy and don't use it much, but since everyone is posting theirs, I just thought I'd be part of the gang.

    Attachment 15580
    Some day please update and include "circle" please !
    (why not from before?)
    S

  8. #8
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    5,985

    Default

    Quote Originally Posted by stevesfr View Post
    Some day please update and include "circle" please !
    (why not from before?)
    S
    I guess it's something you can use.
    I think I'll sit down and do an update tonight, after the baby goes to sleep, and I'll def. add circle.

    Because I'm retarded. I needed it badly a while back, wrote it, used it a few times and haven't really touched it. A buddy of mine uses it all the time for As-Built surveys.

    I'll at least add circles and fix the units tonight.
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  9. #9
    Forum Newbie
    Discipline
    Electrical
    Using
    AutoCAD 2010
    Join Date
    Mar 2012
    Posts
    2

    Default

    Hi guys, i have code thats similar to this but i have a few problems with it.

    The problem is that it calculates the lenghths of ALL polylines in the drawing.
    I would like it if it only calculated the lengths of the polylines from my selection and send the totals to excel by layer.

    The code i have currently looks like this:
    Code:
    (defun c:ple (/ elist  en   i    layer    layer_list
      leng  pline   row    ss     sumlen   total
      x  xlApp   xlBook   xlBooks  xlCells  xlSheet
      xlSheets
            )
      (vl-load-com)
      (setq xlApp    (vlax-get-or-create-object "Excel.Application")
     xlBooks  (vlax-get-property xlApp "Workbooks")
     xlBook    (vlax-invoke-method xlBooks "Add")
     xlSheets (vlax-get-property xlBook "Sheets")
     xlSheet    (vlax-get-property xlSheets "Item" 1)
     xlCells    (vlax-get-property xlSheet "Cells")
      ) 
      (vla-put-visible xlApp :vlax-true)
      ;headers
      (vlax-put-property xlCells "Item" 1 1 "Layer")
      (vlax-put-property xlCells "Item" 1 2 "Length")
      
      (setq row 2
     total 0)
      (setq ss (ssget "_X" (list (cons 0 "*POLYLINE"))) i -1)
      (repeat (sslength ss)
        (setq en (ssname ss (setq i (1+ i)))
       elist (entget en)
       layer (cdr (assoc 8 elist)))
        (if (not (member layer layer_list))
          (setq layer_list (cons layer layer_list))))
      
      
      (repeat (length layer_list)
        (setq layer (car layer_list))
        (vlax-put-property xlCells "Item" row 1 layer)
        (setq ss (ssget "_X" (list (cons 0 "*POLYLINE")(cons 8 layer))) i -1 sumlen 0)
        (repeat (sslength ss)
        (setq row (1+ row))  
        (setq pline (vlax-ename->vla-object (ssname ss (setq i (1+ i)))))
        (setq leng  (vlax-curve-getdistatparam pline
        (vlax-curve-getendparam pline)))
        (vlax-put-property xlCells "Item" row 2 (rtos leng 2 3))
        ;;;    (vlax-put-property xlCells "Item" row 2 (rtos leng 2 3)); for metric units  
        (setq sumlen (+ sumlen leng)))
        (setq row (1+ row))
        (vlax-put-property xlCells "Item" row 1 "SubTotal:")
        (vlax-put-property xlCells "Item" row 2 (rtos sumlen 2 3))
        (setq total (+ total sumlen))
    ;;;    (vlax-put-property xlCells "Item" row 2 (rtos sumlen 2 3)); for metric units
        (setq layer_list (cdr layer_list))
        (setq row (+ row 2))
        
      ) 
    ; footers:
    (vlax-put-property xlCells "Item" row 1 "Total:")
    (vlax-put-property xlCells "Item" row 2 (rtos total 2 3))
    ;;;(vlax-put-property xlCells "Item" row 2 (rtos total 2 3)); for metric units  
    (mapcar (function (lambda(x)
          (vl-catch-all-apply
            (function (lambda()
          (progn
            (vlax-release-object x)
            (setq x nil)))))))
    (list xlCells xlSheet xlSheets xlBook xlBooks xlApp)
    )
    (alert "Close Excel file manually")
    (gc)(gc)
    (princ)
      )
    (princ "\t\t***\t  Type PLE to write polines length to Excel\t***")
    (princ)


    Quote Originally Posted by Commandobill View Post
    or this one extracts them to excel

    Code:
    (defun c:ple (/    layer layer_list leng row ss sumlen total xlApp xlCells)
      (vl-load-com)
      (if (setq ss (ssget "_X" (list (cons 0 "*POLYLINE"))))
        (progn
          (setq    xlApp (vlax-get-or-create-object "Excel.Application")
            xlCells       (vlax-get-property
                     (vlax-get-property
                       (vlax-get-property
                     (vlax-invoke-method
                       (vlax-get-property xlApp "Workbooks")
                       "Add")
                     "Sheets")
                       "Item" 1)
                     "Cells"))
          
          (vla-put-visible xlApp :vlax-true)
          (vlax-put-property xlCells "Item" 1 1 "Layer")
          (vlax-put-property xlCells "Item" 1 2 "Length")
          (setq row 2
            total 0)      
          (mapcar '(lambda (z)
             (if (not (member z layer_list))
               (setq layer_list (append (list z) layer_list))))
              (mapcar '(lambda (z) (cdr (assoc 8 (entget z)))) (mapcar 'cadr (ssnamex ss))))
          (repeat (length layer_list)
        (setq layer (car layer_list))
        (setq ss (ssget "_X" (list (cons 0 "*POLYLINE")(cons 8 layer))) sumlen 0)
        (mapcar '(lambda (z) (setq sumlen (+ sumlen (vla-get-length (vlax-ename->vla-object (cadr z)))))) (ssnamex ss))
        (vlax-put-property xlCells "Item" row 1 layer)
        (vlax-put-property xlCells "Item" row 2 (rtos sumlen 2 3))
        (setq total (+ total sumlen))
        (setq layer_list (cdr layer_list))
        (setq row (+ row 1))
        )
          (setq row (+ row 1))
          (vlax-put-property xlCells "Item" row 1 "Total:")
          (vlax-put-property xlCells "Item" row 2 (rtos total 2 3))
          
          (vlax-release-object xlApp)
          (alert "Close Excel file manually")
          (gc)(gc)
          (princ)
          ) (alert "There are no Polylines on your drawing!"))
      )

  10. #10
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,780

    Default

    Registered forum members do not see this ad.

    My 5 cents worth

    Total Length.JPG
    A man who never made mistakes never made anything

Similar Threads

  1. lisp to put text with pline leangth above line
    By chelsea1307 in forum AutoLISP, Visual LISP & DCL
    Replies: 32
    Last Post: 12th Nov 2012, 12:35 pm
  2. Need a code lisp sum the length of line, pline, arc..
    By Nad SK in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 4th Dec 2008, 08:53 am
  3. How to count total layer on drawing
    By sibinh in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 11th Apr 2007, 09:21 am
  4. lisp for total line lengths
    By happyunited in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 27th Mar 2007, 03:31 pm
  5. total line lengths by layer
    By Mark Thomas in forum Tutorials & Tips'n'Tricks
    Replies: 0
    Last Post: 13th May 2004, 05:01 pm

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