Hide Table of Contents

Compare Documents Example (VBA)

This example shows how to compare the volumes of two parts and then save the results of the comparison as a solid part 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:

'        (1) Report is created in c:\test\report.

'        (2) The file Volume Comparison of ellipse

'            and thinellipse.sldprt is created.

'

'---------------------------------------------

 

Option Explicit

 

Sub main()

 

    Dim swapp                   As SldWorks.SldWorks

    Dim swUtil                  As SWUtilities.gtcocswUtilities

    Dim swUtilCompdoc           As SWUtilities.gtcocswCompareDocument

    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 Documents

    Set swUtilCompdoc = swUtil.GetToolInterface(gtSwToolCompDocs, 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 = swUtilCompdoc.CompareDocument2("c:\test\ellipse.sldprt", "", "c:\test\thinellipse.sldprt", "", gtCodVolumeCompare, gtResultSaveReport, "C:\test\Report", bAddToBinder, bOverwrite)

 

     ' Save the volume comparison results as a SOLIDWORKS part document

    longStatus = swUtilCompdoc.SaveCompareVolumeResults("c:\test")

 

    ' Perform any necessary clean up

    longStatus = swUtilCompdoc.Close()

    

End Sub

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Compare Documents (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2015 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.