Compare Features Example (VBA)
This example shows how to compare the solid features between the original
and modified parts using the SolidWorks Utilities API.
'--------------------------------------------
'
' Preconditions:
' (1)
The files c:\test\test.sldprt
' and
c:\test\thinellipse.sldprt exist.
' (2)
The path c:\test\report\gtReport
exists.
'
' Postconditions: Report is created in c:\test\report.
'
'---------------------------------------------
Option Explicit
Sub main()
Dim
swapp As
SldWorks.SldWorks
Dim
swUtil As
SWUtilities.gtcocswUtilities
Dim
swUtilCompFeat As
SWUtilities.gtcocswCompareFeature
Dim
longStatus As
Long
Dim
bAddToBinder As
Boolean
Dim
bOverwrite As
Boolean
'
Connect to SolidWorks
Set
swapp = Application.SldWorks
'
Get the SolidWorks Utilities interface
Set
swUtil = swapp.GetAddInObject("Utilities.UtilitiesApp")
'
Set the SolidWorks Utilities tool to Compare Features
Set
swUtilCompFeat = swUtil.GetToolInterface(gtSwToolFeatDiff,
0)
'
Compare the volumes of the specified part documents; do not show the Results
'
dialog box, but do save the results to a file in the specified path
bAddToBinder
= False
bOverwrite
= True
longStatus
= swUtilCompFeat.CompareFeatures2("c:\test\ellipse.sldprt",
"", "c:\test\thinellipse.sldprt", "", gtResultSaveReport,
"C:\test\Report", bAddToBinder, bOverwrite)
'
Perform any necessary clean up
longStatus
= swUtilCompFeat.Close()
End Sub