AnsweredAssumed Answered

How to count hole number include half hole

Question asked by Yong Ning on Jan 13, 2016
Latest reply on Jan 15, 2016 by Andreas Killer

Follow code, count cut whole hole is 31. not halt hole.

 

Need calculte cut whole  hole is 36 include half hole

 

 

10.jpg

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swSelMgr As SldWorks.SelectionMgr

Dim swFeat As SldWorks.Feature

Dim swSketch As SldWorks.Sketch

 

Sub main()

 

 

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Dim swFace As SldWorks.Face2

    Set swFace = swSelMgr.GetSelectedObject5(1)

    Dim vLoops As Variant

    Dim i As Integer

    Dim totalHolesCount As Integer, vCount

 

    vCount = swFace.GetLoopCount - 1

 

 

    Dim SwLoop As Loop2

    Dim vEdges As Variant

      Set SwLoop = swFace.GetFirstLoop

      Do While Not SwLoop Is Nothing

     

        If Not SwLoop.IsOuter Then

            vEdges = SwLoop.GetEdges

            If UBound(vEdges) = 0 Then

                Dim swEdge As SldWorks.Edge

                Set swEdge = vEdges(0)

                Dim swCurve As SldWorks.Curve

                Set swCurve = swEdge.GetCurve

                'If swCurve.IsCircle Then

                    totalHolesCount = totalHolesCount + 1

                'End If

            End If

        End If

        Set SwLoop = SwLoop.GetNext

    Loop

 

    MsgBox "Total holes count: " & totalHolesCount

 

End Sub

 

 

How to calculate cut hole number with API? | SOLIDWORKS Forums

https://forum.solidworks.com/message/340498#340498

Outcomes