ilogic code iges

ilogic code iges

JamieSENG
Advocate Advocate
974 Views
4 Replies
Message 1 of 5

ilogic code iges

JamieSENG
Advocate
Advocate

I use the below code to batch export dwgs to an external folder. I wanted to use the same method to export all open ipts to iges but doesn't work. I edited the code so it recognized it was a part and not a drawing and it runs with no errors but doesn't actually work.

 

Imports SysIO = System.IO
Sub Main()
'See if there are any open views
If (ThisApplication.Views.Count > 0) Then
'Setup Translator to dwg
Dim DWGAddIn As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
'Go through each view and save if it's a drawing document
For Each view As View In ThisApplication.Views
If view.Document.DocumentType = kDrawingDocumentObject Then
'Get the directory file is saved in. Can replace this with specific directory
Dim dwgDir = "C\tempdwg\"
'Get name Of file without the extension And add Rev. To it.
oDataMedium.MediumType = kFileNameMedium

oDataMedium.FileName = dwgDir & _
 SysIO.Path.GetFileNameWithoutExtension(view.Document.FullFileName) & _
 " - Rev. " & ".dwg"

' Check whether the translator has 'SaveCopyAs' options
If DWGAddIn.HasSaveCopyAsOptions(view.Document, oContext, oOptions) Then
'Use Export To DWG to save drawing configuration and set here
Dim strIniFile As String = "C:\batchsettingsini.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
'Save File
Call DWGAddIn.SaveCopyAs(view.Document, oContext, oOptions, oDataMedium)

End If
End If
Next
End If
End Sub

Any ideas how this can be achieved?

0 Likes
Accepted solutions (1)
975 Views
4 Replies
Replies (4)
Message 2 of 5

JamieSENG
Advocate
Advocate

Anyone? Any help or guidance would be greatly appreciated.

0 Likes
Message 3 of 5

MechMachineMan
Advisor
Advisor

It's a completely different translator/addin you need to use to export step files....

 

Search the forums and I'm sure you will quickly find a working STEP/iges export feature.

 

A 3d Export translator should work across multiple 3d filetype formats.


--------------------------------------
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 4 of 5

JamieSENG
Advocate
Advocate
Accepted solution

I had modified the code in my first post to use the addin for step and iges I just didn't have it at hand when I wrote it.

 

I'm my example below I changed the kdrawingdocumentobject to kpartdocumentobject and it seems to have done what I require.

 

Imports SysIO = System.IO
Sub Main()
'See if there are any open views
If (ThisApplication.Views.Count > 0) Then
' Get the IGES translator Add-In.
Dim oIGESTranslator As TranslatorAddIn
oIGESTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F44-0C01-11D5-8E83-0010B541CD80}")
Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium = ThisApplication.TransientObjects.CreateDataMedium

'Go through each view and save if it's a drawing document
For Each view As View In ThisApplication.Views
If view.Document.DocumentType = kPartDocumentObject Then
'Get the directory file is saved in. Can replace this with specific directory
Dim IGESDir = "C:\IGES\"
'Get name Of file without the extension And add _acad2k To it.
oDataMedium.MediumType = kFileNameMedium

oDataMedium.FileName = IGESDir & _
 SysIO.Path.GetFileNameWithoutExtension(view.Document.FullFileName) & _
 " - Rev. " & ".igs"

' Check whether the translator has 'SaveCopyAs' options
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)

'Use Export To IGES to save drawing configuration and set here
'Dim strIniFile As String = "C:\IGES\Format2000DONOTDELETE.ini"
' Create the name-value that specifies the ini file to use.
'oOptions.Value("Export_Acad_IniFile") = strIniFile
'Save File
Call oIGESTranslator.SaveCopyAs(view.Document, oContext, oOptions, oDataMedium)
End If
End If
Next
End If
End Sub
0 Likes
Message 5 of 5

JamieSENG
Advocate
Advocate

I've confirmed the above does create a working iges file. Happy days, I've now got the means to export on a single level drawing view and part views of multiple formats as well as batch exports of the same.

 

I have a global form that I have to access all of these options. Anyone that comes across this post that required similar let me know I'm more than happy to share.

0 Likes