Jump to content

Total perimeter command?


Recommended Posts

Posted

Is there a way to determine the total perimiter of multiple objects?

 

I have a rectangle with several holes, slots, and other assorted geometry and I would like to do a window select and find the total perimeter (linear distance) of all features.

 

Is this possible?

 

Thanks,

 

Jim

Posted

Give this a try:

 

(defun c:tlen (/ n e ss rjp-getlength)
 (defun rjp-getlength (e / ep)
   (if (= (type e) 'ename)
     (setq e (vlax-ename->vla-object e))
   )
   (if (not (vl-catch-all-error-p
              (setq ep (vl-catch-all-apply 'vlax-curve-getendparam (list e)))
            )
       )
     (vlax-curve-getdistatparam e ep)
     0.0
   )
 )
 (setq n 0)
 (if (setq ss (ssget))
   (progn (while (setq e (ssname ss 0))
            (setq n (+ (rjp-getlength e) n))
            (ssdel e ss)
          )
          (alert (rtos n))
   )
 )
 (princ)
)

Posted

You could use the LIST command.

Of course you will have to add up the totals yourself though.

Posted

ronjonp,

 

Pardon my ignorance and inexperience, but I've never entered code for lisp routines. Is there a brief tutorial somewhere explaining the process...mainly how and where to put it?

 

 

Thanks,

 

 

Jim

Posted

Refer to the AutoCAD FAQ section. Look under Customisation. There should be an article about how to load an AutoLISP routine.

Posted

Another way of approaching it:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:tlen  [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] ss[b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]apply[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]+[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vl-remove-if[/color][/b]
       [b][color=DARKRED]'[/color][/b][b][color=BLUE]vl-catch-all-error-p[/color][/b]
         [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b]x[b][color=RED])[/color][/b]
                    [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-apply[/color][/b]
                      [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b]y[b][color=RED])[/color][/b]
                         [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getDistatParam[/color][/b] y
                           [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getEndParam[/color][/b] y[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] x[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b]
                   [b][color=RED]([/color][/b][b][color=BLUE]vl-remove-if[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]listp[/color][/b]
                     [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]cadr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssnamex[/color][/b] ss[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

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...