I made this code,but only one problems is below
when I draw following wave ,the start point isnt last endpoint
who can help,many thanks!
(defun c:wa (/ *error* an cenpt dx ep lm-arcwith3p nu olducs sp ss)
(defun *error*()
(command "ucs" olducs "")
)
(if (not (tblsearch "layer" "water"))
(entmake(list'(0 . "LAYER")'(100 . "AcDbSymbolTableRecord")'(100 . "AcDbLayerTableRecord")(cons 2 "water")'(62 . 1)'(70 . 0)'(6 . "CONTINUOUS")))
)
(defun lm-arcwith3p (point1 point2 / ang P1 p2 p3 p4 )
(setq
ang (angle point1 point2)
P1 (polar point1 (- ang (* 0.25 pi)) 28.28)
P2 (polar p1 (+ (angle point1 p1) (* 0.1 pi)) 22.36)
point2 (polar point1 ang 100)
;P3 (polar p4 (+ (angle p4 point2) (* 0.1 pi)) 22.36)
p3 (polar p2 ang 20)
P4 (polar point2 (+ ang (* 1.25 pi)) 28.28)
point3 (polar point1 (+ ang (* 0.5 pi)) 100)
)
; (command ".ucs" point1 point2 point3)
(command ".PLINE" point1 P1 p2 p3 p4 point2 "")
; (command ".ucs" "p" )
(entlast)
)
(setq olducs (getvar "UCSORG"))
; (command "ucs" "w")
(setvar "peditaccept" 1)
(setvar "cmdecho" 0)
(while
(setq sp (getpoint "\nstart point:"))
(setq ep (getpoint sp "\nend point:"))
; (while ep
; (setq ep (getpoint sp "\n指定波浪线终点:"))
; )
(setq nu (/ (fix(distance sp ep)) 100))
(setq ss (ssadd))
(setq xsp (car sp) xep (car ep))
(if (> xsp xep)
(progn
(setq tmpsp sp)
(setq sp ep)
(setq ep tmpsp)
)
)
(setq an (angle sp ep))
(repeat nu
(setq ss (ssadd (lm-arcwith3p sp (setq ep(polar sp an 100))) ss))
(setq sp ep)
)
(command ".pedit" "m" ss "" "J" 0 "" )
)
(command "ucs" olducs "")
(princ)
)