insert blocks via combobox

insert blocks via combobox

Anonymous
Not applicable
295 Views
1 Reply
Message 1 of 2

insert blocks via combobox

Anonymous
Not applicable
Hello guys,

I'm beginning a project where I need to insert certain blocks depending on what selection is made in a combobox.
The items in the combobox do not match the names of the blocks.
For example, The combo box contains Red, White, Blue, Green.
Red will insert BlockA .
White will insert BlockB.
Blue will insert BlockC
Green will insert BlockD

What is the best way to accomplish this? I'm new to VBA and I am certainly unfamiliar with inserting blocks.

As always, any advice is greatly appreciated.

Thanks,

Xi
0 Likes
296 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Hai , this it can help u

if comobobox.selelcteditem ="red" then
insert block a''For this see autocad help in "Insert Block"
end if


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
0 Likes