Description
This SOLIDWORKS macro provides a fast and efficient way to export active documents to the IGES file format (.igs). Designed for SOLIDWORKS parts and assemblies, this macro automatically saves the exported IGES file to the same directory as the original document, using the same filename. With the ability to export part and assembly to IGES file, this is an ideal solution for you if you are someone who frequently needs to save their CAD files in a universal format for compatibility with other CAD software.
System Requirements
- SolidWorks Version: SolidWorks 2014 or newer
- Operating System: Windows 7 or later
Pre-Requisites
Note
- The active document youโll be working on must be a part or assembly.
- This macro will not operate correctly with drawing files.
- Make sure to save the document changes before running the macro, since the file will be saved in the same directory as the original file.
Results
Note
- The macro will save the active document to an .igs file in the same directory.
- Once complete, a message box will pop up indicating the saved file location.
VBA Macro Code
' Disclaimer:
' The code provided should be used at your own risk.
' Blue Byte Systems Inc. assumes no responsibility for any issues or damages that may arise from using or modifying this code.
' For more information, visit [Blue Byte Systems Inc.](https://bluebyte.biz).
Dim swApp As SldWorks.SldWorks
Dim Part As ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
' Initialize SolidWorks application and active document
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
' Exit if no document is active
If Part Is Nothing Then Exit Sub
' Get the path of the active document
Dim Path As String
Path = Part.GetPathName
' Exit if the active document is a drawing (since IGES export is not supported for drawings)
If Part.GetType = swDocDRAWING Then
Exit Sub
End If
' Prepare the path for the IGES file by replacing the extension
Dim Extension As String
Extension = Mid(Path, InStrRev(Path, "."))
Path = Replace(Path, Extension, ".igs")
Extension = ".igs"
' Export the file as IGES
longstatus = Part.SaveAs3(Path, 0, 0)
' Notify the user about the saved file location
MsgBox "Saved " & Path, vbInformation
End Sub
You can download the macro from here.
Custom Modification
Need to customize the macro? Or do you wish to incorporate it with another workflow process? At Blue Byte Systems Inc., we specialize in doing just that, whether you need to export part and assembly to IGES file or adapt the macro for other tasks. Please reach out to us, and we will develop a custom macro designed to meet your specific needs!
Ready to be more productive with a custom macro? Click here to contact us!