Originally Posted by
rhall.72202
Is there a way, via lisp, to create the following notch detail????
The lines are drawn in as shown and then the radii added.
The angles of the 2 lines vary across drawings.
I am positive this will not work in all instances, but it is a start. I do not know all of your parameters or how your entities are drawn.
This program assumes the two lines are "LINE" entities. No error checking is provided.
Code:
(defun C:TEST (/ NOTCH:ASC NOTCH:DTR BPNT BRAD INTPICK INTPICK1 INTPICK2 L1 L1-2INT L1ANG L1ANG90 L1E L1S L2 L2ANG L2ANG90 L2E L2S L3 L3-4INT L3E L3S L4E L4S LPNT LRAD TEMP1)
(defun NOTCH:DTR (A) (* pi (/ A 180.0)))
;;; utility to convert decimal degrees to radians
(defun NOTCH:ASC (ELEMENT ENTITY /)
;;; retrieve assoc data from entity
(cdr (assoc ELEMENT ENTITY))
)
(defun MAKEARC (PNT RAD START END / ECODES)
(setq ECODES (list (cons 0 "ARC")
(cons 8 (getvar "clayer"))
(cons 10 PNT)
(cons 40 RAD)
(cons 50 START)
(cons 51 END)
)
)
(entmake ECODES)
)
(setq L1 (entget (car (entsel "\nSelect Line 1: ")))
L2 (entget (car (entsel "\nSelect Line 2: ")))
INTPick (getpoint "\nPick point in interior of angle: "))
(if (not lrad) ; set little radius if not already set
(setq lrad 0.125))
(if (not brad) ; set big radius if not already set
(setq brad 0.5))
(setq L1S (cdr (assoc 10 L1)) ; get line 1 start point
L1E (cdr (assoc 11 L1)) ; get line 1 end point
L2S (cdr (assoc 10 L2)) ; get line 2 start point
L2E (cdr (assoc 11 L2)) ; get line 2 end point
)
(setq L1-2INT (inters L1S L1E L2S L2E NIL)) ; get line intersection point
(setq L1ANG (angle L1S L1E) ; get line angles
L2ANG (angle L2S L2E)
L1ANG90 (- L1ANG (DTR 90.0)) ; get temporary perpendicular angles
L2ANG90 (+ L2ANG (DTR 90.0))
)
(setq INTPICK1 (inters L1S L1E INTPICK (polar INTPICK L1ANG90 1.0) NIL) ; get interior angle intersection points
INTPICK2 (inters L2S L2E INTPICK (polar INTPICK L2ANG90 1.0) NIL)
)
(if (/= (angle INTPICK1 L1-2INT) L1ANG) ; verify line1 angle
(setq TEMP1 L1S
L1S L1E
L1E TEMP1
temp1 nil
L1ANG (angle L1S L1E) ; get line angles
)
)
(if (/= (angle INTPICK2 L1-2INT) L2ANG) ; verify line2 angle
(setq TEMP1 L2S
L2S L2E
L2E TEMP1
temp1 nil
L2ANG (angle L2S L2E)
)
)
(setq L1ANG90 (angle INTPICK1 INTPICK) ; get perpendicular angles
L2ANG90 (angle INTPICK INTPICK2)
)
(setq L3S (polar L1S L1ANG90 LRAD) ; get temp line 3 start
L3E (polar L1E L1ANG90 LRAD) ; get temp line 3 end
lpnt (inters L2S L2E L3S L3E NIL) ; get little arc radius
)
(setq L3s (polar LpNT (+ L1ANG90 (dtr 180.0)) LRAD)
L3E LpNT
)
;(command "line" l3s l3e "")
(setq L4S (polar L2S L2ANG90 BRAD)
L4E (polar L2E L2ANG90 BRAD)
L3-4INT (inters L3S L3E L4S L4E NIL)
)
(entdel (asc -1 l1)) ; delete original line 1
(entdel (asc -1 l2)) ; delete original line 2
(entmake (subst (cons 11 l3s)(assoc 11 l1) l1)) ; make new line 1
(setq l3s (polar lpnt l2ang lrad) ; new start point for line 3
l3e l2e) ; new end point for line 3
(setq l3 (subst (cons 10 l3s)(assoc 10 l2) l2) ; line 3
l3 (subst (cons 11 l3e)(assoc 11 l3) l3))
(setq BPNT ; radius point of big arc
(polar (polar
lpnt
(- L2ANG (dtr 180.0))
(* (+ BRAD LRAD) (cos (ASIN (/ BRAD (+ BRAD LRAD)))))
)
L2ANG90
BRAD
)
)
(setq l2 (subst (cons 11 (inters l2s l2e bpnt (polar bpnt l2ang90 1.0) nil))(assoc 11 l2)l2) ; modify line 2
l2 (subst (cons 10 l2s)(assoc 10 l2)l2))
(entmake l2) ; make new line 2
(entmake l3) ; make new line 3
(MAKEARC BPNT
BRAD
(angle BPNT lpnt)
(angle BPNT
(inters BPNT (polar BPNT L2ANG90 1.0) L2S L2E NIL)
)
)
(MAKEARC LPNT
LRAD
(angle LPNT BPNT)
(angle LPNT
(inters LPNT (polar LPNT L1ANG90 1.0) L1S L1E NIL)
)
)
)
(defun ASIN (X /)
;;arcsine= arctan(X/Sqrt(1.0-(X^2)))
(cond ((= X 1) (setq R (/ pi 2)))
((= X -1) (setq R (/ (* pi -1) 2)))
(t (setq R (atan (/ X (sqrt (- 1.0 (expt X 2)))))))
) ;_ end of cond
) ;_ end of defun