Guest Posted July 28, 2013 Posted July 28, 2013 1) Rectangle with sides and direction Have two points (or one and the second distance) to one side of the rectangle. Once defined the first side designed temporary line of infinite length in the vertical direction and distance that the first length provided. You can select the second point of the rectangle for this temporary line or give the length and will be designed automatically. (look photo 1) 2) Rectangle with 4 points (one for each side) Give one point for each side of the rectangle drawn Rectangle that includes these points. (look photo 2) Quote
Guest Posted July 29, 2013 Posted July 29, 2013 for the first part i find in the forum alanjt post here (http://www.cadtutor.net/forum/showthread.php?63494-Lisp-for-rectangle/page5) Would this be of any interest? http://www.theswamp.org/index.php?topic=34267.0 but i dont have password and the Registration has been disabled for the time... Quote
Guest Posted July 29, 2013 Posted July 29, 2013 any help please i need this lisp .............. Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 The answer to the second question is that you cannot do it. With four points as shown, you could rotate the rectangle and still get it to pass through the four points, albeit the rectangle would be a different size. Not quite sure that I understand your first question, but it would appear from you last post you have that solved. Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 any help please i need this lisp .............. Alan's LISP: (defun c:BX (/ foo _dist p1 p2 p3 ang) ;; Draw rectangle based on 2 or 3 picked points ;; Alan J. Thompson, 07.26.10 (defun foo (l) (entmake (append '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (100 . "AcDbPolyline") (90 . 4) (70 . 129)) (mapcar (function (lambda (p) (cons 10 (reverse (cdr (reverse (trans p 1 0))))))) l) ) ) ) (defun _dist (a b) (distance (list (car a) (cadr a)) (list (car b) (cadr b)))) (if (and (setq p1 (getpoint "\nSpecify first point: ")) (setq p2 (getpoint p1 "\nSpecify second point: ")) (not (grdraw p1 p2 3 1)) ) (if (setq p3 (initget 0 "Left Right") p3 (getpoint p2 "\nSpecify third point or Square box or [Left/Right]: ") ) (cond ((vl-consp p3) (foo (list p1 p2 p3 (polar p3 (angle p2 p1) (_dist p1 p2))))) ((eq (type p3) 'STR) (cond ((eq p3 "Left") (setq ang (+ (/ pi 2.) (angle p1 p2)))) ((eq p3 "Right") (setq ang (+ (* pi 1.5) (angle p1 p2)))) ) (foo (list p1 p2 (polar p2 ang (_dist p1 p2)) (polar p1 ang (_dist p1 p2)))) ) ) ) ) (redraw) (princ) ) Quote
Guest Posted July 29, 2013 Posted July 29, 2013 i dont have a password to check this lisp ............ Quote
Guest Posted July 29, 2013 Posted July 29, 2013 What about 2) Rectangle with 4 points (one for each side) Give one point for each side of the rectangle drawn Rectangle that includes these points. Quote
Guest Posted July 29, 2013 Posted July 29, 2013 the first part with the bx.lsp is solved but i need and second please ............. Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 As I said in post #5 you cannot do a rectangle with one point for each side. It is possible to draw lots of rectangles through the points. Check out this image. Quote
Guest Posted July 29, 2013 Posted July 29, 2013 if the one point is a corner of this rectacle and the other 3 points are one for each side is it possible ?? Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 Yes that would be possible. In your image where A is a corner, you get only one solution. Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 can you do it ??? Not in LISP. But I would think someone will be along who can help you. Quote
Tharwat Posted July 29, 2013 Posted July 29, 2013 Try this and let me know .. (defun c:Test (/ p1 p2 p3 p4 l1 x1 x2 l2 y1 y2) (and (setq p1 (getpoint "\n First point :")) (setq p2 (getpoint "\n Second Point :")) (setq p3 (getpoint "\n Third Point :")) (setq p4 (getpoint "\n Forth Point :")) ) (progn (setq l1 (mapcar 'car (list p1 p2 p3 p4))) (setq x1 (apply 'max l1)) (setq x2 (apply 'min l1)) (setq l2 (mapcar 'cadr (list p1 p2 p3 p4))) (setq y1 (apply 'max l2)) (setq y2 (apply 'min l2)) (command "_.rectang" "_non" (list x1 y2) "_non" (list x2 y1) ) ) (princ) ) Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 The LISP draws a rectangle through the four points, but the sides of the rectangle are vertical and horizontal. For this situation you have multiple solutions when the rectangle's sides are not horizontal and vertical, see my post #11 with example image. The OP then asked if with one corner point and three points on the sides if it would be possible and it is. I would have thought of picking the corner point first and then the other points, then constructing the figure as the rectangle command will only work for horizontal and vertical sides. Quote
Lee Mac Posted July 29, 2013 Posted July 29, 2013 In your image where A is a corner, you get only one solution. These constraints do not define a unique rectangle: Quote
nestly Posted July 29, 2013 Posted July 29, 2013 Here's a non-lisp solution using Geometric Constraints 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.