Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help w/ code creating iges of each part in an Assy

1 REPLY 1
SOLVED
Reply
Message 1 of 2
jpblower
200 Views, 1 Reply

Help w/ code creating iges of each part in an Assy

Public Sub SendIGES()

    ' Get the IGES translator Add-In.
    Dim oIGESTranslator As TranslatorAddIn
    Set oIGESTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F44-0C01-11D5-8E83-0010B541CD80}")
    
    Dim oContext As TranslationContext
    Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
    
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
    
    Dim oData As DataMedium
    Set oData = ThisApplication.TransientObjects.CreateDataMedium
    
    Dim i As Long 'Counter for For loop
    
    Dim oAssyDoc As AssemblyDocument
    Set oAssyDoc = ThisApplication.ActiveDocument
    
    Dim oAssyCompDef As AssemblyComponentDefinition
    Set oAssyCompDef = oAssyDoc.ComponentDefinition
    
    Dim oPartDoc As PartDocument
    
    Dim oPartCompDef As PartComponentDefinition
        
    oContext.Type = kFileBrowseIOMechanism
    
    Dim oOcc As ComponentOccurrence
    i = 1
    
    For Each oOcc In oAssyCompDef
        Set oPartDoc = oAssyCompDef.Occurrences.Item(i)
        Set oPartCompDef = oPartDoc.ComponentDefinition
        
        oData.FileName = "C:\Users\JBL09\Desktop\iges test\Temptest_" & i & ".igs"
        Call oIGESTranslator.SaveCopyAs(oPartCompDef, oContext, oOptions, oData)
        i = i + 1
    Next
    
End Sub

 I have this code to try to export an iges file for each part in an assy.  However, I get an error when the code tries to run the For loop.  What gives?

 

 

1 REPLY 1
Message 2 of 2
jpblower
in reply to: jpblower

I figured it out.  For anyone wanting to know here's the new For loop that works.

 

    For Each oOcc In oAssyCompDef.Occurrences
        oData.FileName = "C:\iges test\Temptest_" & i & ".igs"
        Call oIGESTranslator.SaveCopyAs(oOcc.Definition.Document, oContext, oOptions, oData)
        i = i + 1
    Next

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report