Issue setting the TangentPolarDirection of a 3D spline handle with VBA. In VBA solidworks is only allowing a max setting of 45° (.785398 radians). When trying to set a value above this solidworks ignores the value. In my case I need to set this to 90° (1.57 radians). Within the solidworks program you can set the tangent polar direction setting to 1.57 with in the spline settings and it works correctly.
Just seeing if anyone else has seen this issue? Or am I missing something? Running solidworks 2022.
Example code. Just sketch a 3d spline with more than 4 points in this case and the 4th point should change to 90° but it only will go to 45°. Spline will need to be in the edit mode.
Dim swApp As Object
Sub main()
Set swApp = Application.SldWorks
Dim longstatus As Long, longwarnings As Long
Dim swSelMgr As SldWorks.SelectionMgr
Dim swSpline As SldWorks.SketchSpline
Dim skSegment As SldWorks.SketchSegment
Dim swSplineHandle As Variant
Dim angleDeg As Double
Dim angleRad As Double
Dim c As Integer
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swModelDocExt = swModel.Extension
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Spline1", "SKETCHSEGMENT", -0.263278726281002, 3.66283743989145E-02, 1.35835575022665, False, 0, Nothing, 0)
Set swSpline = swSelMgr.GetSelectedObject6(1, 0)
' Get the handles on the spline
swSplineHandle = swSpline.GetSplineHandles()
i = 0
c = 0
For i = LBound(swSplineHandle) To UBound(swSplineHandle)
swSplineHandle(c).TangentDriving = True
If swSplineHandle(c).SplinePointNumber = 4 Then
Debug.Print "PrePolar handle " & swSplineHandle(c).TangentPolarDirection
angleRad = 90 * 0.0174533
If angleRad > 1.57 Then
angleRad = 1.57
End If
Debug.Print "Polar Value Set To " & angleRad
swSplineHandle(c).TangentPolarDirection = angleRad
Debug.Print "Polar handle " & swSplineHandle(c).TangentPolarDirection
Debug.Print " "
End If
i = i + 1
c = c + 1
Next
End Sub
