- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I searched the forums and found answers to similar questions but not the exact process I would like to achieve.
I have an iAssembly with 720 members in the factory. I would like to use iLogic to export each member to a *.stp file so I don't have to do it manually.
I am unfamiliar with the code but I managed to merge the code from 3 different forum posts to create what I have below. It will open each factory member, save it as a *.iam assembly, and close it, but it does not export it as a *.stp file. It also ignores the path I specify and creates a new folder with the same name as the assembly.
Does anyone have any suggestions on the code changes needed to get this to export each member as a *.stp file?
' Set reference to active document. oDoc = ThisApplication.ActiveDocument ' Check the Document type is an assembly or part If (oDoc.DocumentType <> kAssemblyDocumentObject And _ oDoc.DocumentType <> kPartDocumentObject) Then MsgBox("Error:Document type is not assembly/part") Exit Sub End If Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition Dim initRowIndex As Integer Dim oFactory As iAssemblyFactory = oDef.iAssemblyFactory Dim oRow As iAssemblyTableRow Dim oMember As iAssemblyMember For Each oRow In oFactory.TableRows ' Generate the member and file, (overwrites member file or creates new file) oFactory.CreateMember(oRow) Dim oPath As String oPath = oFactory.MemberCacheDir Dim oReferDoc As AssemblyDocument oReferDoc = ThisApplication.Documents.Open(oPath & "\" & oRow.MemberName & ".iam", True) 'Dim oName As String 'oName = oReferDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value ThisApplication.SilentOperation = True ' Get the STEP translator Add-In. Dim oSTEPTranslator As TranslatorAddIn oSTEPTranslator = ThisApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}") Dim oContext As TranslationContext oContext = ThisApplication.TransientObjects.CreateTranslationContext Dim oOptions As NameValueMap oOptions = ThisApplication.TransientObjects.CreateNameValueMap partNumber = iProperties.Value("Project", "Part Number") SavePath = "C:\Users\Inventor\Part Files\Step Files\" 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 = IOMechanismEnum.kFileBrowseIOMechanism Dim oData As DataMedium oData = ThisApplication.TransientObjects.CreateDataMedium oData.FileName = SavePath & partNumber & ".stp" oSTEPTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData) End If oReferDoc.Close ThisApplication.SilentOperation = False Next
Solved! Go to Solution.