Hi all,
I'm trying to construct a revolve sketch for a configurable shoulder screw using the code below for the lines.
When I go through the code line by line, the sketch executes perfectly, however, when I run the overall program the sketch does not build correctly (See images below, correct on the left and incorrect on the right)
The error seems to be occurring at "Thread Undercut Diameter". I have checked all values and they are correct, the lines are just not being constructed correctly.
I will attach the macro if anyone thinks they will require it for a diagnosis.
Set skSegment = Part.SketchManager.CreateLine(0, 0, 0, 0, HR, 0) 'Head
Set skSegment = Part.SketchManager.CreateLine(0, HR, 0, HL, HR, 0)
Set skSegment = Part.SketchManager.CreateLine(HL, HR, 0, HL, UR, 0) 'Head Undercut
Set skSegment = Part.SketchManager.CreateLine(HL, UR, 0, (HL + UL), UR, 0)
Set skSegment = Part.SketchManager.CreateLine((HL + UL), UR, 0, (HL + UL), SR, 0) 'Shoulder
Set skSegment = Part.SketchManager.CreateLine((HL + UL), SR, 0, (HL + SL), SR, 0)
Set skSegment = Part.SketchManager.CreateLine((HL + SL), SR, 0, (HL + SL), TUR, 0) 'Thread Undercut Diameter
Set skSegment = Part.SketchManager.CreateLine((HL + SL), TUR, 0, (HL + SL + TUL), TUR, 0) 'Thread Undercut Length
Set skSegment = Part.SketchManager.CreateLine((HL + SL + TUL), TUR, 0, (HL + SL + TUL), TR, 0) 'Thread Diameter
Set skSegment = Part.SketchManager.CreateLine((HL + SL + TUL), TR, 0, (HL + SL + TL), TR, 0) 'Thread Length
Set skSegment = Part.SketchManager.CreateLine((HL + SL + TL), TR, 0, (HL + SL + TL), 0, 0)
Set skSegment = Part.SketchManager.CreateLine((HL + SL + TL), 0, 0, 0, 0, 0)
Any help would be great!
Cheers
SolidworksApi macros