CountAllHoles SRC
CountAllHoles SRC
'http://ic3d.com.au/
'----------------------------------------------------------------------------------'Disclaimer: The API examples are provided as is and should be used as reference
only.
'You may redistribute it and/or modify it on the condition that this header is r
etained.
'In no event shall IC3D be liable for any types of damages whatsoever
'(including without limitation, damages from the loss of use, data, profits, or
business)
'arising out of the uses of this information, applications, or services.
'----------------------------------------------------------------------------------'Macro counts all holes in active part or assembly and outputs the result to CSV
file
Const DIAM_ROUND_DIGITS As Integer = 5 ' number of digits after decimal
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swHolesDic As Object
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "Please open SolidWorks Part or Assembly"
End
End If
Set swHolesDic = CreateObject("Scripting.Dictionary")
swHolesDic.CompareMode = vbTextCompare 'dicitonary works better with string
keys
Dim vBodies As Variant
If swModel.GetType = swDocumentTypes_e.swDocASSEMBLY Then
Dim swAssy As SldWorks.AssemblyDoc
Set swAssy = swModel
Dim vComps As Variant
vComps = swAssy.GetComponents(False)
Dim i As Integer
For i = 0 To UBound(vComps)
Dim swComp As SldWorks.Component2
Set swComp = vComps(i)