square off two parallel lines and trim corner lisp help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
can anyone help modifyin this routine so when i select polyline it will go directly to fillet commenad.
this lisp will draw line from the end point of selecte two parallel lines even if not both lines are not equal distance.
and the theose lines are not parallel it wil use the fillet "0" to trim them at the intersection.
so i need it to work on polylines. or at lest use the fillet "0"
right now it doesn't
(defun c:tc (/ l1 l2 s1 s2
p10 p11 p20 p21 e1 e2 p1 p2 em1 em2 la
sp ep sa ea mp ra pt1 pt2 pp1 pp2 zl pe1 pe2
)
(setq ccl (getvar "CECOLOR"))
(setq clt (getvar "CELTYPE"))
(setq cla (getvar "clayer"))
; (princ "\nSelect 2 Parallel Lines")
(while (not l1)
(while (not s1)
(setq s1 (entsel "\nSelect 1st Line: ")))
(setq p1 (nth 1 s1)
ep (car s1))
(if (= "LINE" (cdr (assoc 0 (entget ep))))
(setq l1 ep)))
(setq pe1 (osnap p1 "end"))
(redraw l1 3)
(while (not l2)
(while (not s2)
(setq s2 (entsel "\nSelect 2nd Line: ")))
(setq p2 (nth 1 s2)
ep (car s2))
(if (= "LINE" (cdr (assoc 0 (entget ep))))
(setq l2 ep)))
(setq pe2 (osnap p2 "end"))
(redraw l2 3)
(setq e1 (entget l1)
e2 (entget l2)
p10 (cdr (assoc 10 e1))
p11 (cdr (assoc 11 e1))
p20 (cdr (assoc 10 e2))
p21 (cdr (assoc 11 e2)))
;;;COMPARE LINE ANGLES
(if (not (or (equal (angle p10 p11) (angle p20 p21) 1e-8)
(equal (angle p10 p11) (angle p21 p20) 1e-8)))
(progn
;(alert "Lines Are Not Parallel")
(command "fillet" s1 s2) (exit)))
;;;COMPARE LINE ELEVATIONS
(setq zl (mapcar 'caddr (list p10 p11 p20 p21)))
(if (apply '/= zl)
(progn
(alert "Lines Are Not Equal Elevation")
(exit)))
;;;COMPARE LINE UCS
(if (not (equal (cdr (assoc 210 e1)) (cdr (assoc 210 e2)) 1e-8))
(alert "Lines Are Not Same UCS - Be Careful"))
;;;CLOSEST ENDS TO 1ST PICK POINT
(if (> (distance p10 p1) (distance p11 p1))
(setq pt1 p10 em1 10 la (angle p11 p10))
(setq pt1 p11 em1 11 la (angle p10 p11)))
(if (> (distance p20 pt1) (distance p21 pt1))
(setq pt2 p20 em2 10)
(setq pt2 p21 em2 11))
(grdraw pt1 pt2 3 0)
;;;PERPINDICULAR POINTS
(setq pp1 (inters p10 p11 pt2 (polar pt2 (+ (angle p10 p11) (* pi 0.5)) 1) nil))
(setq pp2 (inters p20 p21 pt1 (polar pt1 (+ (angle p10 p11) (* pi 0.5)) 1) nil))
(grdraw pt1 pp2 1 0)
(grdraw pt2 pp1 2 0)
(setq mp (mapcar '(lambda (a b) (* (+ a b) 0.5)) pt1 pt2)
ra (* (distance pt1 pp2) 0.5)
sa (angle pt1 pp2)
ea (+ sa pi)
sp (polar mp sa ra)
ep (polar mp ea ra))
;**********************************
(setq cmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq ent (car s1))
(setq edata (entget ent))
(setq etype (cdr (assoc 0 edata)))
(setq c (cdr (assoc 62 edata)))
(setq lt (cdr (assoc 6 edata)))
(setq l (cdr (assoc 8 edata)))
(setq lts (cdr (assoc 48 edata)))
(if (not lts) (setq lts 1))
(progn
(if (= lt nil) (setq lt "BYLAYER"))
(if (= c nil) (setq c "BYLAYER"))
)
(command "_color" c)
(command "_linetype" "s" lt "")
(command "_layer" "set" l "")
(setvar "celtscale" lts)
;****************
(command "line" pp1 pt2 "")
(command "lengthen" "dy" s1 pp1 "")
(command "lengthen" "dy" s2 pp1 "")
(command "regen")
(setvar "CECOLOR" ccl)
(setvar "CELTYPE" clt)
(setvar "clayer" cla)
(redraw)
(prin1))