I have a macro that when I select (1) round hole and then run the macro it finds all the same size holes in a drawing view and then uses autodimension to add all the dimensions.
I just updated to SolidWorks 2026 and now it does not work. It runs perfectly in 2025 still.
Here is the macro:
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDrawing As SldWorks.DrawingDoc
Dim drView As SldWorks.View
Dim Comp As SldWorks.Component2
Dim itr As Long
Dim CompCount As Long
Dim vComps As Variant
Dim vEdges As Variant
Dim i As Long
Dim Entity As SldWorks.Entity
Dim swEdge As SldWorks.Edge
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDrawing = swModel
Set swSelMgr = swModel.SelectionManager
For i = 1 To swSelMgr.GetSelectedObjectCount
If swSelMgr.GetSelectedObjectType(i) = swSelectType_e.swSelDRAWINGVIEWS Then Set drView = swSelMgr.GetSelectedObject6(i, -1)
If swSelMgr.GetSelectedObjectType(i) = 1 Then
Set Entity = swSelMgr.GetSelectedObject6(i, -1)
Set swEdge = Entity.GetSafeEntity
End If
Next i
If swEdge Is Nothing Then
swApp.SendMsgToUser "No Edge Selcted. Pick 1 round Edge."
Exit Sub
End If
If drView Is Nothing Then
swApp.SendMsgToUser "No View Selcted. Pick 1 round Edge."
Exit Sub
End If
Dim vCurvePar As Variant
Dim swCurve As SldWorks.Curve
Set swCurve = swEdge.GetCurve
vCurvePar = swCurve.CircleParams
Dim compareDia As Double
compareDia = vCurvePar(6)
CompCount = drView.GetVisibleComponentCount
If CompCount = 0 Then
swApp.SendMsgToUser "No Model in View."
Exit Sub
End If
vComps = drView.GetVisibleComponents
If IsEmpty(vComps) Then
swApp.SendMsgToUser "Your Selections are Wrong. Pick 1 round edge."
Exit Sub
End If
For i = LBound(vComps) To UBound(vComps)
swModel.ClearSelection2 True
Set Comp = vComps(i)
Next i
vEdges = drView.GetVisibleEntities(Comp, swViewEntityType_Edge)
Dim SelEdge() As SldWorks.Edge
If IsEmpty(vEdges) Then
swApp.SendMsgToUser "No Edges in View."
Exit Sub
Else
For itr = 0 To UBound(vEdges)
Dim matchEdge As SldWorks.Edge
Dim matchCurve As SldWorks.Curve
Set matchEdge = vEdges(itr)
Set matchCurve = matchEdge.GetCurve
If matchCurve.IsCircle Then
Dim mvCurvePar As Variant
mvCurvePar = matchCurve.CircleParams
Dim curveDia As Double
curveDia = mvCurvePar(6)
If Round(curveDia, 8) = Round(compareDia, 8) Then
ReDim Preserve SelEdge(itr)
Set SelEdge(itr) = matchEdge
End If
End If
Next itr
End If
Dim swSelectData As SldWorks.SelectData
Set swSelectData = swSelMgr.CreateSelectData
swSelectData.Mark = 1
swDrawing.ActivateView (drView.Name)
If swModel.Extension.MultiSelect(SelEdge, False, swSelectData) <> 0 Then
Dim ret As Long
ret = swDrawing.AutoDimension(swAutodimEntities_e.swAutodimEntitiesBasedOnPreselect, swAutodimScheme_e.swAutodimSchemeOrdinate, swAutodimHorizontalPlacement_e.swAutodimHorizontalPlacementAbove, swAutodimScheme_e.swAutodimSchemeOrdinate, swAutodimVerticalPlacement_e.swAutodimVerticalPlacementRight)
End If
End Sub
I start with a view like this and select one of the edges of the hole I want to dimension.
After I run the macro I should see this:
But in 2026 sp 4.1 nothing happens.
Anyone else see this happening or can try to recreate the problem.
Looking for any help. This is a MAJOR issue for me if that macro no longer works.
