
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am writing a program that calculates the price of a part based on an Excel spreadsheet.
The only feature I am missing at the moment is that I would like the program to highlight each part as it steps through them so the user can follow along and see that each part has been calculated.
I am not picky on how the highlighting happens. It could color the whole part red or something, but it needs to be put back to it's original appearance when the program ends. I have pasted my code below. I've included the lines of code that I've been tinkering with for highlighting.
Keep in mind that I'm a very beginner programmer (this is actually my first iLogic program) so if anything looks weird of sub-optimal it's because I don't know any better. I would also appreciate general comments on how the code could be done better.
Any ideas?
' Get the active assembly document. Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument ' Iterate through all of the documents referenced by the assembly. Dim oDoc As Document For Each oDoc In oAsmDoc.AllReferencedDocuments ' Verify that the document is a part. If oDoc.DocumentType = kPartDocumentObject Then Dim oPartDoc As PartDocument = oDoc Dim model As String = oPartDoc.DisplayName model = model & ".ipt" 'Manipulate part 'Highlight part in question 'Component.Color(oDoc) = "Red" oPartDoc.ActiveRenderStyle = oAsmDoc.RenderStyles.Item("Red") 'Specify Excel file used for pricing ExcelFile = "F:\blablabla\Stock Parts Prices.xlsx" 'Look up whether or not the part is priced by inch or lb in the excel sheet Dim CostTypeRow As Integer = GoExcel.FindRow(ExcelFile, "Sheet1", "Stock Type", "=", iProperties.Value(model,"Project", "Stock Number")) Dim CostType As String If CostTypeRow = -1 Then CostType = "NULL" ElseIf CostTypeRow > 0 Then CostType = GoExcel.CellValue(ExcelFile, "Sheet1", "C" & CostTypeRow) 'Look up cost of that part Cost = GoExcel.CellValue(ExcelFile, "Sheet1", "B" & CostTypeRow) End If If CostType = "POUND" Then mass = iProperties.Mass(model) TotalCost = Cost * mass iProperties.Value(model,"Project", "Estimated Cost") = TotalCost Else If CostType = "INCH" Then Try length = Parameter(model, "B_L") MessageBox.Show("Detected Length = " & Parameter(model, "B_L"), model) Catch length = InputBox("Input length of part:", iProperties.Value(model,"Summary", "Title") & " " & iProperties.Value(model,"Project", "Stock Number"), "0") End Try TotalCost = length * Cost iProperties.Value(model,"Project", "Estimated Cost") = TotalCost End If Else End If Next MessageBox.Show("Son", "Done")
Solved! Go to Solution.