;I.HALIM GOKBULUT-HGKStudio
;çizimdeki toplam ARC ve LINE uzunluklarını hesaplar;
(defun c:top(/ temp sset ssl nsset i topyay topciz basaci sonaci boy bas son alfa)
  (prompt "\nUzunlukları Toplanacak Yay ve Doğruları Seçiniz.")
  (setq sset (ssget))
  (if (null sset) 
    (progn
      (princ "\nBişey şeçilmedi.")
      (exit)
    )
  )
  ;; Validate selection set
  (setq ssl   (sslength sset)
        nsset (ssadd))
    (princ "\n<Seçilen objeler inceleniyor...>")
  (while (> ssl 0)
    (setq temp (ssname sset (setq ssl (1- ssl))))
    (if (or
          (= (cdr (assoc 0 (entget temp))) "LINE")
          (= (cdr (assoc 0 (entget temp))) "ARC")
           (= (cdr (assoc 0 (entget temp))) "CIRCLE")
        )
      (ssadd temp nsset)
    )
  )
  (setq ssl (sslength nsset)
        sset nsset
  )
  (print ssl)
  (princ " ARC, CIRCLE ve LINE objesi bulundu.")

   (setq i 0 topyay 0 topciz 0)
   (repeat ssl
         (setq elist (entget (ssname sset i)))
         (cond 
               ((= (cdr (assoc 0 elist)) "ARC")
                      (setq   yaricap (cdr (assoc 40 elist))
                                 alfa (- (cdr (assoc 51 elist)) 
                                           (cdr (assoc 50 elist))
                                        )
                      )
                      (if (< alfa 0.0) (setq alfa (+ alfa (* 2 PI))))
                      (setq boy (* alfa yaricap)
                               topyay (+ topyay boy)
                      )
               );ARC
               ((= (cdr (assoc 0 elist)) "CIRCLE")
                      (setq yaricap (cdr (assoc 40 elist))
                                 boy (* 2 PI yaricap)
                                 topyay (+ topyay boy)
                       )
               );CIRCLE

              ((= (cdr (assoc 0 elist)) "LINE")
                     (setq bas (cdr (assoc 10 elist))
                                son (cdr (assoc 11 elist))
                                boy (distance bas son)
                                topciz (+ topciz boy)
                      )
              );LINE
         );cond
         (setq  i (1+ i))
   )
   (princ (strcat "\nYaylar = " (rtos topyay 2 2) " m. Doğrular = " (rtos topciz 2 2) " m. Toplam Uzunluk = " (rtos (+ topciz topyay) 2 2) " m"))
   (princ)
);defun
(princ "\n I.HALIM GOKBULUT-HGKStudio\n")
(princ "\ntopla.lsp yüklendi. TOP komutu ile çalıştırınız.")
(princ)