I created a macro that creates a socket head cap screw (see attached)
Everything is working OK, except for the "cutting" sketch for the threads.
Here's the VBA code to create this sketch, where x is axial distance, and y is radial distance in the sketch
x1 = 0
x2 = 0
x3 = 0
x4 = 0
y1 = 0
y2 = 0
x1 = Pitch / 8 ' axial, upper left
x12 = Tan(30 * 3.14159 / 180) ' tangent of 30 degrees
x13 = 0.625 * H_thread * x12
x3 = x1 + x13 ' axial, lower left
x2 = x1 + (0.75 * H_thread * x12 * 2) ' axial, upper right
x4 = x3 + (Pitch * 0.25) ' axial, lower right
y1 = (Bolt_Diameter / 2) ' radial
y2 = (Bolt_Diameter / 2) - (H_thread * 0.875) ' radial
' across, at constant bolt diameter, line 1
Set skSegment = Part.SketchManager.CreateLine(x1, y1, 0#, x2, y1, 0#)
' down at angle, from initial point
Set skSegment = Part.SketchManager.CreateLine(x1, y1, 0#, x3, y2, 0#)
' short connecting segment
Set skSegment = Part.SketchManager.CreateLine(x3, y2, 0#, x4, y2, 0#)
' from far upper right, down at angle
Set skSegment = Part.SketchManager.CreateLine(x2, y1, 0#, x4, y2, 0#)
The resulting sketch is attached.
If y is radial distance, and there are only two y values, how does the resulting sketch have 3 radial values??
The end points of the lines are not even located on the calculated x,y values.
The calculated values are derived from the ANSI attachment.
The sketch looks identical, no matter how many times I run the macro.
Is this sketch error due to the precision of the model? Any other help would be appreciated.