Export DXF & PDF rule not working after upgrading from 2019 to 2021

Export DXF & PDF rule not working after upgrading from 2019 to 2021

tchappleA6VPF
Participant Participant
437 Views
5 Replies
Message 1 of 6

Export DXF & PDF rule not working after upgrading from 2019 to 2021

tchappleA6VPF
Participant
Participant

Hi All,

 

We have recently updated to inventor 2021, from 2019. I was using a bit of code to automatically export .dxf and .pdf copies of IDW's into specific folders on our shared network. Since the upgrade this rule will not work and I'm a bit stumped as to why not? 

Please can anybody shed some light?

 

Best regards

Tom

' Get the DXF translator Add-In.
Dim DXFAddIn As TranslatorAddIn
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "‪T:\Design Data\DWG-DXF\exportdxf.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
oDataMedium.FileName = "T:\Drawings\Standard Drawings\DXF\" & ThisDoc.FileName(False) & ".dxf" 'fixed folder
'Publish document.
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
'Launch the dxf file in whatever application Windows is set to open this document type with
i = MessageBox.Show("Preview the DXF file?", "Title",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
If i = vbYes Then ThisDoc.Launch(oDataMedium.FileName)

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 = "T:\Drawings\Standard Drawings\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 & _
" rev" & oRevNum & ".pdf"


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

0 Likes
438 Views
5 Replies
Replies (5)
Message 2 of 6

theo.bot
Collaborator
Collaborator

Chenk if the network folder location  are available and correct. If I change these in your code to my own paths, the rule works file.

0 Likes
Message 3 of 6

tchappleA6VPF
Participant
Participant

Hi Theo,

 

Thanks for taking a look. I have since checked the network paths and they are all ok. I have also ran the rule on a colleagues machine and it is working fine for them, but still no luck for me. I should also mention this is an external rule. I am getting the following error messages:

tchappleA6VPF_0-1633689105362.pngtchappleA6VPF_1-1633689124330.png

Best regards

0 Likes
Message 4 of 6

matt_jlt
Collaborator
Collaborator

If it's working on one machine and not the other, I have had two similar issues before. Not to say these are your problems but something i have experienced before. Also, you don't have any checks on your properties to make sure they are filled out. For example, if you try to run it on a document that isn't saved it will throw an error as it wont be able to retrieve the filename and same for other properties. Also, if you have any raster views or run it on a view that isn't finished updating and you try to export it to DXF it will still be in a raster state and will crash on export.



Issue 1 - Permissions of user didn't allow access to directories etc. and resulted in failure on save

 

Issue 2 - Have had this on a couple of machines, something has gone wrong with installation of the translator and you need to reinstall or repair the inventor installation.

0 Likes
Message 5 of 6

tchappleA6VPF
Participant
Participant

Hi,

 

After playing around all morning, I "manually" exported a file as a .DXF and so was given the prompt for .DXF export options, once I selected these and exported the file, I then re-tried running my rule and it worked fine. Not sure why this is the case but I shan't complain as the problem is now solved.

 

Thanks for the help.

0 Likes
Message 6 of 6

matt_jlt
Collaborator
Collaborator

I didn't even think of that 😁

I assume that all of the other users have previously exported a DXF / DWG manually which results in the ini file being created. This is what your export options would be using.

I have a specifi INI file i use across all users to ensure everyone is exporting to the same standard such as scale / sheet or model space and version of file etc.

0 Likes