devitg Posted June 4, 2019 Posted June 4, 2019 Good work Marko Tanks for the so simple and effective LISP . Quote
lrm Posted June 4, 2019 Posted June 4, 2019 Here's a version that requires only 3 points, the front two corners of the desk and any point along the back edge of the desk. u12 is a unit vector from p1 to p2 u43 is a unit vector from the projection of p3 onto line p1 p2 to p3. (defun c:mike2 (/ p1 p2 p3 p4 p5 p6 d e f h osm u12 u43) ; lrm 6/4/2019 (setq p1 (getpoint "\nFront desk corner: ") p2 (getpoint "\nOther front desk corner: ") p3 (getpoint "\nA beck desk corner: ") osm (getvar "osmode") ) (setvar "osmode" 0) (setq d (distance p1 p2) u12 (mapcar '/ (mapcar '- p2 p1) (list d d d)) e (dot (mapcar '- p3 p1) u12) p4 (mapcar '+ p1 (mapcar '* (list e e e) u12)) f (distance p3 p4) u43 (mapcar '/ (mapcar '- p3 p4) (list f f f)) h (+ f 800.0) p5 (mapcar '+ p2 (mapcar '* u43 (list h h h))) p6 (mapcar '+ p1 (mapcar '* u43 (list h h h))) ) (command "_.pline" "_non" p1 "_non" p2 "_non" p5 "_non" p6 "c") (setvar "osmode" osm) (princ) ) (defun cross (a b / crs) (setq crs (list (- (* (nth 1 a) (nth 2 b)) (* (nth 1 b) (nth 2 a)) ) (- (* (nth 0 b) (nth 2 a)) (* (nth 0 a) (nth 2 b)) ) (- (* (nth 0 a) (nth 1 b)) (* (nth 0 b) (nth 1 a)) ) ) ;end list ) ;end setq crs ) ;end cross ;;; dot product of 2 vectors a and b (defun dot (a b / dd) (setq dd (mapcar '* a b)) (setq dd (+ (nth 0 dd) (nth 1 dd) (nth 2 dd))) ) Quote
BIGAL Posted June 5, 2019 Posted June 5, 2019 Nice Lrm that's what I was thinking off the unit vector, as the request is to include random objects so just need the square off point. A maybe rather than hard code + 800 a getreal with default of 800. That way will work with other offsets. (setvar "osmode" 0) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq off (atof (nth 0 (AH:getvalsm (list "Offset plines " "Offset distance" 5 4 "800"))))) (setq d (distance p1 p2) ...... ...... h (+ f off) Multi GETVALS.lsp 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.