18
Jun
(defun c:sum_len (/)
  (princ
    "\nSelect Lines and Arcs: "
  )
  (setq	ausw (ssget (list (cons -4 ""))))
  (setq ind 0)
  (setq glg 0)

  (if (/= ausw nil)
    (progn
      (repeat (sslength ausw)
	(princ ".")
	(setq elem (entget (ssname ausw ind)))
	(setq elem_t (strcase (cdr (assoc 0 elem))))

	(if (= elem_t "LINE")
	  (progn
	    (setq p1 (cdr (assoc 10 elem)))
	    (setq p2 (cdr (assoc 11 elem)))
	    (setq lg (distance p1 p2))
	    (setq glg (+ glg lg))
	  )
	)
	(if (= elem_t "ARC")
	  (progn
	    (setq rad (cdr (assoc 40 elem)))
	    (setq a1 (cdr (assoc 50 elem)))
	    (setq a2 (cdr (assoc 51 elem)))
	    (setq a3 (- a2 a1))
	    (if	(< a2 a1)
	      (setq a3 (+ a2 (- (* pi 2) a1)))
	    )
	    (setq glg (+ glg (/ (* (* pi 2 rad) a3) (* pi 2))))
	  )
	)
	(setq ind (+ ind 1))
      )
      ;; end repeat
      (princ (strcat "\nLength: " (rtos glg)))
    )
  )
)

,

Add reply