Hi Alls,
This my code to attempt a program trim a line,but that code only one line can not perfect work,any one over there to look that code what am I doing wrong,I very apreaciated for your help,thanks.
(defun dtr (a)
(* pi (/ a 180.0))
)
(defun create_offset ()
(setq p5 (polar p3 0 20))
(command "_offset" 1 el1 p5 "")
(setq e3 (entlast))
(command "_offset" 7 el1 p5 "")
(setq e4 (entlast))
)
(defun erase_obj ()
(command "_erase" e3 "")
(command "_erase" e4 "")
)
(defun c:test (/ p1 p2 el1 p3 ang)
(setq p1 '(0 0 0))
(setq p2 '(10 10 0))
(command "_rectang" p1 p2 "")
(setq el1 (entlast))
(setq p3 (mapcar '(lambda (a b)(/ (+ a b) 2.0)) p1 p2))
(setq lst '(51.923 58.846 65.769 72.692 79.615 86.538))
(setq p4 (polar p3 (dtr (nth 0 lst)) 25))
(command "_line" p3 p4 "")
(setq el2 (entlast))
(create_offset)
(setq om (getvar "osmode"))
(setvar "osmode" 1)
(setq ce (getvar "cmdecho"))
(setvar "cmdecho" 1)
(command "_trim" el2 e3 "" (osnap p3 "endp") "")
(command "_trim" el2 e4 "" (osnap p4 "endp") "")
(erase_obj)
(setq el3 (entlast))
(setq sse1 (entget el3))
(setq sp1 (cdr (assoc 10 sse1)))
(setq ep1 (cdr (assoc 11 sse1)))
(command "_erase" el3 "")
(setq p4 nil el2 nil el3 nil sse1 nil)
(setq p5 (polar p3 (dtr (nth 1 lst)) 25))
(command "_line" p3 p5 "")
(setq el4 (entlast))
(create_offset)
(command "_trim" el4 e3 "" (osnap p3 "endp") "")
(command "_trim" el4 e4 "" (osnap p5 "endp") "") ; problem here
(erase_obj)
(setq el4 (entlast))
(setq sse2 (entget el4))
(setq sp2 (cdr (assoc 10 sse2)))
(setq ep2 (cdr (assoc 11 sse2)))
(command "_erase" el4 "")
(setq p5 nil el4 nil el4 nil sse4 nil)
(command "_pline" ep1 sp1 sp2 ep2 "" "")
(setvar "osmode" om)
(setvar "cmdecho" ce)
(princ)
)