Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
We build a code to export files with a specific filename.
In the code below we want to export the files with a code "-PI-".
This works fine in a topassembly.
This code is for the occurences(with a specific filename) in the top assembly.
Is it possible to do this for the complete assembly incl. the subassembly's?
And even beter is it possible to make a choise between the top or the complete assembly (incl. the subassembly's).
'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = ThisDoc.FileName(False) 'without extension If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'get user input RUsure = MessageBox.Show ( _ "This will create a STEP & JPG file for all components." _ & vbLf & " " _ & vbLf & "Are you sure you want to create STEP & JPG's for all of the assembly components?" _ & vbLf & "This could take a while.", "iLogic - Batch Output STEPs ",MessageBoxButtons.YesNo) If RUsure = vbNo Then Return Else End If '- - - - - - - - - - - - -Folder setup - - - - - - - - - - - - oPath = ThisDoc.Path 'get STEP target folder path oFolder = oPath & "\" & oAsmName & "Export" 'Check for the step folder and create it if it does not exist If Not System.IO.Directory.Exists(oFolder) Then System.IO.Directory.CreateDirectory(oFolder) End If '- - - - - - - - - - - - -Export selected parts- - - - - - - - - - - - 'define the active document as an assembly file Dim AssyDoc As AssemblyDocument = ThisDoc.Document Dim oOccurrencesToExport As New List(Of ComponentOccurrence) 'Select the part file contains a filename For Each oOcc As ComponentOccurrence In AssyDoc.ComponentDefinition.Occurrences Dim oFilename As String = oOcc.Definition.Document.displayname If oFilename.Contains("-PI-") Then oOccurrencesToExport.Add(oOcc) End If Next ''- - - - - - - - - - - - -Export all parts & assembly's in main & sub-assembly - - - - - - - - - - - - 'below the export loop to export all the component occurrences we saved in the list before. For Each oCompOcc As ComponentOccurrence In oOccurrencesToExport Dim oOccDoc As Document = oCompOcc.Definition.Document Dim oOccDocFillPath As String = oOccDoc.FullFileName Dim oFilenameWithoutExtension As String = System.IO.Path.GetFileNameWithoutExtension(oOccDocFillPath) 'Filename STP Dim oFullPathstp As String = String.Format("{0}\{1}.stp", oFolder, oFilenameWithoutExtension) 'save documents oOccDoc.SaveAs(oFullPathstp, True) Next
Solved! Go to Solution.