Exploding Solids in VBA

Discussion in 'AutoCAD' started by D Hartley, Apr 15, 2004.

  1. D Hartley

    D Hartley Guest

    Am I missing something, or is it not possible to explode a 3d Solid into
    regions using VBA? The help file says

    3DPolyline , BlockRef, LightweightPolyline, MInsertBlock, Polygonmesh,
    Polyline, Region
    The object or objects this method applies to.



    David
     
    D Hartley, Apr 15, 2004
    #1
  2. D Hartley

    wivory Guest

    Sadly you're not mistaken - there is no native method to explode 3d solids. However I have been able to use code such as the following:
    [pre]
    PrevCount = ThisDrawing.ModelSpace.Count
    ThisDrawing.SendCommand "explode" & vbCr & "L" & vbCr & vbCr
    RegionCount = ThisDrawing.ModelSpace.Count - PrevCount
    ReDim Region(1 To RegionCount)
    For I% = 1 To RegionCount
    Set Region(I%) = ThisDrawing.HandleToObject(ThisDrawing.ModelSpace.Item(PrevCount + I%).Handle)
    Next I%
    [/pre]
    Regards

    Wayne Ivory
    IT Analyst Programmer
    Wespine Industries Pty Ltd
     
    wivory, Apr 16, 2004
    #2
  3. D Hartley

    D Hartley Guest

    That's ingenious, Wayne. One question, though. Does this require the user
    to select the 3dsolid first, or can you select it using code?

    Thanks,
    David
     
    D Hartley, Apr 16, 2004
    #3
  4. D Hartley

    wivory Guest

    Sorry, I should have clarified. In my case I am exploding a solid that was just created so my code sends an "L" for "Last entity created" to the explode command's "select an entity to explode" request.

    If your entity is not a "recent" creation I suppose one way you could work around this is to use the Copy method on it and then you would have a brand new entity to expode.

    Regards

    Wayne
     
    wivory, Apr 19, 2004
    #4
  5. D Hartley

    wivory Guest

    Oops. I did the code from memory and I just realised I didn't allow for the fact that although we have extra Region objects, we have one less solid object. You'll need to add one to the RegionCount and adjust the array subscript accordingly.

    Regards

    Wayne
     
    wivory, Apr 19, 2004
    #5
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.