李,如果找不到障碍物,我相信你的常规动作会摇摆不定。
当我不打算在我的例程中进行用户交互(允许用户选择文件夹、文件等)时(即使这样,我在大多数情况下也会考虑过度杀戮,即我通常会尽可能快地使例程失败。如下面最后一个示例所示)。然而,当我设计一个用于用户交互的应用程序时,你可以指望至少还有100行左右,只是为了让它有点防爆。
- (defun blockp ( bn )
- ;;
- ;; blockp
- ;; return ``location'' for a block search.
- ;;
- ;; if block is in dwg. returns ``dwg''
- ;; if block is found in paths returns
- ;; ``path to dwg''
- ;; if not found, returns ``nil''
- (cond
- ((tblsearch "BLOCK" bn) 'dwg)
- ((findfile (strcat bn ".dwg")))) )
- ( (lambda ( block-to-insert file-to-get-block-from )
- (cond
- ( (or
- (tblsearch "BLOCK" block-to-insert)
- (ObjectDBX-copyblockfromdrawing file-to-get-block-from block-to-insert)
- )
- (command "insert" block-to-insert PAUSE "" "")
- (while (eq (logand (getvar "CMDACTIVE")) 1)
- (command PAUSE))
- )
- ( T
- (princ "\n\nUnable to locate block"))))
- "BlockThatDoesntExistInDrawing"
- "c:\\Drawing.dwg")
|