- (defun c:tt (/ ss obj end_pt pt c_flag n ch_start ch_close ch_open)
- (vl-load-com)
- (if (setq ss (ssget ":E:S" '((0 . "LWPOLYLINE"))))
- (progn
- (sssetfirst nil ss)
- (setq obj (vlax-ename->vla-object (ssname ss 0))
- ch_close nil
- ch_start nil
- ;;; ch_open nil
- )
- (setq end_pt (vlax-curve-getEndPoint OBJ))
- (while (and (not ch_close)
- (car (list t (initget "S E C O _start end close open" )))
- (setq pt (getpoint end_pt "\n指定下一点[S从起点开始/E从终点开始/C闭合/O打开]:"))
- ) ;_ end of and
- (cond
- ((= (type pt) 'list)
- (if (vlax-curve-isClosed obj)
- (setq n (fix (1- (vlax-curve-getendParam obj)))
- c_flag t
- ) ;_ end of setq
- (setq n (fix (vlax-curve-getendParam obj))
- c_flag nil
- ) ;_ end of setq
- ) ;_ end of if
- (if (or ch_start c_flag )
- (progn
- (vla-addvertex
- obj
- 0
- (vlax-safearray-fill
- (vlax-make-safearray vlax-vbDouble '(0 . 1))
- (list (car pt) (cadr pt))
- ) ;_ end of vlax-safearray-fill
- ) ;_ end of vla-addvertex
- (setq end_pt (vlax-curve-getStartPoint OBJ))
- ) ;_ end of progn
- (progn
- (vla-addvertex
- obj
- (1+ n)
- (vlax-safearray-fill
- (vlax-make-safearray vlax-vbDouble '(0 . 1))
- (list (car pt) (cadr pt))
- ) ;_ end of vlax-safearray-fill
- ) ;_ end of vla-addvertex
- (setq end_pt (vlax-curve-getEndPoint OBJ))
- ) ;_ end of progn
- ) ;_ end of if
- )
- ((and (= (type pt) 'str)(= pt "start"))
- (setq end_pt (vlax-curve-getStartPoint OBJ))
- (setq ch_start t)
- )
- ((and (= (type pt) 'str)(= pt "end"))
- (setq end_pt (vlax-curve-getEndPoint OBJ))
- (setq ch_start nil)
- )
- ((and (= (type pt) 'str)(= pt "close"))
- (if (not(vlax-curve-isClosed obj))
- (vla-put-closed obj 1))
- (setq ch_close t)
- )
- ((and (= (type pt) 'str)(= pt "open"))
- (if (vlax-curve-isClosed obj)
- (vla-put-closed obj 0))
- ;;; (setq ch_open t)
- )
- ) ;_ end of cond
- ) ;_ end of while
- ) ;_ end of progn
- ) ;_ end of if
- (sssetfirst nil)
- (princ)
- ) ;_ end of defun
|