你好。
在我做的一个例程中,我使用grread来捕获使用“escape”来取消选择,而不退出例程。我非常失望地看到(在AutoCAD 2015 sp2中),它偶尔会失败并退出。我发现,在2015年,如果轨迹参数为T,则逃逸陷阱很可能在使用逃逸的前1到3次中失败。当然,当grread用于提供动态预览时,需要Track参数。这是我的命令行,在第三次尝试aa和第二次尝试bb时显示bomb
如果轨迹参数为假,即使通常在让一个滑倒之前正确捕捉20-50次,它仍然会爆炸。我尝试了两种方法,都使用catch-all-apply,一种使用error-p来捕捉,另一种强制输入一个nil值。两种方法的结果相似。
你能试试(aa T)和(bb T)吗,然后试试垃圾邮件转义。请告诉我它是否有效或失败,以及您试用的产品/年份。(注意:使用Enter退出2个功能)
- ;http://www.theswamp.org/index.php?topic=27900.msg334947#msg334947
- ;_GetChar by mp modified to test grread escape traping
- (defun aa (track / done data key result);
- ;; return the character for the key pressed
-
- (while (not done)
- ;; stay in the loop until the user presses a key
- (vl-catch-all-apply
- '(lambda ( )
- (setq
- data nil
- data (grread track 14 1)
- )
- )
- )
- (setq
- key (car data)
- result (cadr data)
- )
- (cond
- ;; user pressed <esc>
- ((null data) (princ "\nescape"))
- ;; user pressed a key
- ((eq 2 key) (setq done t))
- ;; user hit right mouse button, consider same as enter
- ((eq 25 key)(setq done t result 13))
- )
- )
- (chr result)
- )
- ;http://www.theswamp.org/index.php?topic=27900.msg334940#msg334940
- ;test by cab modified to test grread escape traping
- ;originally (grread t 11 0). End up failing either if grread track argument is nil or t
- ;hit enter to exit
- (defun bb (track / input LastPT ent obj )
- (vl-load-com)
- (while ; stay in loop until one of the COND statements return nil
- (progn
- (setq input (vl-catch-all-apply 'grread (list track (+ 1 2 0)))
- (cond
- ((vl-catch-all-error-p input)
- (princ "\nPressed escape ")
- t ; exit
- )
- ((= 5 (car input)) ; pointing device
- (cond
- ((and LastPT (< (distance (cadr input) LastPT) 0.0001))) ; no update if same point
- ((setq ent (nentselp (setq LastPT (cadr input))))
- (setq obj (vlax-ename->vla-object (car ent)))
- (princ (strcat "\nFound a " (vla-get-objectname obj) " at "(vl-princ-to-string (cadr ent))))
- )
- )
- t ; stay in loop
- )
- ((= 2 (car input)) ; Keyboard input
- (princ (vl-prin1-to-string input))
- (if (= (cadr input) 13)
- nil ;exit loop
- t) ; stay in loop
- )
- ((= 3 (car input)) ; Selected 3d point
- (if (setq ent (nentselp (cadr input)))
- (progn
- (setq obj (vlax-ename->vla-object (car ent)))
- (princ (strcat "\nFound a " (vla-get-objectname obj) " at the point selected: "(vl-princ-to-string (cadr ent))))
- )
- )
- t ; stay in loop
- )
- )
- )
- ) ; while
- (princ)
- )
这个问题只在cad 2015中出现吗?(欢迎评论/建议) |