James Burke Posted May 11, 2009 Posted May 11, 2009 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 Quote
ronjonp Posted May 11, 2009 Posted May 11, 2009 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) ) Quote
Cad64 Posted May 11, 2009 Posted May 11, 2009 You could use the LIST command. Of course you will have to add up the totals yourself though. Quote
James Burke Posted May 13, 2009 Author Posted May 13, 2009 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 Quote
ReMark Posted May 13, 2009 Posted May 13, 2009 Refer to the AutoCAD FAQ section. Look under Customisation. There should be an article about how to load an AutoLISP routine. Quote
Lee Mac Posted May 13, 2009 Posted May 13, 2009 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] Quote
Recommended Posts
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.