I have a line in a sketch, it could be a 2d or 3d sketch having a either a line, arc, or spline, which I need to get the endpoints of. I have a sub, createPatternedArray sketchCurve which I pass the sketch to. I was reading that there are multiple types of SketchSegments, which is why I set sksegment = to the selection, vseg, in question.
In my model I select my sketchsegment and get the sketch it belongs to using. In my first run through, the sketchsegment was a spline.
set curve_sel=swSelMgr.GetSelectedObject6(1,-1)
set sketchCurve=curve_sel.GetSketch
The sub is setup as follows:
createPatterenedArray(path_sketch)
Dim vsegs as Variant
Dim vseg as Variant
Dim sksegment as SldWorks.SketchSegment
Dim swsketchCurrLine as SldWorks.SketchLine
Dim swCurveStartPt as SldWorks.SketchPoint
Dim swCurveEndPt as SldWorks.SketchPoint
vseg = path_sketch.GetSketchSegments
For Each vseg In vsegs
Set sksegment = vseg
'sksegment.Select True
Set swsketchCurrLine = sksegment
Set swCurveStartPt = swsketchCurrLine.GetStartPoint2
Set swCurveEndpt = swsketchCurrLine.GetEndPoint2
Next vseg
'OTHER CODE WRITTEN HERE'
end sub
I get a Run-time error "Object variable of With block variable not set" and it points to
Set swCurveStartPt = swsketchCurrLine.GetStartPoint2.
The locals window shows that vsegs has an object in it and sksegment is showing that something got set to it. However, swsketchCurrLine is showing "Nothing". I get the same result if I change the sketchsegment from a spline to a line. Where am I messing up? Do I have to set up special cases if it's a spline, line, or arc?