大家好,
我想用这个lisp来插入块,但我想用另一种方式——我想在我的工具栏上做一个图标,你的lisp和dcl一起工作。我不需要这个dcl,我想做一个宏。。。你能帮我吗?这就是我说的例行公事。。。
谢谢
- ;;----------------------=={ Copy Block }==--------------------;;
- ;; ;;
- ;; Copies the specified block definition from the specified ;;
- ;; filename to the ActiveDocument using a deep clone ;;
- ;; operation (Method inspired by Tony Tanzillo) ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; block - string specifying block name to copy ;;
- ;; filename - filename of drawing from which to copy block ;;
- ;;------------------------------------------------------------;;
- ;; Returns: Block definition in ActiveDocument, else nil ;;
- ;;------------------------------------------------------------;;
- (defun LM:CopyBlock ( block filename / acapp acdoc acblk acdocs dbxDoc item )
- (vl-load-com)
- ;; © Lee Mac 2010
- (setq acapp (vlax-get-acad-object)
- acdoc (vla-get-ActiveDocument acapp)
- acblk (vla-get-Blocks acdoc))
- (vlax-map-collection (vla-get-Documents acapp)
- (function
- (lambda ( doc )
- (setq acdocs
- (cons
- (cons (strcase (vla-get-fullname doc)) doc) acdocs
- )
- )
- )
- )
- )
- (if
- (and
- (not (LM:Itemp acblk block))
- (setq filename (findfile filename))
- (not (eq filename (vla-get-fullname acdoc)))
- (or
- (setq dbxDoc (cdr (assoc (strcase filename) acdocs)))
- (progn
- (setq dbxDoc (LM:ObjectDBXDocument))
- (not
- (vl-catch-all-error-p
- (vl-catch-all-apply 'vla-open (list dbxDoc filename))
- )
- )
- )
- )
- (setq item (LM:Itemp (vla-get-Blocks dbxDoc) block))
- )
- (vla-CopyObjects dbxDoc
- (vlax-make-variant
- (vlax-safearray-fill
- (vlax-make-safearray vlax-vbObject '(0 . 0)) (list item)
- )
- )
- acblk
- )
- )
-
- (and dbxDoc (vlax-release-object dbxDoc))
- (LM:Itemp acblk block)
- )
- ;;-----------------=={ ObjectDBX Document }==-----------------;;
- ;; ;;
- ;; Retrieves a version specific ObjectDBX Document object ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: - None - ;;
- ;;------------------------------------------------------------;;
- ;; Returns: VLA ObjectDBX Document object, else nil ;;
- ;;------------------------------------------------------------;;
- (defun LM:ObjectDBXDocument ( / acVer )
- ;; © Lee Mac 2010
- (vla-GetInterfaceObject (vlax-get-acad-object)
- (if (< (setq acVer (atoi (getvar "ACADVER"))) 16)
- "ObjectDBX.AxDbDocument"
- (strcat "ObjectDBX.AxDbDocument." (itoa acVer))
- )
- )
- )
- ;;-----------------------=={ Itemp }==------------------------;;
- ;; ;;
- ;; Retrieves the item with index 'item' if present in the ;;
- ;; specified collection, else nil ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; coll - the VLA Collection Object ;;
- ;; item - the index of the item to be retrieved ;;
- ;;------------------------------------------------------------;;
- ;; Returns: the VLA Object at the specified index, else nil ;;
- ;;------------------------------------------------------------;;
- (defun LM:Itemp ( coll item )
- ;; © Lee Mac 2010
- (if
- (not
|