Jump to content

I need lisp for calculating length of all line and area of slected atem.


Recommended Posts

Posted

i need any lisp for suppose multi line slection length and area suppose im slecting 10 line he shows me length of 10 line or polyline same multi slection area of objects

Posted

Check this out ....

 

(defun c:TesT (/ l pl a ss i sn)(vl-load-com)
 ;; Tharwat 20 .Nov. 2011 ;;
 (if (setq l  0
           pl 0
           a  0
           ss (ssget  '((0 . "LWPOLYLINE,POLYLINE,LINE")))
     )
   (progn
     (repeat (setq i (sslength ss))
       (setq sn (ssname ss (setq i (1- i))))
       (cond
         ((eq (cdr (assoc 0 (entget sn))) "LINE")
          (setq
            l (+ l
                 (distance (cdr (assoc 10 (entget sn)))
                           (cdr (assoc 11 (entget sn)))
                 )
              )
          )
         )
         ((member (cdr (assoc 0 (entget sn)))
                  '("LWPOLYLINE" "POLYLINE")
          )
          (progn
            (setq
              pl (+ pl (vla-get-length (vlax-ename->vla-object sn)))
            )
            (setq a (+ a (vla-get-area (vlax-ename->vla-object sn))))
          )
         )
       )
     )
     (alert (strcat "Total Length of Lines : < "
                    (rtos l 2)
                    " >"
                    "\n"
                    "Total Length of Polylines : < "
                    (rtos pl 2)
                    " >"
                    "\n"
                    "Total Area of Polylines : < "
                    (rtos a 2)
                    " >"
            )
     )
   )
   (princ)
 )
 (princ)
)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...