;;;从AutoCAD 2013 Active Reference帮助中code Examples中提取 ;;;本源代码由 xshrimp 2013.2.20 搜集整理,版权归原作者所有! (vl-load-com) (defun c:Example_Rows() ;; This example creates a new MInsertBlock in the current drawing and ;; displays the column and row information for the new MInsertBlock (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Define the Circle object (setq centerPoint (vlax-3d-point 0 0 0) InsertPoint (vlax-3d-point 1 1 0) radius 0.5) ;; Create a new block to hold the Circle (setq newBlock (vla-Add (vla-get-Blocks doc) centerPoint "CBlock")) ;; Add the Circle object to the new block (setq circleObj (vla-AddCircle newBlock centerPoint radius)) ;; Create a rectangular array of Circles using the new block containing the Circle ;; and the AddMInsertBlock method (setq modelSpace (vla-get-ModelSpace doc)) (setq newMBlock (vla-AddMInsertBlock modelSpace InsertPoint "CBlock" 1 1 1 1 2 2 1 1)) (vla-ZoomAll acadObj) ;; Display information about the Columns and Rows defined by the MInsertBlock (alert (strcat "The new rectangular array comprises: \n" (itoa (vla-get-Columns newMBlock)) " columns with a spacing of " (rtos (vla-get-ColumnSpacing newMBlock) 2) " and\n" (itoa (vla-get-Rows newMBlock)) " rows with a spacing of " (rtos (vla-get-RowSpacing newMBlock) 2) ".")) )