Hi i write this code to draw the frame of a door. I am trying to trim the lines of the wall when I draw the frame but I can not succes to trim automatically .
Code:
(defun c:doorframe ()
(command "_layer" "_m" "WINDOOR" "_c" "90" "" "")
(setvar "OSMODE" 41)
(setq point1 (getpoint "\n1st insertion point:"))
(if (/= point1 nil)
(progn
(setq point2 (getpoint "\n2nd insertion point:"))
(if (/= point2 nil)
(progn
(setq point3 (getpoint "\n Opposite wall point:"))
(if (/= point3 nil)
(progn
(setq x1 (car point1))
(setq y1 (cadr point1))
(setq h1 (caddr point1))
(setq x2 (car point2))
(setq y2 (cadr point2))
(setq h2 (caddr point2))
(setq x3 (car point3))
(setq y3 (cadr point3))
(setq h3 (caddr point3))
(setq gonia12 (+ (- (* 2 PI) (angle point1 point2)) (/ PI 2)))
(IF (> GONIA12 (* 2 PI)) (- GONIA12 (* 2 PI)))
(setq gonia21 (+ (- (* 2 PI) (angle point2 point1)) (/ PI 2)))
(IF (> GONIA21 (* 2 PI)) (- GONIA21 (* 2 PI)))
(setq gonia23 (+ (- (* 2 PI) (angle point2 point3)) (/ PI 2)))
(IF (> GONIA23 (* 2 PI)) (- GONIA23 (* 2 PI)))
(setq fld1 (rtos gonia12 3 4))
(setq fld2 (rtos gonia21 3 4))
(setq fld3 (rtos gonia23 3 4))
(prin1 (strcat "-->" fld1 fld2 fld3))
(setq anoigma (distance point1 point2))
(setq paxos (distance point2 point3))
(setq x4 (+ x3 (* anoigma (sin gonia21))))
(setq y4 (+ y3 (* anoigma (cos gonia21))))
(setq point4 (list x4 y4 0))
(setq x5 (+ x1 (* 0.05 (sin gonia12))))
(setq y5 (+ y1 (* 0.05 (cos gonia12))))
(setq point5 (list x5 y5 0))
(setq x6 (+ x4 (* 0.05 (sin gonia12))))
(setq y6 (+ y4 (* 0.05 (cos gonia12))))
(setq point6 (list x6 y6 0))
(setq x7 (+ x2 (* 0.05 (sin gonia21))))
(setq y7 (+ y2 (* 0.05 (cos gonia21))))
(setq point7 (list x7 y7 0))
(setq x8 (+ x3 (* 0.05 (sin gonia21))))
(setq y8 (+ y3 (* 0.05 (cos gonia21))))
(setq point8 (list x8 y8 0))
(command "OSNAP" "NONE" "")
(command "line" point1 point5 "")
(command "line" point2 point7 "")
(command "line" point3 point8 "")
(command "line" point4 point6 "")
(command "line" point5 point6 "")
(command "line" point7 point8 "")
(command "_layer" "_m" "WALLS-2D" "_c" "6" "" "_lw" "0.5" "" "")
(command "line" point1 point4 "")
(command "line" point2 point3 "")
(command "_trim" point1 point2 "")
(command "_trim" point4 point3 "")
)
)
)
)
)
)
);--- end defun