另一个例子:
- (defun c:test ( / block point )
- (setq block "test.dwg")
- (setq point '(0.0 0.0 0.0))
- (if (setq block (LM:ForceBlockDefinition block))
- (entmake
- (list
- (cons 0 "INSERT") (cons 2 block) (cons 10 point)
- )
- )
- (princ "\n** Block not Found **")
- )
- (princ)
- )
- ;;---------------=={ Force Block Definition }==---------------;;
- ;; ;;
- ;; Ensures, if possible, that a block definition is present ;;
- ;; in a drawing. ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, June 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; block - block name or filename ;;
- ;;------------------------------------------------------------;;
- ;; Returns: Block name, else nil ;;
- ;;------------------------------------------------------------;;
- (defun LM:ForceBlockDefinition ( block / path ext base )
- (vl-load-com)
- ;; © Lee Mac 2010
- (setq path (vl-filename-directory block)
- ext (vl-filename-extension block)
- base (vl-filename-base block))
- (and (eq "" ext) (setq ext ".dwg"))
- (or (eq "" path) (setq path (strcat path "\")))
-
- (cond
- ( (tblsearch "BLOCK" base) base )
- ( (setq block (findfile (strcat path base ext)))
- (command "_.-insert" block) (command) base
- )
- )
- )
|