GetSketchSegments problem

Hello everyone

I wanted to delete all construction lines in all sketches in a part

so as usual, I wrote code to traverse all features, and at every one of them I called this function:

Function deleteConstructionSketchSegments (swModel As SldWorks.ModelDoc2, swFeat As SldWorks.Feature)

Dim swSketch As SldWorks.Sketch

Set swSketch = swFeat.GetSpecificFeature2

swFeat.Select2 False, 0

swModel.EditSketch

Dim varSketchSegments As Variant

varSketchSegments = swSketch.GetSketchSegments

Dim swSketchSeg As SldWorks.SketchSegment

Dim lngCounter As Long

For lngCounter = 0 To UBound(varSketchSegments)

Set swSketchSeg = varSketchSegments(lngCounter)

If swSketchSeg.ConstructionGeometry Then

swSketchSeg.Select4 False, Nothing

swModel.EditDelete

End If

Next lngCounter

swModel.InsertSketch2 True

End Function

Every thing went well, until the function treated a sketch that has no segments at all, a points-sketch, where I got the message "Type mismatch".

So, any help on how to avoid that!

Thanks everyone

SolidworksApi/macros