PDuMont Posted July 8, 2015 Posted July 8, 2015 Hello, I started to write a lisp to accomplish what I was trying to do, and quickly realized I was out of my league. What I am trying to do is draw a rectangle(magenta) perpendicular to the slot(red). In the top example I figured I could use the midpoint of the slot, and get the distance of the outside profile(white) to properly size the rectangle, but that will do nothing for the variables in the other 2 examples. Any ideas, suggestions... Thanks Quote
jonathann3891 Posted July 8, 2015 Posted July 8, 2015 Have you tried to use AutoCAD's align function? Quote
PDuMont Posted July 8, 2015 Author Posted July 8, 2015 Hi jonathann, yes I have, I use it all the time. I also have a copy/align lisp I use. The problem is the the length of the rectangle varies quite often, sometimes I can have upwards of 100 various rectangles I have to draw/align. Quote
David Bethel Posted July 8, 2015 Posted July 8, 2015 How or what is the slot made ? LWPOLYLINE? Quote
Tharwat Posted July 8, 2015 Posted July 8, 2015 Can you upload a sample drawing saved in Autocad 2009 or back? Quote
PDuMont Posted July 8, 2015 Author Posted July 8, 2015 Hi Tharwat. This is a sample of how many different instances I can encounter. test1.dwg Quote
PDuMont Posted July 8, 2015 Author Posted July 8, 2015 No, that varies constantly in length according to the part it is on, but the width is always .5". I was hoping to select the slot(red) and pick two points on the part to determine the rectangles' length, keeping it perpendicular to the slot. Quote
Tharwat Posted July 8, 2015 Posted July 8, 2015 No, that varies constantly in length according to the part it is on, But it is not in the attached drawing ! they look smaller than the slot rectangle . Quote
PDuMont Posted July 8, 2015 Author Posted July 8, 2015 Maybe that was a confusing example to give you. Generally the rectangle will go all the way across the part with the slot. Quote
PDuMont Posted July 8, 2015 Author Posted July 8, 2015 Maybe an explanation: The slot (with the bulge) is for a mechanical fastener, the perpendicular intersecting rectangle is for a tool to access the fastener's mechanism. Quote
David Bethel Posted July 8, 2015 Posted July 8, 2015 What ever is making the slot is not making a perfect oblong : LWPOLYLINE Layer: "CN_3-4_PLY-SLOT" Space: Model space Handle = 70bb Closed Constant width 0.00000000 area 2.17691944 perimeter 7.63345115 at point X=3052.78821521 Y=1484.80108524 Z=0.00000000 bulge -1.00000000 center X=3053.11821521 Y=1484.80108524 Z=0.00000000 radius 0.33000000 start angle 180.0000 end angle 0.0000 at point X=3053.44821521 Y=1484.80108524 Z=0.00000000 at point X=3053.44821521 Y=1482.02108524 Z=0.00000000 bulge -1.00000000 center X=3053.11821521 Y=1482.02108524 Z=0.00000000 Press ENTER to continue: radius 0.33000000 start angle 0.0000 end angle 180.0000 at point X=3052.78821521 Y=1482.02108524 Z=0.00000000 Until that is corrected, I don't believe that can accurately calculate the perpendiculars -David Quote
Tharwat Posted July 9, 2015 Posted July 9, 2015 Try this program that should work only on rectangular shapes on zero or 180 degrees . (defun c:Test (/ ss) ;; Tharwat 09.07.2015 ;; (princ "\nSelect polyline [rectangular shapes only]:") (if (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1)))) ((lambda (i / sn a b c pts p1 p2 p3 p4 1p 2p 3p 4p r) (while (setq sn (ssname ss (setq i (1+ i)))) (vla-getboundingbox (vlax-ename->vla-object sn) 'a 'b) (setq pts (mapcar 'vlax-safearray->list (list a b))) (mapcar 'set '(p1 p3) pts) (setq p2 (list (car p1) (cadr p3)) p4 (list (car p3) (cadr p1)) c (inters p1 p3 p2 p4) ) (if (< (distance p1 p2) (distance p2 p3)) (setq r (list (distance p2 p3) (angle p2 p3))) (setq r (list (distance p1 p2) (angle p1 p2))) ) (setq 1p (polar (polar c (cadr r) 0.25) (+ (cadr r) (* pi 0.5)) (/ (car r) 2.) ) 2p (polar 1p (+ (cadr r) pi) 0.5) 3p (polar 2p (+ (angle 1p 2p) (* pi 0.5)) (car r)) 4p (polar 3p (angle 2p 1p) 0.5) ) (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) '(8 . "CN_3-4_PLY-SLOT-25R") (cons 10 1p) (cons 10 2p) (cons 10 3p) (cons 10 4p) ) ) ) ) -1 ) ) (princ) )(vl-load-com) Quote
PDuMont Posted July 9, 2015 Author Posted July 9, 2015 Thank you David and Tharwat. David, not sure exactly where the discrepancy is in that shape. We have a 3d solid we pull off a tool palette to subtract out. This is mostly cabinet grade plywood construction, so tolerances hover around .03". Tharwat, that lisp is cool, however it creates a fixed size rectang according to the polyline selected. Would it not be possible to pick points 1 & 2 to determine location and set ucs, and points 3 & 4 to determine length of rectang. Maybe I am over thinking all this... 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.