Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic SaveAs Error

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Daan_M
587 Views, 2 Replies

iLogic SaveAs Error

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:

Daan_M_0-1601282604507.png

 

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?

 

Daan_M_1-1601282704209.png

 

 

 

EDIT: trying to export the drawing as .pdf manually through the Inventor UI also doesn't work.. 'Save as type' field is empty aswell:

 

Daan_M_0-1601283492258.png

 

 

Daan_M_0-1601283019949.png

 

 

 

2 REPLIES 2
Message 2 of 3
JhoelForshav
in reply to: Daan_M

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)

 

Message 3 of 3
Daan_M
in reply to: JhoelForshav

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:

 

https://knowledge.autodesk.com/support/inventor-products/troubleshooting/caas/sfdcarticles/sfdcartic...

 

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.

Post to forums  

Autodesk Design & Make Report