Explode Block Refs?

Discussion in 'AutoCAD' started by Kwnart, Feb 2, 2004.

  1. Kwnart

    Kwnart Guest

    I've been trying to figure out how to do this for about 2 weeks now. I've got a VB program that inserts blocks via blockreference. After all the blocks are in place, I want to explode them. It works if I put in an .explode and .delete command after each and blockref insertion. I'd rather have a function that comes in after all the blocks are placed and explode them.

    Here is some of the code I have for insertion
    Dim BlockReference As AcadBlockReference
    Dim InputPoint(0 To 2) As Double
    'insert basic cabinet
    InputPoint(0) = 147.59871
    InputPoint(1) = 47.479348
    Set BlockReference = ThisDrawing.ModelSpace.InsertBlock(InputPoint, "steri93basic.dwg", 1#, 1#, 1#, 0#)


    Now here is the function I wrote to explode all the blocks. I keep getting a type mismatch with this set up I can't figure out how to get rid of...

    Private Sub Explode()
    Dim BlockReference As AcadBlockReference
    Dim i As Integer
    Dim scount As Integer

    scount = ThisDrawing.Blocks.count - 1
    ReDim ExpObj(0 To scount) As Variant

    For Each BlockReference In ThisDrawing.ModelSpace
    ExpObj(i) = BlockReference.Explode
    BlockReference.Delete
    i = i + 1
    Next

    End Sub


    Any suggestions would be greatly appreciated!

    Rich
     
    Kwnart, Feb 2, 2004
    #1
  2. Kwnart

    developer Guest

    Use a variable of type Variant to recieve the objects returned by the Explode method, since there can be any number of objects returned. Also, when using an Explode method, the original object will remain underneath the newly created objects. Try making the ExpObj a Variant in your code and you'll see what I mean.
     
    developer, Feb 2, 2004
    #2
  3. Kwnart

    Rob_Kish Guest

    Do not believe 'For Each' will work for AcadBlockReference. Either
    filter for BlkRefs (FilterValue = "INSERT") or change loop to For Each
    objEnt In ThisDrawing.ModelSpace, If TypeOf objEnt = AcadBlockReference
    Then, Set BlockReference = objEnt, ... , End If


    --
    Rob_Kish - I'm the Spartacus of VBA!

    'my vbd journal' (http://tinyurl.com/ypt2v)

    -the truth of a proposition is not related to its credibility ...
    and vice versa.- --lazarus long
     
    Rob_Kish, Feb 2, 2004
    #3
  4. Kwnart

    developer Guest

    Sorry, I meant ExpObj should be a Variant as opposed to the array of Variants in your sample code.
     
    developer, Feb 2, 2004
    #4
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.