- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've got an external ilogic rule which exports a DXF from the open IDW file and i'm then wanting the file to close.
The DXF export portion of the file runs fine, but as soon as I add ThisDoc.Document.Close(True) to the last line, I get an error dialog with "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))".
I have tried the ThisDoc.Document.Close(True) in it's own rule and it works without error. I have also tried adding it as the last line in my export PDF from IDW external rule and it also works without error for PDFs. The problem is in this DXF export rule.
Can anyone offer some advice? I'm guessing it's probably still executing the DXF export and tries to close the drawing in the middle of the process or something?
'Default top level directory
oPath = "U:\INVENTOR PARTS\"
' 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 = 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 = "C:\Inventor 2022\Tweed DXF Output Settings.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Get the iProperties from the model and create the file name string
Dim oMdoc As Document
oMdoc = ThisDrawing.ModelDocument
Dim oProp1Value As String
oProp1Value = oMdoc.PropertySets("Design Tracking Properties").Item("Cost Center").Value
Dim oProp2Value As String
oProp2Value = oMdoc.PropertySets("Design Tracking Properties").Item("Project").Value
Dim oProp3Value As String
oProp3Value = oMdoc.PropertySets("Design Tracking Properties").Item("Part Number").Value
'Check if subfolder exists and/or create it
oFolder = oPath & oProp1Value & "\"
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
oDataMedium.FileName = oFolder & oProp1Value & " - " & oProp2Value & " - " & oProp3Value & ".dxf"
'Publish document.
Call DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
ThisDoc.Document.Close(True)
Solved! Go to Solution.