Is anyone else having issues with Auto Route in the routing add-in not working? I run flexible tube routes, and I use a macro to do most of the work. It will start a route and then try to auto route between the points. I use the "CreateRouteThroughSketchEntities" method. The return value is "0" which means success but all I get are the start and end of the tube? If I go back and edit the route there is no spline connecting the start and end points. Now if I try to use the "CreatePointToPointAutoRoute" Method I get the return value of 1 which means "swRouteTypeAndConversionModeMismatch". Not really sure what that is telling me? Do I have something set wrong in my routing data base? This was working fine for a few years and then just stopped working. I have it draw in a spline as a work around, but it sometimes gets the tangency wrong and auto route did not do that.
I guess the main thing I am asking is anyone else seeing this. If not and you use auto Route then what is your secret?
Here is the macro I am testing. This is the auto route section of a much larger standalone routing helper app I made.
if you want to test it you will need to make a flexible tube route like I have shown in the picture and have it preselected then run the macro to do the auto route.
this is basically a copy paste of the SolidWorks API help example. It ran great for years and then just stopped working I think in 2024 release. I am runner 2025 sp5 now.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swTopLevelAssembly As SldWorks.AssemblyDoc
Dim rtRouteManager As SWRoutingLib.RouteManager
Dim swSelMgr As SldWorks.SelectionMgr
Dim swSketchPt1 As SldWorks.SketchPoint
Dim swSketchPt2 As SldWorks.SketchPoint
Dim status As Boolean
Dim routeStatus As Long
Dim sketchEntityTypes(1) As Long
Dim sketchPt1IDs As Variant
Dim sketchPt2IDs As Variant
Dim sketchPtIDs(1) As Long
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
Set swSelMgr = swModel.SelectionManager
Set swTopLevelAssembly = swModel
' Get the RouteManager from the top-level assembly
Set rtRouteManager = swTopLevelAssembly.GetRouteManager
If rtRouteManager Is Nothing Then
Debug.Print "No RouteManager found in top-level document"
Exit Sub
End If
' Get and edit the route
swModel.EditRoute
' Get the AutoRoute
Dim rtAutoRoute As AutoRoute
Set rtAutoRoute = rtRouteManager.GetAutoRoute
If rtAutoRoute Is Nothing Then
Debug.Print "No AutoRoute found"
Exit Sub
End If
'Assign the types of sketch entities to be sketch points
sketchEntityTypes(0) = 0
sketchEntityTypes(1) = 0
' Get the IDs of the sketch points
status = swModelDocExt.SelectByID2("Point3", "SKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
Set swSketchPt1 = swSelMgr.GetSelectedObject6(1, -1)
sketchPt1IDs = swSketchPt1.GetID
Debug.Print "sketchPt1IDs: " & sketchPt1IDs(0); ", " & sketchPt1IDs(1)
swModel.ClearSelection2 True
status = swModelDocExt.SelectByID2("Point8", "SKETCHPOINT", 0, 0, 0, False, 0, Nothing, 0)
Set swSketchPt2 = swSelMgr.GetSelectedObject6(1, -1)
sketchPt2IDs = swSketchPt2.GetID
Debug.Print "sketchPt2IDs: " & sketchPt2IDs(0); ", " & sketchPt2IDs(1)
' Create an array containing the first
' member of each sketch point ID array
' to pass to IAutoRoute::CreateRouteThroughSketchEntities
sketchPtIDs(0) = sketchPt1IDs(0)
sketchPtIDs(1) = sketchPt2IDs(0)
swModel.ClearSelection2 True
' Create the route
routeStatus = rtAutoRoute.CreateRouteThroughSketchEntities(swAutoRouteConversionMode_e.swFlexibleAutoRouteMode, swAutoRouteAutoTangencyMode_e.swAutoTangencyMode_ON, sketchEntityTypes, sketchPtIDs)
Debug.Print routeStatus
' Return to editing the top-level assembly
swTopLevelAssembly.EditAssembly
End Sub
This should tell you success but then does not show the tube.
