Explode Objects

AutoCAD ActiveX

 
Explode Objects
 
 
 

Exploding objects converts the objects from single objects to their constituent parts but has no visible effect. For example, exploding forms simple lines and arcs from 3D polygons, polylines, polygon meshes, and regions. It replaces a block reference with copies of the simple objects that compose the block.

For more information about exploding objects, see “Disassociate Compound Objects (Explode)” in the User's Guide.

Explode a polyline

This example creates a lightweight polyline object. It then explodes the polyline into separate objects. The example then loops through the resulting objects and displays a message box containing the name of each object and its index in the list of exploded objects.

Sub Ch4_ExplodePolyline()
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 11) As Double
      
    ' Define the 2D polyline points
    points(0) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
    points(10) = 4: points(11) = 1
      
    ' Create a light weight Polyline object
    Set plineObj = ThisDrawing.ModelSpace. _
 AddLightWeightPolyline(points)
      
    ' Set the bulge on one segment to vary the
    ' type of objects in the polyline
    plineObj.SetBulge 3, -0.5
    plineObj.Update
      
    ' Explode the polyline
    Dim explodedObjects As Variant
    explodedObjects = plineObj.Explode
      
    ' Loop through the exploded objects
    ' and display a message box with
    ' the type of each object
    Dim I As Integer
    For I = 0 To UBound(explodedObjects)
    explodedObjects(I).Update
        MsgBox "Exploded Object " & I & ": " & _
 explodedObjects(I).ObjectName
        explodedObjects(I).Update
    Next
End Sub