Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have an iLogic rule that lets me export selected parts from assembly as step files.
I want to add a modification so that when i select parts and run the rule, then a folder browser pops up and lets me choose where i want to save selected parts. Now it just saves step files in the same directory that the part files are located, but i want to be able to choose where i want to save .step files.
Rule i use for exporting selected files is from this forum, posted by marcin_otręba.
The rule:
Public Sub Main() 'MsgBox("BOM QTY Update ") Dim ass As AssemblyDocument= ThisApplication.ActiveDocument Dim oselset As SelectSet = ass.SelectSet Dim i As Integer = 0 Dim result As Boolean Dim occ As ComponentOccurrence If oselset.Count<>0 Then For Each occ In oselset Dim doc As Document = occ.Definition.Document ' Update or create the custom iProperty. result=ExportToSTEP(doc) If result = True Then i = i + 1 End If Next
MessageBox.Show(i & " files successfully exported", "result") Else MessageBox.Show("You must select files to export before running rule", "Error") End If End Sub 'Here's the subroutine. Function ExportToSTEP(doc As Document) As Boolean ' Get the STEP translator Add-In. Dim oSTEPTranslator As TranslatorAddIn oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") If oSTEPTranslator Is Nothing Then MsgBox("Could not access STEP translator.") ExportToSTEP=False Exit Function End If Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap If oSTEPTranslator.HasSaveCopyAsOptions(doc, 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 oData = ThisApplication.TransientObjects.CreateDataMedium oData.FileName = Replace(Replace(doc.fullfilename,".ipt",""),".iam","") & ".stp" Call oSTEPTranslator.SaveCopyAs(doc, oContext, oOptions, oData) ExportToSTEP=True End If End Function
Solved! Go to Solution.