Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've put together some iLogic from different samples, but I have run into a real problem.
I'm trying to take a top level assembly and open all the parts referenced, and save a step file named as the part's "Part Number" to a specific folder.
It will cycle through but cant seam to put the individual part number. I've tried a few different options to pull the part number from the referenced part but just cant seam to make it work.
With the code below, I get an error saying the file *.ipt was not found.
the error is on line 47 I believe.
Any suggestions, ideas, or references would be much appreciated.
Regards
Darrell
If ThisApplication.ActiveDocument.DocumentType <> kAssemblyDocumentObject Then MessageBox.Show("Please run this rule from the assembly file.", "iLogic") Exit Sub End If 'define the active document as an assembly file Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument oAsmName = ThisDoc.FileName(False) 'without extension oAsmNameex=ThisDoc.FileName(True) oAsmPN= iProperties.Value(ThisApplication,"Project", "Part Number") 'MessageBox.Show (oAsmPN) 'get user input RUsure = MessageBox.Show ( _ "This will create a STEP file for all components." _ & vbLf & " " _ & vbLf & "Are you sure you want to create STEP Drawings 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 '- - - - - - - - - - - - -STEP setup - - - - - - - - - - - - oFolder = ("C:\Inventor STP") '- - - - - - - - - - - - -Assembly Export- - - - - - - - - - - - ThisDoc.Document.SaveAs(oFolder & "\" & oAsmPN &(".stp") , True) '- - - - - - - - - - - - -Components - - - - - - - - - - - - 'look at the files referenced by the assembly Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments Dim oRefDoc As Document 'work the referenced models For Each oRefDoc In oRefDocs Dim oCurFile As Document Dim oModelPN As String oCurFile = ThisApplication.Documents.Open(oRefDoc.FullFileName, True) oCurFileName = oCurFile.FullFileName oModelPN = iProperties.Value(oCurFileName,"Project", "Part Number") MessageBox.Show ("Part Number is" & oModelPN) If oRefDoc.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure Then 'defines backslash As the subdirectory separator Dim strCharSep As String = System.IO.Path.DirectorySeparatorChar Try oCurFile.SaveAs(oFolder & "\" & ShortName & (".stp") , True) MessageBox.Show(oCurFile) Catch MessageBox.Show("Error processing " & oCurFileName, "ilogic") End Try End If oCurFile.Close Next '- - - - - - - - - - - - - MessageBox.Show("New Files Created in: " & vbLf & oFolder, "iLogic") 'open the folder where the new files are saved Shell("explorer.exe " & oFolder,vbNormalFocus)
Solved! Go to Solution.