I am using the sample code supplied in the API help section for pack and go for adding or removing a non solidworks file from pack and go. I am trying to modify the code to remove the solidworks file that i do not want to save with pack and go. Anu ideas how to change the code to allow this behvior? Or any alternatives?
'General code from API Help
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics
Partial Class SolidWorksMacro
Public Sub Main()
Dim swModel As ModelDoc2
Dim swModelDocExtAs ModelDocExtension
Dim swPackAndGoAs PackAndGo
Dim openFile As String
Dim errors As Long
Dim warnings As Long
Dim status As Boolean
Dim pgFileNames As Object
Dim i As Long
Dim renderReferences As Object
Dim otherFiles(1) As String
Dim delOtherFiles(0) As String
Dim myPath As String
Dim statuses As Object
' Open assembly document
openFile = "C:\\Program Files\\SolidWorks Corp\\SolidWorks\\samples\\tutorial\\EDraw\\claw\\claw-mechanism.sldasm"
swModel = swApp.OpenDoc6(openFile, swDocumentTypes_e.swDocASSEMBLY, swOpenDocOptions_e.swOpenDocOptions_Silent,"", errors, warnings)
swModelDocExt = swModel.Extension
' Get Pack and Go object
Debug.Print("Pack and Go")
swPackAndGo = swModelDocExt.GetPackAndGo
' Get current paths and filenames of the assembly's documents
status = swPackAndGo.GetDocumentNames(pgFileNames)
Debug.Print("")
Debug.Print(" Add SolidWorks files' paths and filenames: ")
If Not IsNothing(pgFileNames) Then
For i = 0 To UBound(pgFileNames)
Debug.Print(" The path and filename is: " & pgFileNames(i))
Next i
End If
' Set document paths and names for Pack and Go
status = swPackAndGo.SetDocumentSaveToNames(pgFileNames)
' Get the render stock references in this assembly
' and print them to the Immediate window
Debug.Print(" ")
renderReferences = swModelDocExt.GetRenderStockReferences
Debug.Print(" Add render references:")
For i = 0 To UBound(renderReferences)
Debug.Print(" The path and filename is: " & renderReferences(i))
Next i
' Add render stock files to Pack and Go
status = swPackAndGo.AddExternalDocuments(renderReferences)
' Add other non-SolidWorks files to Pack and Go
otherFiles(0) = "c:\\program files\\solidworks corp\\solidworks\\samples\\tutorial\\edraw\\claw\\claw-mechanism.easm"
otherFiles(1) = "c:\\program files\\solidworks corp\\solidworks\\samples\\tutorial\\edraw\\claw\\claw-mechanism.emodel_debugonly.xml"
Debug.Print(" ")
Debug.Print(" Add non-SolidWorks files:")
For i = 0 To UBound(otherFiles)
Debug.Print(" The path and filename is: " & otherFiles(i))
Next i
status = swPackAndGo.AddExternalDocuments(otherFiles)
' Remove one of the non-SolidWorks files from Pack and Go
Debug.Print(" ")
Debug.Print(" Remove non-SolidWorks file:")
delOtherFiles(0) = otherFiles(0)
Debug.Print(" The path and filename is: " & delOtherFiles(0))
status = swPackAndGo.RemoveExternalDocuments(delOtherFiles)
' Override path where to save documents
myPath = "c:\\temp\\"
status = swPackAndGo.SetSaveToName(True, myPath)
' Pack and Go both SolidWorks and non-SolidWorks files
statuses = swModelDocExt.SavePackAndGo(swPackAndGo)
End Sub
'''
'''
Public swApp As SldWorks
End Class
