
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We use a lisp to create an arc tangent to 3 lines and it is not working in 2017
I have gone through the lisp and from what I understand it does the following:
(defun c:fa ( / pt1 pt2 pt3 cen ent1 ent2 ent3 pt4)
;define functions
(setq oldosmode (getvar "OSMODE"))
;save current osmode
(setvar "OSMODE" (+ 1024 512))
;set osnap to geometric center and nearest
(setq oldhighlight (getvar "HIGHLIGHT"))
;save current highlight mode
(setvar "HIGHLIGHT" 0)
;turn off highlight
(initget 1)
;prevents the user from responding to the request by entering only Enter
(setq pt1 (getpoint "\nPoint to first line: "))
;prompts user to select a point on the first line and defines that point as pt1
(initget 1)
;prevents the user from responding to the request by entering only Enter
(setq pt2 (getpoint "\nPoint to second line: "))
;prompts user to select a point on the second line and defines that point as pt2
(initget 1)
;prevents the user from responding to the request by entering only Enter
(setq pt3 (getpoint "\nPoint to third line: "))
;prompts user to select a point on the third line and defines that point as pt3
(setvar "OSMODE" (+ 1024 256))
;set osnap to geometric center and tangent
(command "circle" "3p" pt1 pt2 pt3)
;draws circle 3 point with tangent osnap to pt1 pt2 and pt3
(setvar "OSMODE" 0)
;turns osnaps off
(setq cen (trans (cdr (assoc 10 (entget (entlast)))) 0 1))
;sets cen to the center of the circle just drawn
(entdel (entlast))
;deletes the circle
(setvar "LASTPOINT" cen)
;sets lastpoint vsystem variable to cen (center of circle drawn and deleted)
;Everything seems to work up to here
(setq
pt1 (osnap pt1 "qui,per")
pt2 (osnap pt2 "qui,per")
pt3 (osnap pt3 "qui,per")
)
;I think this is supposed to redefine pt1, pt2, and pt3 to points on the lines perpendicular to the center of the circle but i don't think it is working
(setq
ent1 (ssget pt1)
ent2 (ssget pt2)
ent3 (ssget pt3)
pt4 (polar pt2 (angle cen pt2) (* 2.0 (distance cen pt2)))
)
;this is supposed to define ent1, ent2, and ent3 by selecting the object that passes through pt1, pt2, and pt3 respectively, and then defines pt4 as a point twice the radius of the circle and polar to the angle from the center of the circle to point 2
(command "break" ent1 pt1 pt4)
;breaks ent1 at pt1 to pt4
(command "break" ent3 pt3 pt4)
;breaks ent2 at pt1 to pt4
(command "erase" ent2 "")
;erases ent2
(command "arc" pt1 pt2 pt3)
;draws an arc from pt1 through pt2 to pt3
(setvar "HIGHLIGHT" oldhighlight)
;returns highlight to original setting
(setq oldhighlight nil)
;removes oldhighlight value
(setvar "osmode" oldosmode)
;sets osnaps to previous setting
(setq oldosmode nil)
;removes oldosmode value
(princ)
)
The lisp routine is below. Can anyone tell me why this isn't working?
;given three lines, arcs or combination thereof, fits an arc tangent
;to all 3 and trims off excess.
(defun c:fa ( / pt1 pt2 pt3 cen ent1 ent2 ent3 pt4)
(setq oldosmode (getvar "OSMODE"))
(setvar "OSMODE" (+ 1024 512))
(setq oldhighlight (getvar "HIGHLIGHT"))
(setvar "HIGHLIGHT" 0)
(initget 1)
(setq pt1 (getpoint "\nPoint to first line: "))
(initget 1)
(setq pt2 (getpoint "\nPoint to second line: "))
(initget 1)
(setq pt3 (getpoint "\nPoint to third line: "))
(setvar "OSMODE" (+ 1024 256))
(command "circle" "3p" pt1 pt2 pt3)
(setvar "OSMODE" 0)
(setq cen (trans (cdr (assoc 10 (entget (entlast)))) 0 1))
(entdel (entlast))
(setvar "LASTPOINT" cen)
(setq
pt1 (osnap pt1 "qui,per")
pt2 (osnap pt2 "qui,per")
pt3 (osnap pt3 "qui,per")
)
(setq
ent1 (ssget pt1)
ent2 (ssget pt2)
ent3 (ssget pt3)
pt4 (polar pt2 (angle cen pt2) (* 2.0 (distance cen pt2)))
)
(command "break" ent1 pt1 pt4)
(command "break" ent3 pt3 pt4)
(command "erase" ent2 "")
(command "arc" pt1 pt2 pt3)
(setvar "HIGHLIGHT" oldhighlight)
(setq oldhighlight nil)
(setvar "osmode" oldosmode)
(setq oldosmode nil)
(princ)
)
Solved! Go to Solution.