Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me count these polylines....Please!

Status
Not open for further replies.

MattMason

Technical User
Jan 21, 2004
4
US
Hi Guys. Found this forum about a week ago and this is my first post :). I have a drawing I’m working on that contains loads of polylines…..Kinda like a wiring schematic. All these polylines can be broken down into three groups. Each group is a different color, linetype, and on its own layer.

My question is….I would like to be able to determine the total length for each group of polyline. Can anybody suggest an easy way to do this? I’m hoping that there is a simple way that I am simply overlooking, but I’m tired of beating my head on the keyboard finding it. Any help provided is greatly appreciated.

Thanks,
Matt
 
Maybe this routine will help:

Code:
;| TOTLEN.LSP    c.2000  Rob Herr    robherr@hotmail.com
 'Add selected lines, plines, lwplines, splines, and arcs for total length'

 Revisions:
1.0		Originally created			02/10/2000 Rob Herr
  ___________________________________________________________________
  |     PERMISSION HEREBY GRANTED BLA, BLA, BLA, TO MODIFY ETC.     |
  |   As long as name and email remain with the original program    |
  | unaltered. However I would like to know of any bugs or problems |
  |   that arise with the actual program. And of course I take no   |
  |  responsibility for lost limbs, auto repair bills, mechanical   |
  |         or electronic difficulties, or snake venom.             |
  -------------------------------------------------------------------

------------------------------------------------------------------------
 Modified by J. Tippit, SPAUG President
    E-mail:                     cadpres@spaug.org
    Web Site:                [URL unfurl="true"]http://www.spaug.org[/URL]
------------------------------------------------------------------------

|;

(defun tlines ()
  (setq lbeg (cdr (assoc '10 ent)))
  (setq lend (cdr (assoc '11 ent)))
  (setq llen (distance lbeg lend))
  (setq tlen (+ tlen llen))
  (ssdel sn ss1)
)

(defun tarcs ()
  (setq cen (cdr (assoc '10 ent)))
  (setq rad (cdr (assoc '40 ent)))
  (setq dia (* rad 2.0))
  (setq circ (* (* rad pi) 2.0))
  (setq sang (cdr (assoc '50 ent)))
  (setq eang (cdr (assoc '51 ent)))
  (if (< eang sang)
    (setq eang (+ eang (* pi 2.0)))
  )
  (setq tang (- eang sang))
  (setq tang2 (* (/ tang pi) 180.0))
  (setq circ2 (/ tang2 360.0))
  (setq alen (* circ2 circ))
  (setq tlen (+ tlen alen))
  (princ)
  (ssdel sn ss1)
)

(defun tplines ()
  (command &quot;area&quot; &quot;e&quot; sn)
  (setq tlen (+ tlen (getvar &quot;perimeter&quot;)))
  (ssdel sn ss1)
)

(defun tsplines	()
  (command &quot;area&quot; &quot;e&quot; sn)
  (setq tlen (+ tlen (getvar &quot;perimeter&quot;)))
  (ssdel sn ss1)
)

(DEFUN C:TOTLEN	(/ tlen ss1 sn sn2 et)
  (setq cmdecho (getvar &quot;cmdecho&quot;))
  (setvar &quot;cmdecho&quot; 0)
  (setq tlen 0)
  (prompt
    &quot;\nSelect only those entities you want for total length: &quot;
  )
  (setq ss1 (ssget))
  (while (> (sslength ss1) 0)
    (setq sn (ssname ss1 0))
    (setq ent (entget sn))
    (setq et (cdr (assoc '0 ent)))
    (cond
      ((= et &quot;LINE&quot;) (tlines))
      ((= et &quot;ARC&quot;) (tarcs))
      ((= et &quot;LWPOLYLINE&quot;) (tplines))
      ((= et &quot;POLYLINE&quot;) (tplines))
      ((= et &quot;SPLINE&quot;) (tsplines))
      ((or
	 (/= et &quot;LINE&quot;)
	 (/= et &quot;ARC&quot;)
	 (/= et &quot;LWPOLYLINE&quot;)
	 (/= et &quot;POLYLINE&quot;)
	 (/= et &quot;SPLINE&quot;)
       )
       (ssdel sn ss1)
      )
    )
  )
  (alert
    (strcat
      &quot;The Total Length of Selected Lines, Polylines, and Arcs is: &quot;
      &quot;\n\n&quot;
      &quot;Arch\t->\t&quot;
      (rtos tlen 4 6)
      &quot;\n\n&quot;
      &quot;Decimal\t->\t&quot;
      (rtos tlen 2 8)
    )
  )
  (prompt
    (strcat
      &quot;\nThe Total Length of Selected Lines, Polylines, and Arcs is: &quot;
      &quot;\n&quot;
      &quot;Arch\t\t->\t&quot;
      (rtos tlen 4 6)
      &quot;\t\t\t&quot;
      &quot;Decimal\t->\t&quot;
      (rtos tlen 2 8)
    )
  )
					; (alert (strcat &quot;\nThe Total Length of Selected Lines, Polylines, and Arcs is: &quot; (rtos tlen 2 2)))
  (setvar &quot;cmdecho&quot; cmdecho)
  (princ)
)
(prompt &quot;\nBy Rob Herr   robherr@hotmail.com  &quot;)
(prompt
  &quot;\nType TOTLEN to run.\tVersion 1.1 - Total Length routine &quot;
)
(princ)

Flores
 
Thank You!!!!!!
That was absolutely what I needed. I am convinced that this is a great forum. And I now owe newbiewonkinobie my first unborn child
 
I'm glad I was able to help. You can also thank those who do not compile there code and make it unreadable/uneditable so the rest of us can learn from them.

Flores
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top