Tyke Posted July 29, 2013 Posted July 29, 2013 These constraints do not define a unique rectangle: [ATTACH]43185[/ATTACH] Strictly speaking you are correct Lee. But they do if you always pick the same three sides of the rectangle. Quote
hmsilva Posted July 29, 2013 Posted July 29, 2013 Just for fun. A quick one, minimally tested... (defun c:test (/ P1 P2 P3 P4) (prompt "\nSelect all points clockwise or counterclockwise! ") (command "ucs" "_W") (setq p1 (getpoint "\nSelect the corner point: ") p2 (getpoint "\nselect a point to define the rectangle orientation: ") );; setq (command "ucs" p1 (trans p2 0 1) "") (setq p3 (getpoint "\nSelect next point: ") p4 (getpoint "\nSelect last point: ") p1 (trans p1 0 1) p2 (trans p2 0 1) );; setq (command "_rectang" "_non" p1 "_non" (inters p3 (polar p3 (+ (/ pi 2) (angle p1 p2)) 1) p4 (polar p4 (angle p1 p2) 1) nil ) "ucs" "_P" );; command (princ) );; test Henrique Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 Henrique, that works fine. I believe it is what the OP wanted, let's see if he gets back and tells us. From his avatar he could be a surveyor, so he would survey just one corner and then a point on three sides. We always surveyed three corners and it was easy enough to construct the rectangle from that. Quote
hmsilva Posted July 29, 2013 Posted July 29, 2013 Henrique, that works fine. I believe it is what the OP wanted, let's see if he gets back and tells us. From his avatar he could be a surveyor, so he would survey just one corner and then a point on three sides. We always surveyed three corners and it was easy enough to construct the rectangle from that. Let's wait and see... Quote
Guest Posted July 29, 2013 Posted July 29, 2013 thank you hmsilva and Tyke nice job . It works fine Cheers, my friends! ... Quote
hmsilva Posted July 29, 2013 Posted July 29, 2013 You're welcome, prodromosm Glad I could help Henrique Quote
Lee Mac Posted July 29, 2013 Posted July 29, 2013 Another version perhaps: (defun c:test2 ( / a1 p1 p2 p3 p4 ) (if (and (setq p1 (getpoint "\nPick vertex point: ")) (setq p2 (getpoint "\nPick 2nd point: " p1)) (setq p3 (getpoint "\nPick 3rd point: " p2)) (setq p4 (getpoint "\nPick 4th point: " p3)) ) (command "_.rectang" "_non" p1 "_R" (angtos (setq a1 (angle p1 p2))) "_non" (inters p3 (inters p1 p2 p3 (polar p3 (+ a1 (/ pi 2.0)) 1.0) nil) p4 (polar p4 (angle p1 p2) 1.0) nil) ) ) (princ) ) Or, if three points will suffice: (defun c:test3 ( / p1 p2 ) (if (and (setq p1 (getpoint "\nPick vertex point: ")) (setq p2 (getpoint "\nPick 2nd point: " p1)) ) (command "_.rectang" "_non" p1 "_R" (angtos (angle p1 p2)) "\\") ) (princ) ) Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 thank you hmsilva and Tyke nice job . It works fine Cheers, my friends! ... I didn't do anything really the thanks need to go to the guys who wrote the LISP routines. Quote
Tyke Posted July 29, 2013 Posted July 29, 2013 Another version perhaps: (defun c:test2 ( / a1 p1 p2 p3 p4 ) (if (and (setq p1 (getpoint "\nPick vertex point: ")) (setq p2 (getpoint "\nPick 2nd point: " p1)) (setq p3 (getpoint "\nPick 3rd point: " p2)) (setq p4 (getpoint "\nPick 4th point: " p3)) ) (command "_.rectang" "_non" p1 "_R" (angtos (setq a1 (angle p1 p2))) "_non" (inters p3 (inters p1 p2 p3 (polar p3 (+ a1 (/ pi 2.0)) 1.0) nil) p4 (polar p4 (angle p1 p2) 1.0) nil) ) ) (princ) ) Or, if three points will suffice: (defun c:test3 ( / p1 p2 ) (if (and (setq p1 (getpoint "\nPick vertex point: ")) (setq p2 (getpoint "\nPick 2nd point: " p1)) ) (command "_.rectang" "_non" p1 "_R" (angtos (angle p1 p2)) "\\") ) (princ) ) As ever Lee - fantastic. Quote
hmsilva Posted July 29, 2013 Posted July 29, 2013 Another version perhaps: (defun c:test2 ( / a1 p1 p2 p3 p4 ) (if (and (setq p1 (getpoint "\nPick vertex point: ")) (setq p2 (getpoint "\nPick 2nd point: " p1)) (setq p3 (getpoint "\nPick 3rd point: " p2)) (setq p4 (getpoint "\nPick 4th point: " p3)) ) (command "_.rectang" "_non" p1 "_R" (angtos (setq a1 (angle p1 p2))) "_non" (inters p3 (inters p1 p2 p3 (polar p3 (+ a1 (/ pi 2.0)) 1.0) nil) p4 (polar p4 (angle p1 p2) 1.0) nil) ) ) (princ) ) Or, if three points will suffice: (defun c:test3 ( / p1 p2 ) (if (and (setq p1 (getpoint "\nPick vertex point: ")) (setq p2 (getpoint "\nPick 2nd point: " p1)) ) (command "_.rectang" "_non" p1 "_R" (angtos (angle p1 p2)) "\\") ) (princ) ) Lee, the test2, was giving a small error in the rotation because it depends from defined precision in "Units", defining precision for more decimal places, worked without error. As always, nice code! Henrique Quote
Tharwat Posted July 30, 2013 Posted July 30, 2013 Did not you find my code of any use ? http://www.cadtutor.net/forum/showthread.php?80796-Need-Rectangle-Lisp-!!!!&p=548129&viewfull=1#post548129 Quote
Tharwat Posted July 30, 2013 Posted July 30, 2013 Your code is great my friend Sure ? I hope so . Quote
Lee Mac Posted July 30, 2013 Posted July 30, 2013 Did not you find my code of any use ? Tyke explained earlier that your program is restricted to generating rectangles that are orthogonal to the WCS axes and hence not suitable for a generic case. Why are you angry? Quote
Tharwat Posted July 31, 2013 Posted July 31, 2013 Tyke explained earlier that your program is restricted to generating rectangles that are orthogonal to the WCS axes and hence not suitable for a generic case. My post was related to THIS explanation from the OP . Why are you angry? No at all , it is just a tickle . 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.