Message 1 of 17
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have this code to save out drawings to DXF but it is not behaving consistent.
Sometimes the a new dxf file for each sheet was created but sometimes it would overwrite the previous sheet also.
So I decided to give each sheet a unique name and use this sheet name as part of the filename of the DXF to make.
So far so good...
But now
The code below is working , it outputs a new file for every sheet with the correct name.
The problem that I can't figure out with this code is, that the files are created without the .dxf extension and the size is 0 Kb .
SyntaxEditor Code Snippet
'***** DXF'***** use the custom rule copy Iprops from model to drawing to get the Part Number on the drawing. oFolderDXF = (oPath & "\output\DXF") oDataMediumDXF = ThisApplication.TransientObjects.CreateDataMedium oDXFAddIn = ThisApplication.ApplicationAddIns.ItemById _ ("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") If Not System.IO.Directory.Exists(oFolderDXF) Then System.IO.Directory.CreateDirectory(oFolderDXF) End If ' Check whether the translator has 'SaveCopyAs' options If oDXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then Dim strIniFile As String strIniFile = "C:\Users\kasutaja\Documents\Inventor\MY support files\AI2012_to_DXF2004_NotAllSheets.ini" ' Create the name-value that specifies the ini file to use. oOptions.Value("Export_Acad_IniFile") = strIniFile End If Dim oCurrentNumber As Sheet oCurrentNumber = ThisApplication.ActiveDocument.ActiveSheet ' Iterate through the sheets Dim oSheet As Sheet For Each oSheet In ThisApplication.ActiveDocument.Sheets oSheet.Activate If oSheet.ExcludeFromPrinting = False Then 'run DXF code here Dim oSheetName As Object oSheetName = oSheet.Name() MessageBox.Show("I found variable: " & oSheetName , "Info") oDataMediumDXF.FileName = ThisDoc.PathAndFileName(False) oDataMediumDXF.FileName = oFolderDXF &"\"& oPN & "--" & oFileName & oSheetName & ".dxf" 'oDataMediumDXF.FileName = ThisDoc.PathAndFileName(False)'oDataMediumDXF.FileName = oFolderDXF &"\"& oPN & "--" & oFileName & ".dxf" oDXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMediumDXF) End If Next ' Return to original active sheet oCurrentNumber.Activate sSpace = "" sDots = " ---------- " MessageBox.Show("Drawing is printed as PDF and saved in : " & oFolderPDF _ & vbLf & ""& sDots _ & vbLf & ""& sSpace _ & vbLf & "Drawing is printed as DXF and saved in : "& oFolderDXF _ & vbLf & ""& sDots _ & vbLf & ""& sSpace _ & vbLf & " Click OK to save drawing and close this box. " , "DONE!") ThisDoc.Save Goto Alldone Endrule : MessageBox.Show("No PDF or DXF was saved ", "Info") Alldone :
Solved! Go to Solution.