Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
PumaBH
358 Views, 7 Replies

iLogic, Publish PDF error.

Hello All, 

 

I have an iLogic Rule as shown below that will publish a PDF document of the saved manufacturing drawing. 

When i create manufacturing drawings i have it so the .idw drawing is auto saved as a .pdf as well via the iLogic. 

i do this for all my drawings and on occasions the drawing that was auto saved would sometimes be incorrect.

 

For example the drawing will save as a .pdf under the correct file name but the contents of this file will be something else that was open at the time of the save. often another drawing or part model in a random view orientation. 

 

it is not a regular occurrence and would happen once in every 20 or so drawings. probably when i have more than 10 different file types open in inventor it will confuse itself during operation. 

 

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(oDocument, oContext, oOptions) Then
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2'oOptions.Value("Custom_End_Sheet") = 4
End If 


'get PDF target folder path
oFolder = ThisDoc.Path & "\pdf" 'instead of "k:\dwg\pdf\"

'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


 'Set the PDF target file name
oDataMedium.FileName = oFolder & "\" & oFileName & ".pdf" 
'_" rev" & oRevNum & ".pdf" 


'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) 
'------end of iLogic-------

Cheers!