Bill Tillman Posted March 27, 2017 Posted March 27, 2017 I created the attached file with a LISP program to draw a stair stringer. I've been trying to figure out how to add the dimension shown which will be the overall length of the stringer. When I do this manually, I create a short line from the bottom of the stringer perpendicular to the top line of the stringer, then DIMALIGN from the two outer points. When I try to draw the short line segment I keep hitting a block. (command "._LINE" spt5 "per" spt1 I've also drawn a temporary line between spt1 and spt2 along the top line and tried to use it as the target for perpendicularity but it just doesn't come together like I was hoping. PerDimLisp.dwg Quote
Bill Tillman Posted March 27, 2017 Author Posted March 27, 2017 I came up with a method for this using a little trig, but was wondering if there were any other bright ideas on how to do this out there. Quote
Grrr Posted March 27, 2017 Posted March 27, 2017 Some example: (and (setq p1 (getpoint "\nFirst point")) (setq p2 (getpoint p1 "\nSecond point")) (progn (redraw) (grdraw p1 p2 1) ; draw your line in red (grdraw ; draw the perpendicular line in yellow p1 ; starting from p1 (polar ; calculate the 2nd point p1 ; starting from p1 (+ (angle p1 p2) (/ PI 2.)) ; perpendicular angle, Pi/2 = 90 deg (distance p1 p2) ; distance, same as the original line ); polar 2 ); grdraw ); progn ); and Quote
BIGAL Posted March 28, 2017 Posted March 28, 2017 Maybe also the vl closestpoint to which is 90 also, even if other line is not parallel and gives a pt you can use for the dim using align 2 pts. Quote
Grrr Posted March 28, 2017 Posted March 28, 2017 BIGAL is right, using vlax-curve-getClosestPointTo is easier and avoids calculating the angles (when you already have drawn the line). To visualise the result, using grread : (defun C:test ( / e grr Stop ) (if (setq e (car (entsel "\nSelect line, or curve: "))) (while (not Stop) (setq grr (grread T)) (cond ( (= (car grr) 25) (setq Stop T) ) ( (= (car grr) 5) (redraw) (grdraw (cadr grr) (vlax-curve-getClosestPointTo e (cadr grr) T) 2) ) ( (= (car grr) 3) (entmakex (list (cons 0 "LINE") (cons 10 (cadr grr)) (cons 11 (vlax-curve-getClosestPointTo e (cadr grr) T)) ) ) (setq Stop T) ) ); cond ); while ); if (princ) ); defun Quote
tombu Posted March 28, 2017 Posted March 28, 2017 See also: http://www.cadtutor.net/forum/showthread.php?94266-Nearest-point-to-a-line-from-a-point&p=646114&viewfull=1#post646114 and http://forums.augi.com/showthread.php?149591-Perpendicular-2D-snap-to-line&p=1228990&viewfull=1#post1228990 Thread I started and got great help on. Quote
rkent Posted March 28, 2017 Posted March 28, 2017 Rotate the UCS to the Object, dimension, change UCS back to World. I have UO set up for UCS, Object. And UW set up for UCS, World. Very quick and easy, I find uses for those all the time. I have listed a few of the ones I have set up in my personal quick keys.lsp. (DEFUN C:UO () (SETVAR "CMDECHO" 0)(COMMAND ".UCS" "OBJECT")(PRIN1)) (DEFUN C:UR () (SETVAR "CMDECHO" 0)(COMMAND ".UCS" "RIGHT")(PRIN1)) (DEFUN C:UT () (SETVAR "CMDECHO" 0)(COMMAND ".UCS" "TOP")(PRIN1)) (DEFUN C:UV () (SETVAR "CMDECHO" 0)(COMMAND ".UCS" "VIEW")(PRIN1)) (DEFUN C:UW () (SETVAR "CMDECHO" 0)(COMMAND ".UCS" "WORLD")(PRIN1)) 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.