Using VBA to insert a block

Discussion in 'AutoCAD' started by MarkW, Jun 19, 2004.

  1. MarkW

    MarkW Guest

    Can anyone tell me why this code inserts the block twice and explodes only once?
    All the code should do is insert a one block, explode the block and zoom Extents.
    I can insert and explode this block manually and it works like it should.

    CODE --------------

    Option Explicit

    'This code inserts the Title/Border block "DMR-OFRAME".
    Public Sub InsertOframe()

    Dim BlockReference As AcadBlockReference 'Declares a variable named "BlockReference".
    Dim ExplodedObjects As Variant 'Declares a variable named "ExplodedObjects".

    'Declares an array for insert point coordinates for title block.
    Dim InputPoint(0 To 2) As Double 'Declares a variable named "InputPoint"
    InputPoint(0) = 0 'X
    InputPoint(1) = 0 'Y
    InputPoint(2) = 0 'Z

    'The [NAME] of the block should include the path with the ".dwg" extension on the end.
    Set BlockReference = ThisDrawing.ModelSpace.InsertBlock(InputPoint, "C:\DRAWINGS\Designer DMR-UPU\Rev 6\DMR-OFRAME.dwg", 1#, 1#, 1#, 0#)

    'Calls the "Update" method of the "BlockReference" to ensure that the block was drawn in Model Space.
    BlockReference.Update

    'Explodes the title block -
    ExplodedObjects = BlockReference.Explode

    'Zooms to extents of drawing
    ZoomExtents

    End Sub
     
    MarkW, Jun 19, 2004
    #1
  2. MarkW

    greg hoyt Guest

    i haven't used the explode method before, but perhaps it doesn't delete
    the block reference, just creates the new exploded entities, and leaves
    it to the programmer to delete the original block reference.
     
    greg hoyt, Jun 19, 2004
    #2
  3. MarkW

    Jeff Mishler Guest

    This is exactly how the explode function works......

    Jeff
     
    Jeff Mishler, Jun 19, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.