- (defun c:linex (/ p1 p2 dist ang ents pts linefuzz angfuzz)
- (setq linefuzz 4.0)
- (setq angfuzz 0.001)
- (defun makepline (spc pts / norm elv pline)
- (setq norm (trans '(0 0 1) 1 0 t)
- elv (caddr (trans (car pts) 1 norm))
- )
- (setq pline
- (vlax-invoke
- spc
- 'addlightweightpolyline
- (apply 'append
- (mapcar '(lambda (pt)
- (setq pt (trans pt 1 norm))
- (list (car pt) (cadr pt))
- )
- pts
- )
- )
- )
- )
- (vla-put-elevation pline elv)
- (vla-put-normal pline (vlax-3d-point norm))
- pline
- )
- (setq 45deg (/ pi 4))
- (setq p1 (getpoint "\n指定第一点: "))
- (while (and p1
- (setq p2 (getpoint p1 "\n下一点:"))
- )
- (setq dist (distance p1 p2)
- ang (angle p1 p2)
- )
- (setq dist (* (fix (+ (/ dist linefuzz) 0.99)) linefuzz))
- (if (< (rem ang 45deg) 0.0523599)
- (setq ang (* 45deg (fix (/ ang 45deg))))
- (princ (strcat "\nWarning: Segment "
- (itoa (max (length pts) 1))
- " is a non standard angle."
- )
- )
- )
- (setq p2 (polar p1 ang dist))
- (setq ents (cons
- (entmakex
- (list (cons 0 "LINE")
- (cons 6 "BYLAYER")
- (cons 10 p1)
- (cons 11 p2)
- (cons 39 0.0)
- (cons 62 256)
- )
- )
- ents
- )
- pts (if pts
- (cons p2 pts)
- (list p2 p1)
- )
- )
- (setq p1 p2)
- )
- (and pts
- (null (initget "Yes No"))
- (/= (getkword "\n转换为多段线[(Y)es/(N)o] <Yes>: ")
- "No"
- )
- (makepline
- (if (= 1 (getvar "CVPORT"))
- (vla-get-paperspace
- (vla-get-activedocument (vlax-get-acad-object))
- )
- (vla-get-modelspace
- (vla-get-activedocument (vlax-get-acad-object))
- )
- )
- pts
- )
- (mapcar 'entdel ents)
- )
- (princ)
- )
|