Export to STP file with user input name

Export to STP file with user input name

ober2558
Enthusiast Enthusiast
303 Views
2 Replies
Message 1 of 3

Export to STP file with user input name

ober2558
Enthusiast
Enthusiast

I am looking for a code that will export an assembly as a step file, located in the same folder as the assembly and saved under a user inputted file name. I am not very experienced with iLogic so any help you can provide would be greatly appreciated 

0 Likes
Accepted solutions (1)
304 Views
2 Replies
Replies (2)
Message 2 of 3

vpeuvion
Advocate
Advocate
Accepted solution

Hi,

You can try this code taken from this post and modified for your needs:

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/save-as-step-using-ilogic/td-p/57671...

 

Sub Main()
	Dim Name As String  = InputBox("Enter name", "Name", "Default Name") 'Get the name
	Dim Location As String = ThisDoc.Path 'Get the location

    ' Get the STEP translator Add-In.
    Dim oSTEPTranslator As TranslatorAddIn = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")

    If oSTEPTranslator Is Nothing Then
        MessageBox.Show( "Could not access STEP translator.")
        Exit Sub
    End If

    Dim oContext As TranslationContext = ThisApplication.TransientObjects.CreateTranslationContext
    Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
    If oSTEPTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then
        ' Set application protocol.
        ' 2 = AP 203 - Configuration Controlled Design
        ' 3 = AP 214 - Automotive Design
        oOptions.Value("ApplicationProtocolType") = 3

        ' Other options...
        'oOptions.Value("Author") = ""
        'oOptions.Value("Authorization") = ""
        'oOptions.Value("Description") = ""
        'oOptions.Value("Organization") = ""

        oContext.Type = kFileBrowseIOMechanism

        Dim oData As DataMedium = ThisApplication.TransientObjects.CreateDataMedium
        oData.FileName = Location & "\" & Name & ".stp" ' Create File name

        Call oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
    End If
End Sub

Hope this will help you.

Vincent 

Message 3 of 3

ober2558
Enthusiast
Enthusiast

Perfect, Thank you!