块对象指Blocks集合对象和Block对象,Blocks对象包含一个图形文档中的所有命名的图块,Block对象则包含构成一个图块的所有实体对象,块对象的创建与引用包含3个步骤:用块对象的Add方法创建一个命名块,向块对象添加实体,用InsertBlock方法将该块插入到任何地方,即引用块。
下面的代码创建一个块对象,并向块中添加一个圆,然后在不同位置插入该块对象。
Private Sub Command1_Click()
Dim blockobj As AcadBlock
Dim insertionpnt(0 To 2) As Double
insertionpnt(0) = 0#: insertionpnt(1) = 0#: insertionpnt(2) = 0#
Set blockojb = acadapp.ActiveDocument.Blocks.Add(insertionpnt, "circleblock")
Dim circleobj As AcadCircle
Dim center(0 To 2) As Double
Dim radius As Double
center(0) = 0: center(1) = 0: center(2) = 0
radius = 1
Set circleobj = blockobj.AddCircle(center, radius)
Dim blockrefobj As AcadBlockReference
Set blockrefobj = acadapp.ActiveDocumen