Hi,
I'm getting some strange behaviour when saving my configuration with the following code:
oDDoc As DrawingDocument = ThisDrawing.Document
oExcelDoc = "C:\Data\exceltest.xlsm"
oDocName = "TestName"
oMapNumber = GoExcel.CellValue(oExcelDoc, oESheet, "A1")
Dim oDestPath As String = "C:\Data\" & oMapNumber & "\" 'Directory
Dim oDwgFile As String = oDestPath & oDocName & ".dwg"
Dim oPdfFile As String = oDestPath & oDocName & ".pdf"
oDDoc.SaveAs(oDwgFile, True)
oDDoc.SaveAs(oPdfFile, True)
I get the following error:
What i find suprising is that it does generate the .dwg correctly, even though it throws an error.
However it does not generate the .pdf?
EDIT: trying to export the drawing as .pdf manually through the Inventor UI also doesn't work.. 'Save as type' field is empty aswell:
Solved! Go to Solution.
Solved by Daan_M. Go to Solution.
Hi @Daan_M
It's strange that it can save the dwg and not the pdf. When I tried it I had to make sure the directory exists before running the code for either of them to work:
Dim oDDoc As DrawingDocument = ThisDrawing.Document oExcelDoc = "C:\Data\exceltest.xlsm" oDocName = "TestName" oMapNumber = GoExcel.CellValue(oExcelDoc, oESheet, "A1") Dim oDestPath As String = "C:\Data\" & oMapNumber & "\" 'Directory If System.IO.Directory.Exists(oDestPath) = False Then System.IO.Directory.CreateDirectory(oDestPath, Nothing) End If Dim oDwgFile As String = oDestPath & oDocName & ".dwg" Dim oPdfFile As String = oDestPath & oDocName & ".pdf" oDDoc.SaveAs(oDwgFile, True) oDDoc.SaveAs(oPdfFile, True)
Also make sure the directory doesn't contain any documents with the same names to begin with and maybe clear Inventors memory of unreferenced documents if they have been created before and have just been deleted from the folder:
ThisApplication.Documents.CloseAll(True)
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Thanks for the reply, I dug on the forums and found another user that had a similar kind of problem exporting .dwg, it referenced this troubleshooting thread:
Resetting the Utilities fixed it, no code adjustment was needed in the end, i still put in your suggest below tho 😉
If System.IO.Directory.Exists(oDestPath) = False Then
System.IO.Directory.CreateDirectory(oDestPath, Nothing)
End If
Can't find what you're looking for? Ask the community or share your knowledge.