Explode method copies objects?

Explode method copies objects?

Anonymous
Not applicable
391 Views
3 Replies
Message 1 of 4

Explode method copies objects?

Anonymous
Not applicable
Hi all,

I have the following code that I am using to explode LWpolylines. If I run
the code and check the drawing, I find that the original polyline is
exploded (now seperate line segments) and a new duplicate polyline appears
in the exact same spot as the original. Am I doing something wrong or doing
something that would cause it to "copy" the polyline or is this a
function/problem with the explode method?

Public Sub DrawingScrub()

Dim Response As Variant
Dim Ent As AcadEntity
Dim objLwPoly As AcadLWPolyline
Dim objBlock As AcadBlockReference

Response = MsgBox("This macro will explode ALL objects and place ALL objects
on the 0 (zero) layer." & _
" Do you wish to continue?", vbYesNo, "Drawing Scrub")

If Response = vbYes Then
For Each Ent In ThisDrawing.ModelSpace
If TypeOf Ent Is AcadLWPolyline Then
Set objLwPoly = Ent
objLwPoly.Explode
End If
Next Ent
Else
Exit Sub
End If

End Sub

TIA,

Rob
0 Likes
392 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi Rob,

It's what's known as false advertising. In the traditional sense,
the Explode method does not explode the object but rather it
creates copies of each of its constitiuent parts. You're not doing
anything wrong, so please, do not adjust your set!

Joe
0 Likes
Message 3 of 4

Anonymous
Not applicable
Rob

The explode method doesn't change the original object. Explode returns an
array with all subobjects of the referenced object, eg.:

Dim EntCnt As Integer
Dim ExpObj As Variant
Dim CurEnt As AcadEntity

ExpObj = YourObject.Explode
For EntCnt = LBound(ExpObj) To UBound(ExpObj)
Set CurEnt = ExpObj(EntCnt)
With CurEnt
...DoYourStuff
.Delete 'if necessary, delete the subobject after processing
End With
Next EntCnt

Cheers
--
Juerg Menzi
MENZI ENGINEERING GmbH, Switzerland
http://www.menziengineering.ch


Rob Outman schrieb:
>
> Hi all,
>
> I have the following code that I am using to explode LWpolylines. If I run
> the code and check the drawing, I find that the original polyline is
> exploded (now seperate line segments) and a new duplicate polyline appears
> in the exact same spot as the original. Am I doing something wrong or doing
> something that would cause it to "copy" the polyline or is this a
> function/problem with the explode method?
>
> Public Sub DrawingScrub()
>
> Dim Response As Variant
> Dim Ent As AcadEntity
> Dim objLwPoly As AcadLWPolyline
> Dim objBlock As AcadBlockReference
>
> Response = MsgBox("This macro will explode ALL objects and place ALL objects
> on the 0 (zero) layer." & _
> " Do you wish to continue?", vbYesNo, "Drawing Scrub")
>
> If Response = vbYes Then
> For Each Ent In ThisDrawing.ModelSpace
> If TypeOf Ent Is AcadLWPolyline Then
> Set objLwPoly = Ent
> objLwPoly.Explode
> End If
> Next Ent
> Else
> Exit Sub
> End If
>
> End Sub
>
> TIA,
>
> Rob
0 Likes
Message 4 of 4

Anonymous
Not applicable
Thanx guys,

This makes much more sense now!

Rob

"Jürg Menzi" wrote in message
news:[email protected]...
> Rob
>
> The explode method doesn't change the original object. Explode returns an
> array with all subobjects of the referenced object, eg.:
>
> Dim EntCnt As Integer
> Dim ExpObj As Variant
> Dim CurEnt As AcadEntity
>
> ExpObj = YourObject.Explode
> For EntCnt = LBound(ExpObj) To UBound(ExpObj)
> Set CurEnt = ExpObj(EntCnt)
> With CurEnt
> ...DoYourStuff
> .Delete 'if necessary, delete the subobject after processing
> End With
> Next EntCnt
>
> Cheers
> --
> Juerg Menzi
> MENZI ENGINEERING GmbH, Switzerland
> http://www.menziengineering.ch
>
>
> Rob Outman schrieb:
> >
> > Hi all,
> >
> > I have the following code that I am using to explode LWpolylines. If I
run
> > the code and check the drawing, I find that the original polyline is
> > exploded (now seperate line segments) and a new duplicate polyline
appears
> > in the exact same spot as the original. Am I doing something wrong or
doing
> > something that would cause it to "copy" the polyline or is this a
> > function/problem with the explode method?
> >
> > Public Sub DrawingScrub()
> >
> > Dim Response As Variant
> > Dim Ent As AcadEntity
> > Dim objLwPoly As AcadLWPolyline
> > Dim objBlock As AcadBlockReference
> >
> > Response = MsgBox("This macro will explode ALL objects and place ALL
objects
> > on the 0 (zero) layer." & _
> > " Do you wish to continue?", vbYesNo, "Drawing Scrub")
> >
> > If Response = vbYes Then
> > For Each Ent In ThisDrawing.ModelSpace
> > If TypeOf Ent Is AcadLWPolyline Then
> > Set objLwPoly = Ent
> > objLwPoly.Explode
> > End If
> > Next Ent
> > Else
> > Exit Sub
> > End If
> >
> > End Sub
> >
> > TIA,
> >
> > Rob
0 Likes