Message 1 of 5
nested block? add blocks together

Not applicable
12-01-2007
02:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
need help with nested block,
I can create blocks like below or I can built one block of the combined
block definitions but I can't find out how to nest the block together.
The problem is each block consist of 20-30 parts and what I'd like to do is
create singular blocks and then combine them so if the combined block is
exploded the remain blocks will say intact.
thanks
John
Sub testblocks()
Dim BlockName1 As String
BlockName1 = "zblock1"
' Make point array for block's insertion point
Dim ptOrigin1(2) As Double
ptOrigin1(0) = 0#: ptOrigin1(1) = 0#: ptOrigin1(2) = 0#
' Create the block object
Dim Block As AcadBlock
Set Block = ThisDrawing.Blocks.Add(ptOrigin1, BlockName1)
' Make point arrays for lines
Dim pt1(2) As Double
pt1(0) = -1#: pt1(1) = -5.5: pt1(2) = 0#
Dim pt2(2) As Double
pt2(0) = -1#: pt2(1) = 5.5: pt2(2) = 0#
Dim pt3(2) As Double
pt3(0) = 1#: pt3(1) = 5.5: pt3(2) = 0#
Dim pt4(2) As Double
pt4(0) = 1#: pt4(1) = -5.5: pt4(2) = 0#
' Add the lines to the block's definition
Block.AddLine pt1, pt2
Block.AddLine pt2, pt3
Block.AddLine pt3, pt4
Block.AddLine pt4, pt1
Set BlockRef = ThisDrawing.ModelSpace.InsertBlock(ptOrigin1, BlockName1, 1#,
1#, 1#, 0#)
Dim BlockName2 As String
BlockName2 = "zblock2"
' Make point array for block's insertion point
Dim ptOrigin2(2) As Double
ptOrigin2(0) = 0#: ptOrigin2(1) = 0#: ptOrigin2(2) = 0#
' Create the block object
Set Block = ThisDrawing.Blocks.Add(ptOrigin2, BlockName2)
' Make point arrays for lines
Dim pt5(2) As Double
pt5(0) = 0#: pt5(1) = 0#: pt5(2) = 0#
Block.AddCircle ptOrigin2, 0.0833
Set BlockRef = ThisDrawing.ModelSpace.InsertBlock(ptOrigin2, BlockName2, 1#,
1#, 1#, 0#)
End Sub
I can create blocks like below or I can built one block of the combined
block definitions but I can't find out how to nest the block together.
The problem is each block consist of 20-30 parts and what I'd like to do is
create singular blocks and then combine them so if the combined block is
exploded the remain blocks will say intact.
thanks
John
Sub testblocks()
Dim BlockName1 As String
BlockName1 = "zblock1"
' Make point array for block's insertion point
Dim ptOrigin1(2) As Double
ptOrigin1(0) = 0#: ptOrigin1(1) = 0#: ptOrigin1(2) = 0#
' Create the block object
Dim Block As AcadBlock
Set Block = ThisDrawing.Blocks.Add(ptOrigin1, BlockName1)
' Make point arrays for lines
Dim pt1(2) As Double
pt1(0) = -1#: pt1(1) = -5.5: pt1(2) = 0#
Dim pt2(2) As Double
pt2(0) = -1#: pt2(1) = 5.5: pt2(2) = 0#
Dim pt3(2) As Double
pt3(0) = 1#: pt3(1) = 5.5: pt3(2) = 0#
Dim pt4(2) As Double
pt4(0) = 1#: pt4(1) = -5.5: pt4(2) = 0#
' Add the lines to the block's definition
Block.AddLine pt1, pt2
Block.AddLine pt2, pt3
Block.AddLine pt3, pt4
Block.AddLine pt4, pt1
Set BlockRef = ThisDrawing.ModelSpace.InsertBlock(ptOrigin1, BlockName1, 1#,
1#, 1#, 0#)
Dim BlockName2 As String
BlockName2 = "zblock2"
' Make point array for block's insertion point
Dim ptOrigin2(2) As Double
ptOrigin2(0) = 0#: ptOrigin2(1) = 0#: ptOrigin2(2) = 0#
' Create the block object
Set Block = ThisDrawing.Blocks.Add(ptOrigin2, BlockName2)
' Make point arrays for lines
Dim pt5(2) As Double
pt5(0) = 0#: pt5(1) = 0#: pt5(2) = 0#
Block.AddCircle ptOrigin2, 0.0833
Set BlockRef = ThisDrawing.ModelSpace.InsertBlock(ptOrigin2, BlockName2, 1#,
1#, 1#, 0#)
End Sub