I've been looking for a lisp program to help out at work. I've tried to mix-and-match code to come up with a working lisp but nothing is working. I am using a polyline rectangle to start with, offsetting it out 0.75 outward, and triming everything outside of the offset and erasing the offset. Anyone have the solution?
Thanks
@AutoCADnoob88 wrote:
.... I am using a polyline rectangle to start with, offsetting it out 0.75 outward, and triming everything outside of the offset and erasing the offset. Anyone have the solution?
....
As for the Trimming part, there are threads here about that -- do a Search for some words like "Trim outside" and you should find things.
You can Offset the Polyline rectangle easily enough by just selecting it, without needing to pick outside it to show Offset which way to go -- a routine can do that part for you. One approach:
(setq PL (car (entsel "\nSelect Polyline rectangle to Offset 0.75 units outward: ")))
(command
"_.offset" 0.75 PL "_none"
(polar
; a point guaranteed to be outside if it's a rectangle [or any convex shape whose
; first and last segments are not collinear], regardless of which direction it was
; drawn [could also be done based on various other relationships]
(vlax-curve-getStartPoint PL); base reference
(angle (vlax-curve-getPointAtParam PL 1) (vlax-curve-getStartPoint PL)); direction 2nd vertex to 1st
1 ; [any positive distance]
); polar
"" ; finish Offset
); command
[It even works on Circles, on Ellipses and Splines and Arcs in some circumstances, with not-visually-predictable directional results on Lines at least 1 unit long and Rays, and maybe some other things.]
@AutoCADnoob88 wrote:
I've been looking for a lisp program to help out at work. I've tried to mix-and-match code to come up with a working lisp but nothing is working. I am using a polyline rectangle to start with, offsetting it out 0.75 outward, and triming everything outside of the offset and erasing the offset. Anyone have the solution?
Thanks
Extrim doesnt cut for you AutoCADnoob88? [Express tools]
Or is that trim everything between the original rectangle and the newly offset polyline?
That is awesome! Both work but how would i put them into the same routine? Offset then trim to the offset. That would only leave getting rid of the offset lines and my work would be so much easier.
Here's an alternative method to perform the outside offset:
(defun c:offout ( / e s ) (if (setq s (ssget "_+.:E:S" '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1)))) (vl-catch-all-apply 'vla-offset (list (vlax-ename->vla-object (setq e (ssname s 0))) (if (LM:listclockwise-p (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) (entget e)) ) ) -0.75 0.75 ) ) ) ) (princ) ) ;; List Clockwise-p - Lee Mac ;; Returns T if the point list is clockwise oriented (defun LM:ListClockwise-p ( lst ) (minusp (apply '+ (mapcar (function (lambda ( a b ) (- (* (car b) (cadr a)) (* (car a) (cadr b))) ) ) lst (cons (last lst) lst) ) ) ) ) (vl-load-com) (princ)
@AutoCADnoob88 wrote:
That is awesome! Both work but how would i put them into the same routine? Offset then trim to the offset. That would only leave getting rid of the offset lines and my work would be so much easier.
That still doesnt answer my question AutoCADnoob88, are you trying to "trim" the objects between the original polyline [rectangle] and the newly created polyline?
is that what you meant by <<Offset then trim to the offset.>> ? getting rid of the offset lines is easy only question is what is the end result?
pbe
@pbejse wrote:
....That still doesnt answer my question AutoCADnoob88, are you trying to "trim" the objects between the original polyline [rectangle] and the newly created polyline?
....
The original question seems pretty clear to me: "...triming everything outside of the offset...."
@Kent1Cooper wrote:
@pbejse wrote:
....That still doesnt answer my question AutoCADnoob88, are you trying to "trim" the objects between the original polyline [rectangle] and the newly created polyline?
....
The original question seems pretty clear to me: "...triming everything outside of the offset...."
I see, silly me, i thought it would be more than just that.
It would ne more fun to code if it is what i thought it would be.
Cheers.
Offset a polyline .75 in distance outward. then trim everything outside of the newly created polyline that touches it and then delete the offset. The final picture is the original polyline box with .75in lines intersecting it along the edges.
thanks for all the help
OP, try combining Lee's code for offset with this beutiful code by Alan J. Thompson...
Look here for (c:EIO)
M.R.
Im still struggling putting all of this information together. Ive got the lisp for the offset .75 out and my version supports extrim but no one has mentioned how to delete the offset once everything has been trimmed outside of it. These lisp's are confusing. Why cant we just type in simple english and the program understands, get rid of all this secret code. haha
thanks
@AutoCADnoob88 wrote:
.... no one has mentioned how to delete the offset once everything has been trimmed outside of it. ....
One way: Immediately after the Offset-outward operation [whether my version or Lee Mac's], put a line like this:
(setq opl (entlast)); [= Offset PolyLine]
[Call the variable anything you like.] Then at the end, this:
(entdel opl)