Sub Example_InsertBlock()
' This example creates a block containing a circle.
' It then inserts the block.
' Create the block
Dim blockObj As AcadBlock
Dim insertionPnt(0 To 2) As Double
insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")
' Add a circle to the block
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)
' Insert the block
Dim blockRefObj As AcadBlockReference
insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0
Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
ZoomAll
End Sub
---------------------------------------------------------------------------------------------------------------------------------------------
This is the code for inserting block in the Model Space using COM API. In that you can ssee that while inserting block
we have to use array of double of size 3 insertionPnt(0 to 2)
So my question is while working with 2D, why 3rd CoOrdinate (Z-Coordinate) required ?
Let me correct If I am wrong then the need of double array of size 3 becuase we have 3 CoOrdinate (X,Y,Z) right ?
Does not matter you work 2d or 3d Autocad recognize a point X,Y and Z axis. You need to give as an input even if 0.
You may want to insert block a different Z you can use it. A developer must consider all choices that the user needs. If it is different in case of 2d and 3d it has more complicate to who use COM API. And also it is opposite to general programming logic because more met...
There is no such thing as "2D" in AutoCAD (outside of LWPOLYLINE objects). All coordinates are stored as three values (X Y Z). If there was a separate "2D space" then the programming has to be that much more complex to handle both systems instead of just one. Much easier, faster, fewer problems, etc. to use the same methods for both ways.
If its that much of a bother, you can always write your own "2D" methods which assume a Z-value of 0 and call those instead of the root AutoCAD ones.