RRS1987 Posted October 13, 2011 Share Posted October 13, 2011 Dear All, I need a lisp to draw a Rectangle with in the 3 following inputs. These are the inputs, 1.First center point of Rectangle. 2.Second center point of Rectangle. 3.Width of Rectangle. Please find attached the PDF file & help me Your concern must be appreciated. Thanks. REC.pdf Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 13, 2011 Share Posted October 13, 2011 Maybe: [b][color=BLACK]([/color][/b]defun c:rect3v [b][color=FUCHSIA]([/color][/b]/ p1 p2 d1 c1 c2 c3 c4[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq p1 [b][color=NAVY]([/color][/b]getpoint [color=#2f4f4f]"\nCenter Of 1st Side: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq p2 [b][color=NAVY]([/color][/b]getpoint p1 [color=#2f4f4f]"\nCenter Of 2nd Side: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]grdraw p1 p2 2 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 7[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq d1 [b][color=NAVY]([/color][/b]getdist [color=#2f4f4f]"\nOpposing Width: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq c1 [b][color=NAVY]([/color][/b]polar p1 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p1 p2[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c2 [b][color=NAVY]([/color][/b]polar p1 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p1 p2[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi -0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c3 [b][color=NAVY]([/color][/b]polar p2 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p2 p1[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c4 [b][color=NAVY]([/color][/b]polar p2 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p2 p1[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi -0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entmake [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"3DFACE"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 10 c1[b][color=MAROON])[/color][/b][b][color=MAROON]([/color][/b]cons 11 c2[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]cons 12 c3[b][color=MAROON])[/color][/b][b][color=MAROON]([/color][/b]cons 13 c4[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] I do wish AutoCad had never come up with the rectangle command. It never gave an option as to what type of entity was to be drawn. I've used a 3DFACE, cause I like 'em. LINEs SOLIDs TRACEs, POLYLINEs, LWPOLYINEs could all also be used. -David Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 13, 2011 Share Posted October 13, 2011 Just when I think I've seen every every conceivable way to draw a rectangle someone comes up with a new request. I never knew drawing a rectangle could be so complicated. LOL Quote Link to comment Share on other sites More sharing options...
pBe Posted October 13, 2011 Share Posted October 13, 2011 I was about to say the same thing, there's probably half a dozen request for rectangles during the past 2-3 weeks (exag really) Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 13, 2011 Share Posted October 13, 2011 How do I draw a rectangle by selecting no corner or side points what-so-ever? Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 13, 2011 Share Posted October 13, 2011 Actually the TRACE command would have worked just as well here. That's 1 reason I dislike the rectangle command so much. My $0.02 -David Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 13, 2011 Share Posted October 13, 2011 (edited) No lisp routine for my request? I'm disappointed. Addendum No takers I see. Well the answer would be to use the polygon command to construct a square which is just a special type of rectangle. The definition of a rectangle is "a four sided polygon where all interior angles are 90 degrees". The other properties of a rectangle are: Opposite sides are parallel and congruent, Diagonals bisect each other, and Diagonals are congruent. The only real difference between a square and a rectangle is the length of the sides (in a square the lengths are all the same). Now, back to our square drawn using the Polygon command. It really only requires one pick (for the center) as all other inputs are via the command line. Command: _polygon Enter number of sides : default Specify center of polygon or [Edge]: pick Enter an option [inscribed in circle/Circumscribed about circle] : default Specify radius of circle: 1 Forgive me...slow morning today. Waiting on a safety meeting to start. Have a good one. Edited October 13, 2011 by ReMark Quote Link to comment Share on other sites More sharing options...
pBe Posted October 13, 2011 Share Posted October 13, 2011 OH, for a while there i thought you meant no screen input whatsoever, i was trying to find a way to place my rectangle onto the drawing without pick point. I had it where it would start from 0,0 and move using arrow keys, but the issue there is the increment, depending on the drawing it might take a loooooonnnggg time to get to where its supposed to go. Anyhooo.. Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 13, 2011 Share Posted October 13, 2011 Yeah, I'm looking at a way to do that too! Telekinesis perhaps? Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 13, 2011 Share Posted October 13, 2011 Elmer Fudd's Wandom Wectangle Wenerator: [b][color=BLACK]([/color][/b]defun c:randrect [b][color=FUCHSIA]([/color][/b]/ cd c1 c2 y1 y2[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq cd [b][color=NAVY]([/color][/b]rtos [b][color=MAROON]([/color][/b]getvar [color=#2f4f4f]"CDATE"[/color][b][color=MAROON])[/color][/b] 2 8[b][color=NAVY])[/color][/b] x1 [b][color=NAVY]([/color][/b]atof [b][color=MAROON]([/color][/b]substr cd 17 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] y1 [b][color=NAVY]([/color][/b]atof [b][color=MAROON]([/color][/b]substr cd 16 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] x2 [b][color=NAVY]([/color][/b]atof [b][color=MAROON]([/color][/b]substr cd 15 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] y2 [b][color=NAVY]([/color][/b]atof [b][color=MAROON]([/color][/b]substr cd 14 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]grdraw [b][color=NAVY]([/color][/b]list x1 y1[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]list x2 y2[b][color=NAVY])[/color][/b] 2 3[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.TRACE"[/color] 1.0 [b][color=NAVY]([/color][/b]list x1 y1 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]list x2 y2 0[b][color=NAVY])[/color][/b] [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 13, 2011 Share Posted October 13, 2011 Glad I asked. Thanks David. Quote Link to comment Share on other sites More sharing options...
pBe Posted October 13, 2011 Share Posted October 13, 2011 Yeah, I'm looking at a way to do that too! Telekinesis perhaps? For fun (defun c:RemREc (/ RLength RWidth rect op Stop) (defun *IntGet1 (fn msg) (initget 1) (setq val ((eval fn) msg)) (if (eq val "") (progn (princ "Null Input Try again") (*IntGet1 fn msg))) val ) (setq RLength (*IntGet1 'Getreal "\nEnter Length: ") RWidth (*IntGet1 'Getreal "\nEnter Width: ")) (command "_rectang" "_non" "0,0" "_non" (list RLength RWidth 0.0)) (setq rect (vlax-ename->vla-object (entlast))) (while (null Stop) (princ "\nSelect key up/right/left/down to change position<Enter to stop>:") (setq op (cadr (grread))) (cond ((= op 50) (vla-move rect (vlax-3d-point '(0.0 0.0)) (vlax-3d-point (list 0.0 -10.0 0.0)))) ((= op 52) (vla-move rect (vlax-3d-point '(0.0 0.0)) (vlax-3d-point (list -10.0 0.0 0.0)))) ((= op 54) (vla-move rect (vlax-3d-point '(0.0 0.0)) (vlax-3d-point (list 10.0 0.0 0.0)))) ((= op 56) (vla-move rect (vlax-3d-point '(0.0 0.0)) (vlax-3d-point (list 0.0 10.0 0.0)))) ((member op '(13 32)) (setq Stop T)) ) ) ) arrow keys as 8-> up 2-> down 6-> right 4-> left Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 13, 2011 Share Posted October 13, 2011 Now look what I started! Quote Link to comment Share on other sites More sharing options...
pBe Posted October 13, 2011 Share Posted October 13, 2011 Now look what I started! I wrote that quickie for the fun of it. Great stuff Remark Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 13, 2011 Share Posted October 13, 2011 You're just messing with my mind aren't you? Quote Link to comment Share on other sites More sharing options...
pBe Posted October 13, 2011 Share Posted October 13, 2011 You're just messing with my mind aren't you? Not really Remark, having fun is all. It would have been better if the rectangle started at the middle of the screen. and add an option for rotation as well Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 13, 2011 Share Posted October 13, 2011 I meant that in a good way pBe. Quote Link to comment Share on other sites More sharing options...
pBe Posted October 13, 2011 Share Posted October 13, 2011 I meant that in a good way pBe. Why of course Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 13, 2011 Share Posted October 13, 2011 As a POLYLINE: [b][color=BLACK]([/color][/b]defun c:rect3v [b][color=FUCHSIA]([/color][/b]/ p1 p2 d1 c1 c2 c3 c4[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq p1 [b][color=NAVY]([/color][/b]getpoint [color=#2f4f4f]"\nCenter Of 1st Side: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq p2 [b][color=NAVY]([/color][/b]getpoint p1 [color=#2f4f4f]"\nCenter Of 2nd Side: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]grdraw p1 p2 2 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 7[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq d1 [b][color=NAVY]([/color][/b]getdist [color=#2f4f4f]"\nOpposing Width: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq c1 [b][color=NAVY]([/color][/b]polar p1 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p1 p2[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c2 [b][color=NAVY]([/color][/b]polar p1 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p1 p2[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi -0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c3 [b][color=NAVY]([/color][/b]polar p2 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p2 p1[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c4 [b][color=NAVY]([/color][/b]polar p2 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p2 p1[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi -0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entmake [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"POLYLINE"[/color][b][color=MAROON])[/color][/b][b][color=MAROON]([/color][/b]cons 66 1[b][color=MAROON])[/color][/b][b][color=MAROON]([/color][/b]cons 70 1[b][color=MAROON])[/color][/b][b][color=MAROON]([/color][/b]list 10 0 0 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]foreach v '[b][color=NAVY]([/color][/b]c1 c2 c3 c4[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]entmake [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 10 [b][color=BLUE]([/color][/b]eval v[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entmake [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"SEQEND"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] Remember everything defaults to is current settings for layer linetype, color, ltscale etc. -David -David Quote Link to comment Share on other sites More sharing options...
Least Posted October 13, 2011 Share Posted October 13, 2011 With all this talk about rectangles. I was recently looking for one which could draw a rectangle from two corner points but take the rotation from a selected polyline but I didn't find one. I have a routine which will change the crosshairs angle to a picked line so I tried that with the normal rectangle command but the rectangle is still drawn ortho. Has anybody seen one which can do this? Cheers Quote Link to comment Share on other sites More sharing options...
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.