Length of a Polyline

Discussion in 'AutoCAD' started by Jeff Clark, Jan 10, 2005.

  1. Jeff Clark

    Jeff Clark Guest

    Does anyone have a subroutine for extracting the total length of a polyline
    you would be willing to share with me?
    I'm trying to get together a group of Quantity Take-off routines.....

    Thanks
    --
    Jeffrey A. Clark
    Project Designer
    Consulting Engineer Services
    856/228-2200
     
    Jeff Clark, Jan 10, 2005
    #1
  2. Jeff Clark

    Jeff Clark Guest

    Excellent! Thanks Gary.

     
    Jeff Clark, Jan 10, 2005
    #2
  3. Jeff Clark

    Jeff Mishler Guest

    Gary, instead of posting copyrighted material you should post a link to
    where it can be downloaded. The web page that came from has some disclaimers
    that users really need to know about and agree to.

    Jurg has spent considerable time and effort to post all of the routines on
    his site. It would be one thing if he actually posted his routines here, but
    he always posts a link back to his website. So let's not undermine his
    wishes and maybe he will continue to post additional high quality functions.

    Thanks,
     
    Jeff Mishler, Jan 10, 2005
    #3
  4. Jeff Clark

    GaryDF Guest

    Good point, my bad.

    Gary

     
    GaryDF, Jan 10, 2005
    #4
  5. Jeff Clark

    AnneBrown Guest

    Copyright file removed and copying the answer on why removed.
    ---
    Anne Brown
    Discussion Groups Administrator
    Autodesk, Inc.

    Subject:
    Re: Length of a Polyline
    Date:
    Mon, 10 Jan 2005 11:09:53 -0800
    From:
    "Jeff Mishler" <>
    Organization:
    TDG Engineers
    Newsgroups:
    autodesk.autocad.customization

    Gary, instead of posting copyrighted material you should post a link to
    where it can be downloaded. The web page that came from has some disclaimers
    that users really need to know about and agree to.

    Jurg has spent considerable time and effort to post all of the routines on
    his site. It would be one thing if he actually posted his routines here, but
    he always posts a link back to his website. So let's not undermine his
    wishes and maybe he will continue to post additional high quality functions.

    Thanks,
    --
    Jeff
    check out www.cadvault.com


    This works great...

    Gary

    ;;;Juerg Menzi
    ;;;MENZI ENGINEERING GmbH, Switzerland
    ;;;http://www.menziengineering.ch
     
    AnneBrown, Jan 10, 2005
    #5
  6. Jeff Clark

    ECCAD Guest

    (defun get_length_objects ()
    (setvar "highlight" 1)
    (prompt "\nPick Objects for Length Calculations:")
    (setq SS (ssget))
    ); function
    (defun do_individual_lengths ()
    (setvar "cmdecho" 0)
    (setq SS nil)
    (get_length_objects); Select individual lengths
    (if SS
    (progn
    (setq NUM 0)
    (setq LENGX (SSLENGTH SS))
    (repeat LENGX
    (setq TOTAL 0 AVE 0 COUNT 1)
    (setq C (ssname SS NUM))
    (setq D (entget C))
    (setq E (cdr (assoc -1 D)))
    (get_obj_len C) ; obtain object's length
    (if (/= obj_len 0)
    (progn
    (calc_lengths obj_len)
    (setq TOTAL U_len)
    (*********** do what you need with U_len here*******)
    ); progn
    ); if
    (setq NUM (+ NUM 1))
    ); repeat
    ); progn
    ); if
    (princ)
    ); end function

    (defun calc_lengths ( x_length )
    (setq U_len 0 U_len_S " FT" LN 0 FEET 0 YARDS 0 INCHS 0 METERS 0 MILES 0 KMETERS 0)
    (setq LN x_length)
    (if (and (= ADJ_LEN 1)(/= LEN_FT nil)(/= LEN_FT 0.0)); Adjustment in Feet
    (setq LN (+ LN LEN_FT)); +/- if input is -xx
    ); if
    (if (> LN 0)
    (progn
    (setq FEET LN
    YARDS (/ FEET 3.0)
    INCHS (* FEET 12.0)
    METERS (/ INCHS 39.36)
    MILES (/ FEET 5280.0)
    KMETERS (/ METERS 1000.0)
    ); setq
    ); progn
    ); if
    ); defun
    (defun get_obj_len ( ss_ent )
    (setq obj_len 0 oname nil)
    (setq obj (vlax-ename->vla-object ss_ent))
    (setq oname (vlax-get obj 'ObjectName))
    (cond
    ( (= "AcDbPolyline" oname)
    (command "_area" "O" E)
    (setq obj_len (getvar "Perimeter"))
    )
    ( (= "AcDbCircle" oname)
    (setq obj_len (vlax-get obj 'Circumference))
    )
    ( (= "AcDbLine" oname)
    (setq obj_len (vlax-get obj 'Length))
    )
    ( (= "AcDbArc" oname)
    (setq obj_len (vlax-get obj 'ArcLength))
    )
    ( (= "AcDbEllipse" oname)
    (command "_area" "O" E)
    (setq obj_len (getvar "Perimeter"))
    )
    ); cond
    (if obj (vlax-release-object obj))
    (princ)
    ); function
    (defun C:run ()
    (do_individual_lengths)
    (princ)
    ); end function
     
    ECCAD, Jan 10, 2005
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.