Results 1 to 6 of 6

Thread: Total Pline Length Tracked in Dwg with Fields?

  1. #1
    Member
    Join Date
    2009-12
    Posts
    4
    Login to Give a bone
    0

    Default Total Pline Length Tracked in Dwg with Fields?

    Is there a way (fields ?) to track the total length of plines drawn in a drawing? The drawings I create have many plines in them and constantly are changing. I currently use a lisp routine (found in forum) to calculate total length of plines on certain layers when drawing is complete. I would like to poulate a space in the title block (ie: drawn by, date, footage, etc.) with the footage (total length of plines) of the sheet and hope by using a field it would update if plines in drawing changed length.

    Thanks in advance for any help...

  2. #2
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Total Pline Length Tracked in Dwg with Fields?

    Here's one based on a similar area program I wrote here.

    Code:
    ;;--------------------=={ Length Field }==--------------------;;
    ;;                                                            ;;
    ;;  Creates an MText Field referencing the sum of the lengths ;;
    ;;  of selected objects.                                      ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    
    (defun c:LenField ( / acdoc acspc format pt ss )
    
      (setq format "%lu6%qf1") ;; Field Formatting
    
      (setq acdoc (vla-get-activedocument (vlax-get-acad-object))
            acspc (vlax-get-property acdoc (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace))
      )  
      (if
        (and
          (ssget '((0 . "LINE,*POLYLINE")))
          (setq pt (getpoint "\nPick Point for Field: "))
        )
        (
          (lambda ( ss fld )
            (vlax-for obj ss
              (setq fld
                (strcat fld "%<\\AcObjProp Object(%<\\_ObjId "
                  (LM:GetObjectID acdoc obj) ">%).Length>% + "
                )
              )
            )
            (vla-addMText acspc (vlax-3D-point (trans pt 1 0)) 0.
              (setq fld
                (strcat
                  (substr fld 1
                    (- (strlen fld) (if (< 1 (vla-get-Count ss)) 3 5))
                  )
                  " \\f \"" format "\">%"
                )
              )
            )
            (vla-delete ss)
          )
          (setq ss (vla-get-ActiveSelectionSet acdoc))
          (if (< 1 (vla-get-Count ss)) "%<\\AcExpr " "")
        )
      )
      (princ)
    )
    
    ;;-------------------=={ Get ObjectID }==---------------------;;
    ;;                                                            ;;
    ;;  Returns the ObjectID string for the supplied VLA-Object   ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    ;;  Arguments:                                                ;;
    ;;  doc - VLA Document Object (req'd for 64-bit systems)      ;;
    ;;  obj - VLA Object to query                                 ;;
    ;;------------------------------------------------------------;;
    ;;  Returns:  ObjectID string for VLA-Object                  ;;
    ;;------------------------------------------------------------;;
    
    (defun LM:GetObjectID ( doc obj )
      (if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
        (vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
        (itoa (vla-get-Objectid obj))
      )
    )

  3. #3
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,810
    Login to Give a bone
    0

    Default Re: Total Pline Length Tracked in Dwg with Fields?

    Quote Originally Posted by dwknutson View Post
    Is there a way (fields ?) to track the total length of plines drawn in a drawing? The drawings I create have many plines in them and constantly are changing.
    Use the ._DataExtraction command and output a table in the drawing with a sum row. The table will update when polylines are edited, added, or deleted (use the ._DataLinkUpdate command)
    R.K. McSwain | CAD Panacea |

  4. #4
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: Total Pline Length Tracked in Dwg with Fields?

    Quote Originally Posted by rkmcswain View Post
    Use the ._DataExtraction command and output a table in the drawing with a sum row. The table will update when polylines are edited, added, or deleted (use the ._DataLinkUpdate command)
    That's a much better solution

  5. #5
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,810
    Login to Give a bone
    0

    Default Re: Total Pline Length Tracked in Dwg with Fields?

    Quote Originally Posted by Lee Mac View Post
    That's a much better solution
    I don't know about "better", but it's another way...
    R.K. McSwain | CAD Panacea |

  6. #6
    Member
    Join Date
    2017-08
    Posts
    2
    Login to Give a bone
    0

    Default Re: Total Pline Length Tracked in Dwg with Fields?

    Hi lee
    there is anyway to control conversion factor by dimlfac?

Similar Threads

  1. Replies: 9
    Last Post: 2015-05-03, 07:12 PM
  2. DIM Pline by total length?
    By cadtag in forum AutoLISP
    Replies: 1
    Last Post: 2014-08-04, 04:25 PM
  3. add and total lines/pline
    By CADiver in forum AutoLISP
    Replies: 10
    Last Post: 2012-01-18, 07:07 PM
  4. Multiple Pline selection area total
    By aaronlogan in forum AutoCAD General
    Replies: 6
    Last Post: 2006-07-13, 06:14 PM
  5. Replies: 2
    Last Post: 2005-01-03, 02:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •