Message 1 of 13
iLogic IDW to DXF error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I've been using the forums to get some iLogic rules to do some tedious steps for me.
On my last step to get the code completly working as intended, I get an error on Draftsight when opening my dxf file. This error only occurs when I export to dxf using the code, but if I use Save Copy As I get no error at all.
This drawing file version is not supported.
Code explanation:
- Go through each sheet and get model in view part number and revision;
- If part then it opens the part, saves it as .step and closes;
- If sheetmetal then it saves copy of sheet as .dxf;
- Save each sheet individually to .pdf;
' 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 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
Dim strIniFile As String
strIniFile = "C:\temp\dxfout.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
If TypeOf ThisDoc.Document Is DrawingDocument Then
Dim dwgDoc As DrawingDocument = ThisDoc.Document
For Each dwgSheet As Sheet In dwgDoc.Sheets
If dwgSheet.DrawingViews.Count > 0 Then
modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName
modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
prtNumber = modelDoc.PropertySets("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").ItemByPropId(5).Value
Rev = modelDoc.PropertySets.Item("Summary Information").Item("Revision Number").Value
'MessageBox.Show(modelDoc.Subtype)
If modelDoc.SubType = "{4D29B490-49B2-11D0-93C3-7E0706000000}" Then
Dim oPart As PartDocument
Dim oPartPath As String
' Get drawing path
oPartPath = modelFile
' Set a reference to the target part
oPart = ThisApplication.Documents.ItemByName(oPartPath)
' Open the target part
ThisApplication.Documents.Open(oPartPath)
' Save a copy of oPart as a step file
oPart.SaveAs(Replace(oPartPath, ".ipt","." & Rev & ".step"), True)
' Close oPart
oPart.Close
End If
If modelDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
'Set the destination file name
oDataMedium.FileName = prtNumber & "." & Rev & ".dxf"
'Publish document.
DXFAddIn.SaveCopyAs(modelDoc, oContext, oOptions, oDataMedium)
End If
End If
Next
End If
'['Sub Variables
oRefDocs = ThisApplication.ActiveDocument.AllReferencedDocuments
Dim oDoc As Document
oFolder = ThisDoc.Path
oAddIns = ThisApplication.ApplicationAddIns
oTG = ThisApplication.TransientObjects']
'['PDF Export
'['PDF Options
PDFAddIn = oAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oContext = oTG.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = oTG.CreateNameValueMap
oDataMedium = oTG.CreateDataMedium
oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 4800
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintCurrentSheet']
For Each oDoc In oRefDocs
idwPathName = Left(oDoc.FullDocumentName, Len(oDoc.FullDocumentName) -3) & "idw"
If System.IO.File.Exists(idwPathName) Then
oDrawDoc = ThisApplication.Documents.Open(idwPathName, True)
For Each oSheet As Sheet In oDrawDoc.Sheets
oSheet.Activate
oSheetName = oSheet.Name.Split(":")(0)
oDataMedium.FileName = oFolder & "\" & oSheetName & ".pdf"
Call PDFAddIn.SaveCopyAs(oDrawDoc, oContext, oOptions, oDataMedium)
Next
End If
Next']
I've tried exporting the face of the 3D model, but it's not what we want.
João Silva
Mechanical Engineer