Hi.
Im trying to get inventor to export my drawing to a folder on a network drive.
But my iLogic code doesnt work.
I have found a code that i thought would work but i get an error saying
"The given path's format is not supported."
SyntaxEditor Code Snippet
'query user question = MessageBox.Show("Is a .PDF Export To Monitor Required?", "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question) 'set condition based on answer If question = vbYes Then '------start of iLogic------- oPath = ThisDoc.Path oFileName = ThisDoc.FileName(False) 'without extension oRevNum = iProperties.Value("Project", "Revision Number") oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") oDocument = ThisApplication.ActiveDocument oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism oOptions = ThisApplication.TransientObjects.CreateNameValueMap oDataMedium = ThisApplication.TransientObjects.CreateDataMedium If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then oOptions.Value("All_Color_AS_Black") = 0 oOptions.Value("Remove_Line_Weights") = 0 oOptions.Value("Vector_Resolution") = 400 oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets oOptions.Value("Custom_Begin_Sheet") = 1 oOptions.Value("Custom_End_Sheet") = 10 End If 'get PDF target folder path oFolder = Left(oPath, InStrRev(oPath, "\\G:\Dokumentation\Ritningar\Ritningar Monitor\$Ritningar From CAD")) & "\\G:\Dokumentation\Ritningar\Ritningar Monitor\$Ritningar From CAD" 'Check for the PDF folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If If iProperties.Value("Project", "Revision Number") >= "1" Then 'Set the PDF target file name oDataMedium.FileName = oFolder & "\" & oFileName & _ "-" & oRevNum & ".pdf" Else 'Set the destination file name oDataMedium.FileName = oFolder & "\" & oFileName & ".pdf" End If Else Return End If On Error Goto handlePDFLock 'Publish document oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) '-------------------------------------------------------------------------------------------------------------------- Exit Sub handlePDFLock:MessageBox.Show("PDF not created, most likely someone else has it open.", "No PDF for you " & ThisApplication.GeneralOptions.UserName & "!") Resume Next 'Show message box MessageBox.Show("Drawing saved and PDF Exported to LAST EDITED document folder/PDF", "Save I-logic") '------end of iLogic-------
Whats wrong?
Using Inventor 2015
Jesper
Solved! Go to Solution.
Solved by Jesper_S. Go to Solution.
Because the network drive i was trying to export to was mapped to my computer i didnt need "\\" before may path in iLogic.
The code.
'query user
question = MessageBox.Show("Is a .PDF Export To Monitor Required?", "iLogic Question",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
'set condition based on answer
If question = vbYes Then
'------start of iLogic-------
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oRevNum = iProperties.Value("Project", "Revision Number")
oPDFAddIn = ThisApplication.ApplicationAddIns.ItemById _
("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
If oPDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
oOptions.Value("Custom_Begin_Sheet") = 1
oOptions.Value("Custom_End_Sheet") = 10
End If
'get PDF target folder path
oFolder = Left(oPath, InStrRev(oPath, "G:\Dokumentation\Ritningar\Ritningar Monitor\$Ritningar From CAD")) & "G:\Dokumentation\Ritningar\Ritningar Monitor\$Ritningar From CAD"
'Check for the PDF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
If iProperties.Value("Project", "Revision Number") >= "1" Then
'Set the PDF target file name
oDataMedium.FileName = oFolder & "\" & oFileName & _
"-" & oRevNum & ".pdf"
Else
'Set the destination file name
oDataMedium.FileName = oFolder & "\" & oFileName & ".pdf"
End If
Else
Return
End If
On Error Goto handlePDFLock
'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
'--------------------------------------------------------------------------------------------------------------------
Exit Sub
handlePDFLock:MessageBox.Show("PDF not created, most likely someone else has it open.", "No PDF for you " & ThisApplication.GeneralOptions.UserName & "!")
Resume Next
'Show message box
MessageBox.Show("Drawing saved and PDF Exported to LAST EDITED document folder/PDF", "Save I-logic")
'------end of iLogic-------
Can't find what you're looking for? Ask the community or share your knowledge.