ilogic pdf rule

ilogic pdf rule

Anonymous
Not applicable
954 Views
3 Replies
Message 1 of 4

ilogic pdf rule

Anonymous
Not applicable

Hi all,

 

At the moment i am looking for a solution to save pdf files from the idw files with a ilogic rule.

 

This rule, as shown, is used at the moment but has no functionality to create a path on a different harddrive in our network, with the same folder structure as the folder structure of the idw file. With this rule all the pdf files are saved in the same folder: J:\PDF_Files_Inventor.

For example a idw file is located here in the workspace: C:\VaultWorkspace\Designs\2014\1410\18871\example.idw I would like that the ilogic rule creates new folders on the J drive like: J:\2014\1410\18871\example.pdf

 

oPath = "J:\PDF_Files_Inventor"
oFileName = ThisDoc.FileName(False) 'without extension
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") = 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 = Left(oPath, InStrRev(oPath, "\")) & "PDF_Files_Inventor"

'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"

'Publish document
oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

 

Can anyone give me tips to make this rule more advanced.

 

Thanks,

 

Marco

0 Likes
Accepted solutions (1)
955 Views
3 Replies
Replies (3)
Message 2 of 4

GosponZ
Collaborator
Collaborator
response = MessageBox.Show("Did you change path in this rule?", "Reminder",MessageBoxButtons.YesNo)
If response = vbNo Then Exit Sub

 
'Save PDF with options
'FileName = ThisDoc.FileName(True)
'ThisDoc.Document.SaveAs(FileName & (".pdf") , True)
oPath = ThisDoc.Path
PN = iProperties.Value("Project", "Part Number")


'path_and_namePDF = ThisDoc.Pathandname(False)
oFileName = ThisDoc.FileName(False) 'without extension
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") = 1
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 1
'oOptions.Value("Custom_End_Sheet") = 4
End If



'Set the destination file name 
oPath = "N:\Your desired folder
oPath = InputBox("Replace Path","New Path")
 
oDataMedium.FileName = oPath & "\" & PN & ".pdf"
'Publish document 
 'Confirmation message
 MessageBox.Show("PDF SAVED TO: " & oDataMedium.FileName, "PDF Saved", MessageBoxButtons.OK)
 


On Error Goto handlePDFLock
'Publish document.
Call oPDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)


'--------------------------------------------------------------------------------------------------------------------


Exit Sub


handlePDFLock: 
MessageBox.Show("PDF could not be saved, most likely someone else has it open", "No PDF for you " & ThisApplication.GeneralOptions.UserName & "!")
Resume Next


handleXLSLock: 
MessageBox.Show("No XLS", "iLogic")
Resume Next



 Try this one. I'm using every day working for me.

Message 3 of 4

rossano_praderi
Collaborator
Collaborator
Accepted solution

Hi Marco,

i would like to give you an alternative solution

 

' alternative oFileName value
oFileName = ThisDoc.PathAndFileName(False).Replace(ThisDoc.WorkspacePath(), "J:")

' your code.....

' oFolder 
oFolder = oFileName.Replace(ThisDoc.FileName(False),"")

' your code....

' oDataMedium.FileName
oDataMedium.FileName = oFileName & ".pdf"

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 4 of 4

Anonymous
Not applicable

Hello Rossano Praderi,

 

Thank you very much for this alternative solution.

I have tried it out and it functions very well.

 

Best Regard,

 

Marco de Kort

0 Likes