InsertBlock method example

Sub Example_InsertBlock()

' This example creates a block containing a line and an circle

' and adds it to the Blocks collection. It then inserts the block. 

    ' Create the block and add it to the Blocks collection

    Dim sBlockName As String

    sBlockName = InputBox("Type a block name")

    Dim insPt(0 To 2) As Double: insPt(0) = 4: insPt(1) = 3

    Dim blockObj As AcadBlock

    Set blockObj = ThisDrawing.Blocks.Add(insPt, sBlockName)

    ' Add a line to the block

    Dim myStartPt(0 To 2) As Double: myStartPt(0) = 4: myStartPt(1) = 4

    Dim myEndPt(0 To 2) As Double: myEndPt(0) = 7: myEndPt(1) = 1

    blockObj.AddLine myStartPt, myEndPt

    ' Add a circle to the block

    Dim cenPt(0 To 2) As Double: cenPt(0) = 3: cenPt(1) = 4

    Dim dRadius As Double: dRadius = 1

    blockObj.AddCircle cenPt, dRadius

    ' Insert a instance of the block

    Dim blockRefObj As AcadBlockReference

    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insPt, sBlockName, 1, 1, 1, 0)

    MsgBox "The block " & sBlockName & " has been inserted."

End Sub


Bricscad™ is commercialized by Bricsys NV. Bricsys NV and Vondle NV are fully owned subsidiaries of Menhirs NV. © 2001- Menhirs NV - All rights reserved.