Hey everyone, I'm in trouble again
This LISP is a square made of two triangles
Can achieve the effect of drawing two points into a rectangle
But the rectangle is not in the positive direction
Can this LISP be changed to a rectangle in the positive direction?
Above the photo is the LISP effect
I want the effect of red below
(defun :GR (a) (* pi (/ a 180.0)))
(defun C:SQR ( / ANG12 ANG1X ANG2X P1 P2 PXL PXR)
(setq p1 (getpoint "\nfirst point :"))
(setq p2 (getpoint p1 "\nsecond point :"))
(setq ang12 (angle p1 p2)
ang2x (+ ang12 (:GR 45.0))
ang1x (+ ang12 (:GR 135.0))
)
(setq pxl (inters p2 (polar p2 ang2x 1.0) p1 (polar p1 ang1x 1.0) nil))
(setq pxr (inters p1 (polar p1 (+ ang2x pi) 1.0) p2 (polar p2 (+ ang1x pi) 1.0) nil))
(vl-cmdf "line" p1 p2 "")
(vl-cmdf "pline" p1 pxr p2 pxl p1 "")
)
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by paullimapa. Go to Solution.
Solved by paullimapa. Go to Solution.
After you've drawn the rotated white square, then do the following:
(setq en(entlast)) ; select last object
(setq ob(vlax-ename->vla-object en)) ; convert to vla object
(vla-getboundingbox ob 'mn 'mx) ; get coordinates of object's bounding box
(setq llpt (vlax-safearray->list mn)) ; convert to lower left coordinate point
(setq urpt (vlax-safearray->list mx)) ; convert to upper right coordinate point
(command"_.Rectang" llpt urpt) ; draw the square
sure remember the first line of code where I saved the original square as en:
(setq en(entlast)) ; select last object
All you have to do is now add this line of code at the end:
(entdel en)
I would not do it by drawing the diagonal box, then finding its bounding box, then drawing the box you want [EDIT: if it is really the box you want -- see my next Message], then deleting the diagonal one. I would do it directly:
(defun C:SQR (/ ANG12 ANG1X ANG2X P1 P2)
(setq p1 (getpoint "\nfirst point :"))
(setq p2 (getpoint p1 "\nsecond point :"))
(setq
ang12 (angle p1 p2)
ang2x (+ ang12 (/ pi 2))
ang1x (- ang12 (/ pi 2))
rad (/ (distance p1 p2) 2)
)
(vl-cmdf "line" p1 p2 ""); if still desired
(vl-cmdf "pline"
(polar p1 ang1x rad) (polar p2 ang1x rad)
(polar p2 ang2x rad) (polar p1 ang2x rad)
"_close"
)
)
That's in simplest terms as yours is, but I would suggest adding control over Object Snap, at least, and other typical enhancements.
It looks from the end of your video as though maybe you don't want the Line across the middle, but I wasn't sure.
@a22663564 wrote:
It is successful....
... if the two points are in an orthogonal relationship to one another, but not if they are at some other angle:
My routine in Message 7 works at any angle [as does your original that draws the diagonal box]:
Can't find what you're looking for? Ask the community or share your knowledge.