I altered my code to point it to another location. WHen it didn't work, I pointed it back to the original location and it still refused to work properly 🙁
This it the code I use to ZIP the folder in question.
As mentioned previously, I'm not a coder, so please forgive me if it's a bit 'nasty'
'path to save ZIP file received from other rule
oZipFolder = RuleArguments("FILE LOC FOR DXF")
'MessageBox.Show("oZipFolder = " & oZipFolder, "iLogic")
oFileName = ThisDoc.FileName(False) 'no extension
'MessageBox.Show("oFileName = " & oFileName, "iLogic")
'Temporary locations for testing purposes
'Dim oZipFolder As String = "C:\Users\Darren Lees\OneDrive\CAD\iLogic\DXF Testing\L Drive\"
'Dim oZipFolder As String = "C:\Users\Darren Lees\OneDrive - Osbit\Desktop\"
If Not System.IO.Directory.Exists(oZipFolder) Then
System.IO.Directory.CreateDirectory(oZipFolder)
End If
'Check to see if location for ZIP file is correct
'MessageBox.Show("Your ZIP info: " & oZipFolder + oFileName & " Rev " & SharedVariable("HighestRev") & ".zip")
'Generate ZIP file
If System.IO.File.Exists(oZipFolder & oFileName & " Rev " & SharedVariable("HighestRev") & ".zip")
'***--- used SharedVariable as I don't know how to pass more than one argument using NameValueMap ---***
'If ZIP file with same title exists, delete it and create another one
My.Computer.FileSystem.DeleteFile(oZipFolder + oFileName & " Rev " & SharedVariable("HighestRev") & ".zip")
System.IO.Compression.ZipFile.CreateFromDirectory(oZipFolder, oZipFolder + oFileName & " Rev " & SharedVariable("HighestRev") & ".zip")
Else
'...otherwise create ZIP file
System.IO.Compression.ZipFile.CreateFromDirectory(oZipFolder, oZipFolder + oFileName & " Rev " & SharedVariable("HighestRev") & ".zip")
End If
I just find it confusing that it worked for a while. The only change I made was to direct it to a different path further up the tree (oZipFolder), so further away from the folder being zipped, and it stopped working!!
This is the code where I get the information to send the correct path to my ZIP rule.
oFileName = ThisDoc.FileName(False) 'no extension
'MessageBox.Show("Actual file name (no ext.) = " & oFileName, "iLogic")
'Strip name from file name for DXF file location
Dim FolderName As String = Mid(oFileName, 1, 7)
'MessageBox.Show("Stripped folder name = " & FolderName, "iLogic")
'paths for concept testing or live testing
'Dim DrvName = "C:\Users\Darren Lees\OneDrive - Osbit\Desktop\DXF Testing\" 'drive used for concept testing
Dim DrvName = "C:\Users\Darren Lees\OneDrive\CAD\iLogic\DXF Testing\L Drive\" 'drive used for concept testing
'Dim DrvName As String = "L:\" 'OSBIT Live Drive
'Folder for DXF folder. This can be changed to suit future requirements
Dim UncDxfFolder As String = "\UNCOMPRESSED DXF\"
'Complete destination for DXF and PDF files
Dim oDXF_Folder As String = DrvName & FolderName & UncDxfFolder & oFileName & "\"
'MessageBox.Show("DXF File destination = " & oDXF_Folder, "iLogic")
'Create NameValueMap for DXF destination to send to SAVE TO DXF and SAVE TO DXF rule
Dim oValueDXFMap As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
oValueDXFMap.Add("FILE LOC FOR DXF", oDXF_Folder)
'Destination of ZIP folder containing all of the files within oDXF_Folder
Dim oZipFolder = DrvName & FolderName & "\"
'MessageBox.Show("ZIP folder name = " & oZipFolder, "iLogic")
'Create NameValueMap for ZIP destination to send to SAVE TO ZIP rule
Dim oValueZIPMap As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
oValueZIPMap.Add("FILE LOC FOR DXF", oZipFolder)
'Create NameValueMap for ZIP file name to send to SAVE TO ZIP rule
'Dim oValueZIPNameMap As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap()
'oValueZIPNameMap.Add("FILE LOC FOR DXF", oFileName)
'This rule determines the highest revision of the items within the DXF drawing
iLogicVb.RunExternalRule("LOOP THRU SHEETS")
'hand path details to other rules
iLogicVb.RunExternalRule("EMPTY FOLDER", oValueDXFMap) 'Empty the folder of everything ready for the next DXFs / PDFs
iLogicVb.RunExternalRule("SAVE TO DXF", oValueDXFMap) 'for DXF files
iLogicVb.RunExternalRule("SAVE TO PDF", oValueDXFMap) 'for PDF file
iLogicVb.RunExternalRule("SAVE TO ZIP", oValueZIPMap) 'folder whose contents are to be zipped up
'OPERATION COMPLETE
''MessageBox.Show("Operation Complete!", "Complete", 'MessageBoxButtons.OK, 'MessageBoxIcon.Information)
''MessageBox.Show("Full Folder Location = " & oDXF_Folder, "iLogic")
''MessageBox.Show("ZIP File Folder Location = " & oZipFolder, "iLogic")
As mentioned previously, I'm not a coder, so please forgive me if it's a bit 'nasty' 🤣
It should be relatively easy to work through this. It also sends paths to other routines without issue to create DXFs and a PDF.
Any help on this is hugely appreciated!!
Regards
Darren