nested block? add blocks together

nested block? add blocks together

Anonymous
Not applicable
333 Views
4 Replies
Message 1 of 5

nested block? add blocks together

Anonymous
Not applicable
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
0 Likes
334 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Something like this.....

Dim oBlock3 As AcadBlock

Set oBlock3 = ThisDrawing.Blocks.Add(ptOrigin1, "CombinedBlock")
oBlock3.InsertBlock Blk1InsertPt, oBlock1.Name, 1,1,1,0
oBlock3.InserBlock Blk2InsertPt, oBlock2.Name, 1,1,1,0

ThisDrawing.ModelSpace.InsertBlock Blk1InsPt, "CombinedBlock", 1,1,1,0


HTH,
Jeff

"Jcoon" wrote in message
news:5790110@discussion.autodesk.com...
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
0 Likes
Message 3 of 5

Anonymous
Not applicable
Jeff,

Long time since you last helped me,

I must be looking at this too long because I don't see why the error. will
look at this after dinner

Thanks
John

Sub testblocks()
Dim BlockName1 As String
BlockName1 = "zblock1"

Dim ptOrigin1(2) As Double
ptOrigin1(0) = 0#: ptOrigin1(1) = 0#: ptOrigin1(2) = 0#

Dim Block As AcadBlock
Set Block = ThisDrawing.Blocks.Add(ptOrigin1, BlockName1)
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"
Dim ptOrigin2(2) As Double
ptOrigin2(0) = 0#: ptOrigin2(1) = 0#: ptOrigin2(2) = 0#

Set Block = ThisDrawing.Blocks.Add(ptOrigin2, BlockName2)
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#)

'try to nest blocks
Set oBlock3 = ThisDrawing.Blocks.Add(ptOrigin1, "CombinedBlock")
oBlock3.InsertBlock ptOrigin1, BlockName1, 1, 1, 1, 0
oBlock3.InserBlock ptOrigin2, BlockName2, 1, 1, 1, 0 '
this is where is get an error and I don't see why

ThisDrawing.ModelSpace.InsertBlock ptOrigin2, "CombinedBlock", 1, 1, 1, 0

End Sub



























"Jeff Mishler" wrote in message
news:5790112@discussion.autodesk.com...
Something like this.....

Dim oBlock3 As AcadBlock

Set oBlock3 = ThisDrawing.Blocks.Add(ptOrigin1, "CombinedBlock")
oBlock3.InsertBlock Blk1InsertPt, oBlock1.Name, 1,1,1,0
oBlock3.InserBlock Blk2InsertPt, oBlock2.Name, 1,1,1,0

ThisDrawing.ModelSpace.InsertBlock Blk1InsPt, "CombinedBlock", 1,1,1,0


HTH,
Jeff

"Jcoon" wrote in message
news:5790110@discussion.autodesk.com...
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
0 Likes
Message 4 of 5

Anonymous
Not applicable
InserBlock << formatting is probably off and the 1's & 0's need to be doubles.....but other than that 🙂


"Jcoon" wrote in message news:5790162@discussion.autodesk.com...
Jeff,

Long time since you last helped me,

I must be looking at this too long because I don't see why the error. will
look at this after dinner
0 Likes
Message 5 of 5

Anonymous
Not applicable
Jeff,

what a bonehead I am. I was looking at that error for a half hour and did
see the typo, it might be time to lower my resolution on my monitor or get
newer glasses I guess.
Thanks as always for your help. Now the fun stuff building 40 different
light block arrays, this will take some time oh boy.

Have a great day,
John


is anyone is interested thanks to Jeff this sample works
Sub testblocks()
Dim BlockName1 As String
BlockName1 = "zblock1"

Dim ptOrigin1(2) As Double
ptOrigin1(0) = 0#: ptOrigin1(1) = 0#: ptOrigin1(2) = 0#

Dim Block As AcadBlock
Set Block = ThisDrawing.Blocks.Add(ptOrigin1, BlockName1)
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"
Dim ptOrigin2(2) As Double
ptOrigin2(0) = 0#: ptOrigin2(1) = 0#: ptOrigin2(2) = 0#

Set Block = ThisDrawing.Blocks.Add(ptOrigin2, BlockName2)
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#)

'try to nest blocks
Set oBlock3 = ThisDrawing.Blocks.Add(ptOrigin1, "CombinedBlock")
oBlock3.InsertBlock ptOrigin1, BlockName1, 1#, 1#, 1#, 0#
oBlock3.InsertBlock ptOrigin2, BlockName2, 1#, 1#, 1#, 0#
'


ThisDrawing.ModelSpace.InsertBlock ptOrigin2, "CombinedBlock", 1#, 1#, 1#,
0#

End Sub
















"Jeff Mishler" wrote in message
news:5790164@discussion.autodesk.com...
InserBlock << in the email window (no IDE) so the
formatting is probably off and the 1's & 0's need to be doubles.....but
other than that 🙂


"Jcoon" wrote in message
news:5790162@discussion.autodesk.com...
Jeff,

Long time since you last helped me,

I must be looking at this too long because I don't see why the error. will
look at this after dinner
0 Likes