Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert block in ModelSpace through VBA?

Status
Not open for further replies.

spown

Electrical
Joined
May 28, 2005
Messages
9
Location
BG
First excuse me for my english! It's posible to written stupid things some times.
I'm using VBA for Autocad from month ago. I was written a program to put block with attribute, but the command Thisdrawing.Sendcommand dos't work and do not now why.
Please help!
 
try to avoid using the Sendcommand function
take a look at the InsertBlock example in the Help files
Code:
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 a much better way to insert a block using VBA


 
Thank you for the help. I will attempt to avoid SendCommadn function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top