这就是我使用的参考资料。
我希望它能帮助你。
http://www.afralisp.net/archive/methods/lista/insertblock_method.htm
- (defun c:test ()
- ;---------------{sub function}---------------;
-
- (defun insBlock (
- _blkName ;string
- _scaleX ;real
- _scaleY ;real
- _scaleZ ;real
- _rotation ;real
- /
- _blkInsertPoint
- *error*
- )
- (defun *error* (errmsg)
- (princ "\nAn error has occurred in the programme.\n ")
- (prompt errmsg)
- (princ)
- ) ;_ >defun
- (setq thisdrawing
- (vla-get-activedocument
- (vlax-get-acad-object)
- ) ;_ >vla-get-activedocument
- ) ;_ >setq
- (setq mspace (vla-get-modelspace thisdrawing))
-
- (setq util (vla-get-utility thisdrawing))
- (if (not (tblsearch "BLOCK" _blkName))
- (if
- (and
- (setq filePath (findfile (strcat _blkName ".dwg")))
- (progn (command "_.-insert" filePath nil) t)
- ) ;_ >and
- (setq blkFlag t)
- (setq blkFlag nil)
- ) ;_ >if
- (setq blkFlag t)
- ) ;_ >if
- (if blkFlag
- (progn
- (setq _blkInsertPoint (vla-GetPoint util nil "\nInsertion Point: "))
- (setq vla-obj
- (vla-insertblock
- mspace
- _blkInsertPoint
- _blkName
- _scaleX
- _scaleY
- _scaleZ
- _rotation
- ) ;_ >vla-insertblock
- ) ;_ >setq
- (redraw (entlast) 1)
- vla-obj
- ) ;_ >progn
- (alert "Block not found.")
- ) ;_ >if
- ) ;_ >defun
- ;---------------{sub function}---------------;
- (setq vla-obj ;get-vlaObject
- (insBlock ;call sub function
- "blkName" ;your block name
- 1.0 ;scale x
- 1.0 ;scale y
- 1.0 ;scale z
- 0.0 ;rotation
- ) ;_ >insBlock
- ) ;_ >setq
- ) ;_ >defun
|