- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I created a Do until loop that will run through and make all my parts for me, while reading the parameters for each part from excel. I have the user input the values in the attached pictures before running the rule. My problem is that even though it correctly reads in the parameters from excel, and i've put in message boxes to show me that the parameters are correct throughout the rule, when the part gets to the save as, it only saves out the template. So even though throughout the creation of part 1, the width shows up as 20, when I open the part afterwards, the width is back to being 50.
Before I had it set up so that instead of having a do until loop it would bring up the save as dialog with the next name on the list and all I had to do was hold down the enter key until all the parts were made. That worked, but I was really hoping to automate it so that I could be working on other things while this ran.
This is the excel it is reading from:
SyntaxEditor Code Snippet
Sub Main() Dim row As Integer = 3 'the 2nd row in excel is the template information Dim CellVal As String = "Part" GoExcel.Open(ExcelFile, SheetName) Dim path As String = ThisDoc.Path & "\" Do Until CellVal = "" Dim columnLetter As String = "A" CellVal = GoExcel.CellValue(columnLetter & row) If CellVal = "" Then Exit Do ReadExcel(CellVal) 'read the excel value InventorVb.DocumentUpdate() 'update part to show new values SaveAsNew(CellVal) 'save as part with new name row=row+1 Loop End Sub Function ReadExcel(CellVal)
'this function reads in the values from excel
i = GoExcel.FindRow(ExcelFile, SheetName, "Part", "=", CellVal) 'find the row with the part name
'get values corresponding to that part name Width = GoExcel.CurrentRowValue("Width") Left_Angle = GoExcel.CurrentRowValue("Left Angle") Right_Angle = GoExcel.CurrentRowValue("Right Angle") iLogicVb.UpdateWhenDone = True
ThisDoc.Save End Function Function SaveAsNew(CellVal) Dim newname As String newname = NewPath & CellVal InventorVb.DocumentUpdate() ThisDoc.Save ThisDoc.Document.SaveAs(newname & ".ipt", True) End Function
Solved! Go to Solution.