Jump to content

Recommended Posts

Posted

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

 

example.JPG

 

 

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

Posted

Have you tried to use AutoCAD's align function?

Posted

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.

Posted

How or what is the slot made ? LWPOLYLINE?

Posted

Can you upload a sample drawing saved in Autocad 2009 or back?

Posted

Hi Tharwat.

 

This is a sample of how many different instances I can encounter.

 

test1.dwg

Posted

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.

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

Posted

Maybe that was a confusing example to give you.

Generally the rectangle will go all the way across the part with the slot.

Posted

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.

Posted

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

Posted

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)

Posted

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.

 

 

example2.JPG

 

 

Maybe I am over thinking all this...

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