Exporting .ipt to .igs with custom filename

Exporting .ipt to .igs with custom filename

PDX_Matt
Explorer Explorer
947 Views
3 Replies
Message 1 of 4

Exporting .ipt to .igs with custom filename

PDX_Matt
Explorer
Explorer

Hello,

 

I am trying to tweak the iLogic Snippet for "Save As IGES File" so that it will save the file to a new folder called "IGES" and have the file name be the iProperty "Part Number".  I can add "iProperties.Value("Project", "Part Number")" at the file name part, but it still has the original name that i have to go back and delete.  I just want the file named as the Part Number and put in a new folder.

 

Help!

 

Here is the current code i have:

' Get the IGES translator Add-In.
Dim oIGESTranslator As TranslatorAddIn
oIGESTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F44-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
If oIGESTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
   ' Set geometry type for wireframe.
   ' 0 = Surfaces, 1 = Solids, 2 = Wireframe
   oOptions.Value("GeometryType") = 1
   ' To set other translator values:
   ' oOptions.Value("SolidFaceType") = n
   ' 0 = NURBS, 1 = Analytic
   ' oOptions.Value("SurfaceType") = n
   ' 0 = 143(Bounded), 1 = 144(Trimmed)
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oData As DataMedium
oData = ThisApplication.TransientObjects.CreateDataMedium
oData.FileName = ThisDoc.PathAndFileName(False) & iProperties.Value("Project", "Part Number") & ".igs"
oIGESTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If
0 Likes
Accepted solutions (1)
948 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor
Accepted solution
' Get the IGES translator Add-In.
Dim oIGESTranslator As TranslatorAddIn
oIGESTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F44-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext
oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
If oIGESTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
   ' Set geometry type for wireframe.
   ' 0 = Surfaces, 1 = Solids, 2 = Wireframe
   oOptions.Value("GeometryType") = 1
   ' To set other translator values:
   ' oOptions.Value("SolidFaceType") = n
   ' 0 = NURBS, 1 = Analytic
   ' oOptions.Value("SurfaceType") = n
   ' 0 = 143(Bounded), 1 = 144(Trimmed)
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
Dim oData As DataMedium
oData = ThisApplication.TransientObjects.CreateDataMedium
oData.FileName = ThisDoc.Path & "\" & iProperties.Value("Project", "Part Number") & ".igs"
oIGESTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
End If

--------------------------------------
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
Message 3 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @PDX_Matt,

 

Change the path of oData.FileName to following line.

 

oData.FileName = ThisDoc.Path & "\IGES\" & iProperties.Value("Project", "Part Number") & ".igs"

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 4 of 4

PDX_Matt
Explorer
Explorer

Thank you for the help!!

0 Likes