本帖最后由 酷酷提 于 2022-6-7 17:08 编辑
小毛草 发表于 2021-11-25 08:39
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;窗开启方向;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:CBB (/ *error* ...
老师,请教一下,这个代码会把对象捕捉全部清空,我在代码上面增加了几个备份的命令,怎么还是会清空呢,而且不能备份
- (defun c:CBB()
- ;; 下一条指令为 备份对象捕捉设置
- (setq old (getvar "OSMODE"))
- ;; 下一条指令为 取消和清空对象捕捉
- (setvar "osmode" 0)
- (vl-load-com)
- (setq cmd (getvar "cmdecho"))
- (setq osm (getvar "osmode"))
- (setvar "cmdecho" 0)
- (setvar "osmode" 0)
- (command "_undo" "be")
- (while (setq ssa (ssget ":S" '((0 . "LWPOLYLINE"))))
- (setq entx (car (ssnamex ssa)))
- (setq obj (vlax-ename->vla-object (cadr entx)))
- (setq pae (vlax-curve-getendparam obj))
- (if (or (and (= pae 4.0) (= (vlax-curve-isClosed obj) t))
- (and (= pae 4.0) (equal (vlax-curve-getstartpoint obj) (vlax-curve- getendpoint obj))))
- (progn
- (setq pt (cadr (last entx)))
- (setq pt0 (vlax-curve-getclosestpointto obj pt))
- (setq par (vlax-curve-getparamatpoint obj pt0))
- (setq pai (fix par))
- (setq pai-1 (- pai 1.0))
- (if (< pai-1 0.0) (setq pai-1 (+ pai-1 pae)))
- (setq pai+1 (+ pai 2.0))
- (if (> pai+1 pae) (setq pai+1 (- pai+1 pae)))
- (setq pmid (vlax-curve-getpointatparam obj (+ pai 0.5)))
- (setq pt1 (vlax-curve-getpointatparam obj pai-1))
- (setq pt2 (vlax-curve-getpointatparam obj pai+1))
- (command "_pline" pt1 pmid pt2 ""))
- (alert "你所选取的不由4点组成的闭合矩形!")))
- (command "_undo" "e")
- (setvar "osmode" osm)
- (setvar "cmdecho" cmd)
- ;; 下一条指令为 恢复对象捕捉设置
- (setvar "OSMODE" old)
- (princ))
|