can anyone help?
Does anyone have a lisp or can help me make one that can draws a line based on the angle of a line that is selected?
Example: I have a line that is on a 45 degrees
and I have text at the end of the line
I want to select the line and have a predetermined line
drawn in after the text based on scale of the drawing
see attached picture for better clarification.
can anyone help?
How about OSNAP Extension turned on?
Or in this (special?) case Polar angle 45?
try "snapang" maybe...
(setq draw_obj (entget (car (entsel))))
(command "snapang" (cdr (assoc 10 draw_obj)) (cdr (assoc 11 draw_obj)))
See here, turn on Extension and Parallell.
Then draw your line, use extension to find the first point, move the cursor over your first line and then to the second point to get the Paralell Osnap.
not sure if this is what you want, good exercise it was none the less
this is probably what many of you would call 'clumpsy' code, and as I'm very much a learner I'd love some input on this code and how to possibly improve itCode:(defun c:angline (/ scale lne selpt pt1 pt2 dist1 dist2 bp bp2 rad) (setq scale (getvar "cannoscalevalue")) (setq lne (entsel "\nSelect line: ")) (setq selpt (cadr lne)) (setq pt1 (cdr (assoc 10 (entget (car lne))))) (setq pt2 (cdr (assoc 11 (entget (car lne))))) (setq dist1 (/ (distance pt1 pt2) 2)) (setq dist2 (distance pt1 selpt)) (if (< dist1 dist2) (progn (setq rad (angle pt1 pt2)) (setq bp (polar pt2 rad (* 1 (/ 1 scale)))) (setq bp2 (polar bp rad 1)) (command "_.line" bp bp2 "") (command "_.lengthen" "dy" bp2 pause) ) (progn (setq rad (angle pt2 pt1)) (setq bp (polar pt1 rad (* 1 (/ 1 scale)))) (setq bp2 (polar bp rad 1)) (command "_.line" bp bp2 "") (command "_.lengthen" "dy" bp2 pause "" "") ) ) (princ) )
I tried your code in Acad 2010.
It starts Lengthen again it seems.
Maybe you need an extra (Command) to cancel everything?
Otherwise it works very good.
The other thing is that you'll notice with other peoples code pretty soon, you can assign multiple variables with setq, eg:Code:(if (setq lne (entsel "\nSelect line: ")) (progn ...) (princ "\nNothing Selected."))
sets a = 1, b = 2 and c = 3Code:(setq a 1 b 2 c 3)
Hope that helps a bit.
Would something like this help?
When you get to the point to pick a point, just use the osnap override "ext" and mouse-over the other line.Code:(defun c:PAR (/ #Obj #Point) (vl-load-com) (and (setq #Obj (car (entsel "\nSelect line: "))) (eq "LINE" (cdr (assoc 0 (entget #Obj)))) (setq #Point (getpoint "\nSpecify first point: ")) (vl-cmdf "_.line" "_non" #Point (strcat "<" (angtos (vla-get-angle (vlax-ename->vla-object #Obj)) 0 4)) PAUSE "" ) ;_ vl-cmdf ) ;_ and (princ) ) ;_ defun
Registered forum members do not see this ad.
Oh, and here's a nice addon, perpendicular.
Code:(defun c:Per (/ #Obj #Point #Ang) (and (setq #Obj (entsel "\nSelect line: ")) (eq "LINE" (cdr (assoc 0 (entget (car #Obj))))) (or (setq #Point (getpoint "\nSpecify first point <At Selection>: ")) (setq #Point (vlax-curve-GetClosestPointTo (car #Obj) (cadr #Obj))) ) ;_ or (setq #Ang (angtos (+ (* 0.5 pi) (vla-get-angle (vlax-ename->vla-object (car #Obj)))) 0 4)) (vl-cmdf "_.line" "_non" #Point (strcat "<" #Ang) PAUSE "") ) ;_ and (princ) ) ;_ defun