Message 1 of 8

Not applicable
01-07-2016
08:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have the following piece of code that I'd like to be able to run in any assembly to check that the flat sizes of my sheet metal parts are not over the maximum stock sizew. I originally had the section highlighted in red as a rule on it's own that I could run at part level, which worked perfectly. But it would be hugely useful to have a rule that ran through the same check on all the sub-parts of my assembly. I don't recieve any errors with this bit of code, but its not returning the error message box that it should to tell me the dimensions are too large. Is the code actually running through each sub-part?
Dim openDoc As Document openDoc = ThisDoc.Document Dim docFile As Document If openDoc.DocumentType = 12291 Then For Each docFile In openDoc.AllReferencedDocuments If docFile.DocumentType = 12290 Then InventorVb.DocumentUpdate() 'Obtain max & min flat sizes of part x = MaxOfMany(SheetMetal.FlatExtentsLength, SheetMetal.FlatExtentsWidth) y = MinOfMany(SheetMetal.FlatExtentsLength, SheetMetal.FlatExtentsWidth) 'Read R number of part material1 = (Left(iProperties.Material(False),6)) 'Read max stock sizes of material GoExcel.TitleRow = 3 i = GoExcel.FindRow("F:\Reports\RPT-E2I-012 - Parts Costing.xls", "Parts Costing", "Part Num", "=", material1) maxX = GoExcel.CurrentRowValue("size_x") maxY = GoExcel.CurrentRowValue("size_y") 'Check flat sizes don't exceed stock sizes If x > maxX Or y > maxY Then MessageBox.Show("Your dimensions are too large." & vbLf & "Max dimensions are: " & maxX & " x " & maxY & vbLf & "Your dimensions are: " & Ceil(x) & " x " & Ceil(y), "ERROR!",MessageBoxButtons.OK,MessageBoxIcon.Error) RuleParametersOutput() InventorVb.DocumentUpdate() End If End If Next Else MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) End If
Solved! Go to Solution.