明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3202|回复: 2

vla-copyobject怎么使用?

[复制链接]
发表于 2003-7-1 11:52:00 | 显示全部楼层 |阅读模式
vla-copyobject怎么使用?
请给例
发表于 2003-7-1 12:44:00 | 显示全部楼层
;; COPYBLOCK.LSP  Copyright ?999  Tony Tanzillo
;;
;; AutoCAD 2000  Visual LISP / ObjectDBX Example
;;
;;   http://www.caddzone.com
;;   tony.tanzillo@caddzone.com
;;
;; This example demonstrates how to use ObjectDBX in
;; Visual LISP to directly add blocks defined in any
;; drawing file, to the current drawing.
;;
;; (CopyBlock <FileName> <BlockName>)
;;
;; This function copies the definition of the
;; block whose name is <BlockName> (a string),
;; from the .DWG file whose name is <FileName>
;; (a string), into the current drawing's block
;; table.
;;
;; CopyBlock returns the new copy of the block
;; object in the current drawing's block table.
;;
;; Note that this example performs none of the
;; error checking that is required, and does not
;; attempt to determine what actually happened
;; within the deep clone operation.

(vl-load-com)

(setq *acad* (vlax-get-acad-object))

(defun CopyBlock (DwgName BlkName / blocks dbxDoc)

   (setq blocks
      (vla-get-blocks
         (vla-get-ActiveDocument *acad*)
      )
   )
   
   (setq dbxDoc
      (vla-GetInterfaceObject
         *acad*
         "ObjectDBX.AxDbDocument"
      )
   )
   
   (vla-open dbxDoc DwgName)
   
   (vla-CopyObjects
      dbxDoc
      (vlax-safearray-fill
         (vlax-make-safearray
            vlax-vbObject
           '(0 . 0)
         )
         (list
            (vla-item
               (vla-get-blocks dbxDoc)
               BlkName
            )
         )
      )
      blocks
   )
   
   (vlax-release-object dbxDoc)
   
   (vla-item blocks BlkName)

)      

(princ "\n(CopyBlock <DrawingFileName> <BlockName>)")

(princ)

;;;;;;;;;;;;;;;;;  CopyBlock.lsp ;;;;;;;;;;;;;;;;;;;;
发表于 2012-10-24 10:30:07 | 显示全部楼层
龙龙仔 发表于 2003-7-1 12:44
;; COPYBLOCK.LSP  Copyright ?999  Tony Tanzillo
;;
;; AutoCAD 2000  Visual LISP / ObjectDBX Examp ...

超版就是厉害呀!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-9-26 03:14 , Processed in 0.189160 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表