- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have a rule not created by me, which you can see at the bottom of this post, that exports my drawing to PDF, but the PDF is created in the drawing file folder, I would like to change the target folder to our server, but I have no idea how.
The file path and name generated by the code:
oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".pdf"
is as follows: "c:\_Vault_Pracovni\externi\_ORDERS - ZAKÁZKY\2023 (zak. 51163 - )\51215\Test.pdf"
How to modify the file path to save the file Test.pdf in the following folder?
"\\192.168.1.200\data\cad\externi\_ORDERS - ZAKÁZKY\2023 (zak. 51163 - )\51215\"
As you can see the end part "\externi\_ORDERS - ZAKÁZKY\2023 (zak. 51163 - )\51215\" of the file path is the same, because our server mimics the path of the drawing file except the starting part "c:\_Vault_Pracovni" which I need to change to "\\192.168.1.200\data\cad".
Please note this "\\192.168.1.200\data\cad\externi\_ORDERS - ZAKÁZKY\2023 (zak. 51163 - )\51215\" is not a fixed folder, each order has its own number and specific year that changes so I think that ThisDoc.FileName(False) & ".pdf" should be used but then how to modify the starting part of the path?
'Get the PDF translator Add-In.
Dim PDFAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
'a reference to the active document (the document to be published).
Dim oDocument As Document = ThisApplication.ActiveDocument
Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
'Create a NameValueMap object
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
'Create a DataMedium object
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
oOptions.Value("Sheet_Range") = PrintRangeEnum.kPrintAllSheets
'Check whether the translator has 'SaveCopyAs' options
If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
' Options for drawings...
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
oOptions.Value("All_Color_AS_Black") = 0
'oOptions.Value("Sheet_Range") = PrintRangeEnum.kPrintAllSheets
oOptions.Value("Remove_Line_Weights") = 1
'oOptions.Value("Vector_Resolution") = 400
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4
End If
'the destination file name
oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".pdf"
'Publish document.
Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Solved! Go to Solution.