iain9876 Posted December 10, 2009 Posted December 10, 2009 Does anyone know of a lisp routne that would draw a closed rectangle from 3points with differing z values? 1. First you would have three 3d points with differing z values. 2. You would click on the points in a clockwise order and then a rectangle would be drawn best fit to the 3 points. 3. The 4th point would be squared and elevated to suit. anyone heard of such a routine? Quote
gile Posted December 10, 2009 Posted December 10, 2009 Hi, Here's a quicky (no error handling) (defun c:rect3d (/ p1 p2 p3) (setq p1 (trans (getpoint "\nFirst point: ") 1 0) p2 (trans (getpoint p1 "\nSecond point: ") 1 0) p3 (trans (getpoint p1 "\nThird point: ") 1 0) ) (command "_.ucs" "3" "_non" p1 "_non" p2 "_non" p3) (setq p1 (trans p1 0 1) p2 (trans p2 0 1) p3 (trans p3 0 1) p3 (list (max (car p2) (car p3)) (max (cadr p2) (cadr p3))) ) (command "_.rectangle" "_non" p1 "_non" p3) (command "_.ucs" "_previous") (princ) ) 1 Quote
David Bethel Posted December 10, 2009 Posted December 10, 2009 I don't think that unless the 3 points form a right angle, that a true rectangle can be made with the points defining the corners. A parrallelagram maybe. And what happens if the points are colinear? Maybe I'm not understanding the request properly. -David Quote
iain9876 Posted December 10, 2009 Author Posted December 10, 2009 I don't think that unless the 3 points form a right angle, that a true rectangle can be made with the points defining the corners. A parrallelagram maybe. And what happens if the points are colinear? Maybe I'm not understanding the request properly. -David it would place a best fit rectangle based on the 3 points in 3d Quote
iain9876 Posted December 10, 2009 Author Posted December 10, 2009 Hi, Here's a quicky (no error handling) (defun c:rect3d (/ p1 p2 p3 p4 nor elv) (setq p1 (trans (getpoint "\nFirst point: ") 1 0) p2 (trans (getpoint p1 "\nSecond point: ") 1 0) p3 (trans (getpoint p1 "\nThird point: ") 1 0) ) (command "_.ucs" "3" "_non" p1 "_non" p2 "_non" p3) (setq p1 (trans p1 0 1) p2 (trans p2 0 1) p3 (trans p3 0 1) p4 (list (max (car p2) (car p3)) (max (cadr p2) (cadr p3))) ) (command "_.rectangle" "_non" p1 "_non" p4) (command "_.ucs" "_previous") (princ) ) Thats perfect! 1 Quote
David Bethel Posted December 10, 2009 Posted December 10, 2009 Then there would be 2 possible solutions: 1) ab is perpendicular to bc 2) bc is perpendicular to ab -David Quote
iain9876 Posted December 10, 2009 Author Posted December 10, 2009 Then there would be 2 possible solutions: 1) ab is perpendicular to bc 2) bc is perpendicular to ab -David solution 1 Quote
boxero Posted January 25, 2013 Posted January 25, 2013 This one is perfect. Because often happens that those 3 points are not in 90deg angl, would be nice if could put corrections in rectangle size. Lets say true size is 1.00x0.50 but lisp draws 0.98x0.51 so my idea is to add request regarding if we agree with proposed size or we want put own dimensions?? I hope this make sens, is is something you can help guys?? Quote
BIGAL Posted January 26, 2013 Posted January 26, 2013 It really comes down to the way you want to set the rules use pt1 & pt2 for orientation but some other rule regarding 3rd pt all methods would just use a UCs plane type answer. Stuff like extend/shorten pt pt2 as not true sq to pt3. So without rules a simple lisp can not be produced. 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.