Exporting multi-sheet IDW to dxf (ilogic)

Exporting multi-sheet IDW to dxf (ilogic)

Darius_CAD
Enthusiast Enthusiast
5,442 Views
21 Replies
Message 1 of 22

Exporting multi-sheet IDW to dxf (ilogic)

Darius_CAD
Enthusiast
Enthusiast

Hello,

 

I have already explored some of the posts regarding this subject.  But didn't find a solution.

 

Problem:   When I run rule (exporting multi-sheet IDW to DXF), DXF files have unnecessary first symbol "_" (please look at "1" .jpg).

I need:      That rule will check: if file name has this symbol "_" - delete (or skip this symbol), if file name not have it (when idw has one sheet), just leave file name.

 

My rule (exporting IDW to DXF):

' 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 = "C:\CAD_2007.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 
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension

'----
'get DXF target folder path
oFolder = oPath & "\1.2_DXF"

'Check for the DXF 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 & "\" & "" &".dxf"

'long name
'oDataMedium.FileName = oFolder & "\" & oFileName &".dxf"

'-----
'oDataMedium.FileName = ThisDoc.PathAndFileName(False) & ".dxf" 'same folder, or uncomment:
'oDataMedium.FileName = "C:\myDXFfolder\" & ThisDoc.FileName(False) & ".dxf" 'fixed folder
'Publish document.
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)

 

Any help would help out alot.... thanks!

 

 

0 Likes
Accepted solutions (1)
5,443 Views
21 Replies
Replies (21)
Message 2 of 22

bradeneuropeArthur
Mentor
Mentor
Add this to remove the _

'get DXF target folder path
oFolder = oPath & "\1.2_DXF"
Try
oFolder= oFolder.replace("_","")
Catch
end try

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 22

bradeneuropeArthur
Mentor
Mentor
Or better.

long name '

Try
oFilename.replace("_","")
Catch

End try
oDataMedium.FileName = oFolder & "\" & oFileName &".dxf"

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 22

Darius_CAD
Enthusiast
Enthusiast

Thank you for your reply.

But it didn't help, but something wrong with my knowledge:)

Please look at again.

' 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 = "C:\CAD_2007.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 
oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension

'----
'get DXF target folder path
oFolder = oPath & "\1.2_DXF"

'Check for the DXF 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


Try
oFilename.Replace("_","")
Catch

End Try
oDataMedium.FileName = oFolder & "\" & "" &".dxf"  ' Instead of "oFileName" I use this symbol "", because oFileName is IDW file name but I need just sheet name (2.jpg)


'-----
DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
0 Likes
Message 5 of 22

bradeneuropeArthur
Mentor
Mentor
You need to define a fix filename!!

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 22

Darius_CAD
Enthusiast
Enthusiast

Sorry, I don't understand. "You need to define a fix filename!!"  (I am knew in ilogic:(

 

I not need IDW file name, I just need IDW sheets names, but Inventor, when you saving multi-sheet IDW to dxf, add symbol "_".

Imposible save its without "_"?

 

Thank you for your time.

0 Likes
Message 7 of 22

bradeneuropeArthur
Mentor
Mentor
Where is your filename used. I cannot see that in your code.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 8 of 22

Darius_CAD
Enthusiast
Enthusiast

 

 

.......
End Try oDataMedium.FileName = oFolder & "\" & "" &".dxf" ' Instead of "oFileName" I use this symbol "", because oFileName is IDW file name but I need just sheet name (2.jpg)
......

I not need IDW file name, so I just skip it. So I get good result: --> sheet name without IDW file name --> "_Sheet1" and "_Sheet2" ;So, after it, I have delete "_" manually.

 

If I save to dxf IDW (without ilogic rule), my result is:  FileName_Sheet1, FileName_Sheet2, ....

 

If I save to dxf with my rule, my result is :  _Sheet1, _Sheet2, ....

 

Maybe can use code, which delete FileName +1 symbol?  FileName_Sheet1    (Red symbols delete) ---> So result is       Sheet1, Sheet2,.....

 

0 Likes
Message 9 of 22

MechMachineMan
Advisor
Advisor

AFAIK, you have 2 options:

 

1. Change your code to only export 1 sheet at a time so you have full control over the file name and so it doesn't append sheet name. This would mean you would also have to change your code to cycle through each page and export each page individually.

 

2. Keep it the way it is, but use the FileSystemObject or System.IO functions to modify the filename AFTER it has been saved.

 

Good luck!


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 10 of 22

Darius_CAD
Enthusiast
Enthusiast

MechMachine,

 

Thank you for your advice, but it is uncomfortable, when you have ~50 multi-sheet for exporting to dxf.

 

0 Likes
Message 11 of 22

MechMachineMan
Advisor
Advisor

No, it's not "uncomfortable"!?

 

It's all handled in the programming. So change your code to suit 1 of those 2 options, and you'll be on your merry way with working code.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 12 of 22

Darius_CAD
Enthusiast
Enthusiast

Sorry for my English, I will try, but my programming knowledge is basic:) I will try thank you.

0 Likes
Message 13 of 22

MechMachineMan
Advisor
Advisor

@Darius_CAD try the code below.

 

BUT FIRST, either export a new file with all sheets unchecked, or go to the ini and change the line "All Sheets = Yes" to "All Sheets = No".

 

Dim oDocument As DrawingDocument  
oDocument = ThisApplication.ActiveDocument  

oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oFolder = oPath & "\" & oFileName

'Check for the DXF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If Dim DXFAddIn As TranslatorAddIn DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}") Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap
'The below line might give issues depending on inventor version. Check forums if you are encountering issues. If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then Dim strIniFile As String strIniFile = "C:\CAD_2007.ini" oOptions.Value("Export_Acad_IniFile") = strIniFile End If Dim oDataMedium As DataMedium oDataMedium = ThisApplication.TransientObjects.CreateDataMedium Dim oSheetName As String For Each oSheet In oDocument.Sheets oSheetName = oSheet.Name oDataMedium.FileName = oFolder & "\" & oSheetName & ".dxf" DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium) Next

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 14 of 22

Darius_CAD
Enthusiast
Enthusiast

Nice, file naming is working, but not converting to dxf. I got just files with 0 bites and not dxf (attached). Have you any ideas?

 

Thank you for your time.

 

0 Likes
Message 15 of 22

MechMachineMan
Advisor
Advisor

2 things to try:

- If you just went into the ini file, try exporting a fresh one and using the code to change that.

- If that doesn't fix it, either add a message box to test that it is working, or just comment out the "HasSaveCopyAsOptions" line and try it again.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 16 of 22

Darius_CAD
Enthusiast
Enthusiast

hm.. not working for me.

0 Likes
Message 17 of 22

MechMachineMan
Advisor
Advisor

Neither of those fixes did anything for you?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 18 of 22

MechMachineMan
Advisor
Advisor
Accepted solution

Ok... A couple tweaks were required.

 

1. It was not spitting out the proper sheet name and was not getting rid of the ":1" portion of the sheet name.

2. It was not activating each sheet.

 

Below has those issues fixed.

 

NOTE: Identical sheet names will just overwrite each other, so each sheet name must be unique.

 

Dim oDocument As DrawingDocument  
oDocument = ThisApplication.ActiveDocument  

oPath = ThisDoc.Path
oFileName = ThisDoc.FileName(False) 'without extension
oFolder = oPath & "\" & oFileName

'Check for the DXF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
    System.IO.Directory.CreateDirectory(oFolder)
End If

Dim DXFAddIn As TranslatorAddIn  
DXFAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC4-122E-11D5-8E91-0010B541CD80}")  
  
Dim oContext As TranslationContext  
oContext = ThisApplication.TransientObjects.CreateTranslationContext  
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism  

Dim oOptions As NameValueMap  
oOptions = ThisApplication.TransientObjects.CreateNameValueMap  

'The below line might give issues depending on inventor version. Check forums if you are encountering issues.
If DXFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
    Dim strIniFile As String  
    strIniFile = "C:\CAD_2007.ini"  
    oOptions.Value("Export_Acad_IniFile") = strIniFile  
End If  

Dim oDataMedium As DataMedium  
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium  

Dim oSheetName As String

For Each oSheet In oDocument.Sheets
	oSheet.Activate
    oSheetName = oSheet.Name.Split(":")(0)
    oDataMedium.FileName = oFolder & "\" & oSheetName & ".dxf"
	MsgBox(oDataMedium.FileName)
    DXFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
Next 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 19 of 22

Darius_CAD
Enthusiast
Enthusiast

Amaizing!

 

Best luck for you!

 

Thank you!

 

 

0 Likes
Message 20 of 22

aronmatheus
Advocate
Advocate

If I case have more 3 sheets, He prints 3 times? I observed the drawing staying misconfiguration! 

0 Likes