VERSION 5.00 Begin VB.Form Form1 BorderStyle = 1 'Fixed Single Caption = "Reedmaker" ClientHeight = 3630 ClientLeft = 45 ClientTop = 330 ClientWidth = 4470 LinkTopic = "Form1" MaxButton = 0 'False ScaleHeight = 3630 ScaleWidth = 4470 StartUpPosition = 3 'Windows Default Begin VB.TextBox Text1 Height = 285 Index = 5 Left = 1200 TabIndex = 5 Text = "0" Top = 2040 Width = 1095 End Begin VB.TextBox Text1 Height = 285 Index = 4 Left = 1200 TabIndex = 4 Text = "0" Top = 1680 Width = 1095 End Begin VB.TextBox Text1 Height = 285 Index = 3 Left = 1200 TabIndex = 3 Text = "0" Top = 1320 Width = 1095 End Begin VB.TextBox Text1 Height = 285 Index = 2 Left = 1200 TabIndex = 2 Text = "1" Top = 840 Width = 1095 End Begin VB.TextBox Text1 Height = 285 Index = 1 Left = 1200 TabIndex = 1 Text = "10" Top = 480 Width = 1095 End Begin VB.ListBox List1 Height = 3375 Left = 2520 TabIndex = 8 Top = 120 Width = 1815 End Begin VB.TextBox Text1 Height = 285 Index = 0 Left = 1200 TabIndex = 0 Text = "10" Top = 120 Width = 1095 End Begin VB.CommandButton Command1 Caption = "Generate" Height = 375 Left = 1200 TabIndex = 6 Top = 3120 Width = 1215 End Begin VB.Line Line1 X1 = 120 X2 = 2280 Y1 = 1200 Y2 = 1200 End Begin VB.Label Label1 Caption = "Reed Height:" Height = 255 Index = 5 Left = 120 TabIndex = 13 Top = 2070 Width = 1095 End Begin VB.Label Label1 Caption = "Reed Length:" Height = 255 Index = 4 Left = 120 TabIndex = 12 Top = 1710 Width = 1095 End Begin VB.Label Label1 Caption = "Reed Width:" Height = 255 Index = 3 Left = 120 TabIndex = 11 Top = 1350 Width = 1095 End Begin VB.Label Label1 Caption = "Base Height:" Height = 255 Index = 2 Left = 120 TabIndex = 10 Top = 870 Width = 1095 End Begin VB.Label Label1 Caption = "Base Length:" Height = 255 Index = 1 Left = 120 TabIndex = 9 Top = 510 Width = 1095 End Begin VB.Label Label1 Caption = "Base Width:" Height = 255 Index = 0 Left = 120 TabIndex = 7 Top = 150 Width = 1095 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit '*********************************************************************************** '*********************************************************************************** '*********************************************************************************** '*********************************************************************************** '*********************************************************************************** Private Sub Gen_Reed(ByRef filename As String) 'Verify input data Dim Wb As Double, Lb As Double, Tb As Double, Wr As Double, Lr As Double, Tr As Double Wb = CDbl(Text1(0)): Lb = CDbl(Text1(1)): Tb = CDbl(Text1(2)) Wr = CDbl(Text1(3)): Lr = CDbl(Text1(4)): Tr = CDbl(Text1(5)) 'Sanity checks If Wb = 0 Or Lb = 0 Or Tb = 0 Then MsgBox "Base can not have zero volume.", vbCritical & vbOKOnly Exit Sub End If If Wr = 0 Or Lr = 0 Or Tr = 0 Then MsgBox "Reed can not have zero volume.", vbCritical & vbOKOnly Exit Sub End If If Wr > Wb Then MsgBox "Reed can not be wider than base.", vbCritical & vbOKOnly Exit Sub End If If Tr > Tb Then MsgBox "Reed can not be thicker than base.", vbCritical & vbOKOnly Exit Sub End If 'Calculate and cache (as strings) points used for defining the faces. Dim P1 As String, P2 As String, P3 As String, P4 As String, P5 As String, P6 As String, P7 As String, P8 As String Dim P9 As String, P10 As String, P11 As String, P12 As String, P13 As String, P14 As String, P15 As String, P16 As String 'Intermediate value to clean up some math Dim i As Double P1 = Join(Array(" vertex", 0, 0, 0), " ") P2 = Join(Array(" vertex", Lb, 0, 0), " ") P3 = Join(Array(" vertex", Lb, 0, Tb), " ") P4 = Join(Array(" vertex", 0, 0, Tb), " ") P5 = Join(Array(" vertex", 0, Wb, 0), " ") P6 = Join(Array(" vertex", Lb, Wb, 0), " ") P7 = Join(Array(" vertex", Lb, Wb, Tb), " ") P8 = Join(Array(" vertex", 0, Wb, Tb), " ") i = (Wb - Wr) / 2 P9 = Join(Array(" vertex", Lb, i, 0), " ") P10 = Join(Array(" vertex", Lb + Lr, i, 0), " ") P11 = Join(Array(" vertex", Lb + Lr, i, Tr), " ") P12 = Join(Array(" vertex", Lb, i, Tr), " ") i = i + Wr P13 = Join(Array(" vertex", Lb, i, 0), " ") P14 = Join(Array(" vertex", Lb + Lr, i, 0), " ") P15 = Join(Array(" vertex", Lb + Lr, i, Tr), " ") P16 = Join(Array(" vertex", Lb, i, Tr), " ") 'Let's output! Faces are defined by three points, counter-clockwise 'as viewed from the outside face. (The order of the points is how '"inside" and "outside" are defined) Open filename & "_reed.stl" For Output As #1 Print #1, "solid reed" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P2: Print #1, P3: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P3: Print #1, P4: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P8: Print #1, P5: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P4: Print #1, P8: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P5: Print #1, P8: Print #1, P7: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P5: Print #1, P7: Print #1, P6: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P4: Print #1, P3: Print #1, P8: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P3: Print #1, P7: Print #1, P8: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P9: Print #1, P2: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P13: Print #1, P9: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P5: Print #1, P13: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P5: Print #1, P6: Print #1, P13: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P2: Print #1, P9: Print #1, P12: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P2: Print #1, P12: Print #1, P3: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P3: Print #1, P12: Print #1, P16: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P3: Print #1, P16: Print #1, P7: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P7: Print #1, P16: Print #1, P6: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P6: Print #1, P16: Print #1, P13: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P9: Print #1, P11: Print #1, P12: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P9: Print #1, P10: Print #1, P11: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P12: Print #1, P11: Print #1, P16: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P16: Print #1, P11: Print #1, P15: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P13: Print #1, P16: Print #1, P15: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P13: Print #1, P15: Print #1, P14: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P10: Print #1, P15: Print #1, P11: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P10: Print #1, P14: Print #1, P15: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P9: Print #1, P13: Print #1, P10: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P13: Print #1, P14: Print #1, P10: Print #1, " endloop": Print #1, " endfacet" Print #1, "endsolid" Close End Sub '*********************************************************************************** '*********************************************************************************** '*********************************************************************************** '*********************************************************************************** '*********************************************************************************** Private Sub Gen_Plate(ByRef filename As String) 'Verify input data Dim Wb As Double, Lb As Double, Tb As Double, Wr As Double, Lr As Double, Tr As Double Wb = CDbl(Text1(0)): Lb = CDbl(Text1(1)): Tb = CDbl(Text1(2)) Wr = CDbl(Text1(3)): Lr = CDbl(Text1(4)): Tr = CDbl(Text1(5)) 'Sanity checks If Wb = 0 Or Lb = 0 Or Tb = 0 Then MsgBox "Base can not have zero volume.", vbCritical & vbOKOnly Exit Sub End If If Wr = 0 Or Lr = 0 Or Tr = 0 Then MsgBox "Reed can not have zero volume.", vbCritical & vbOKOnly Exit Sub End If If Wr > Wb Then MsgBox "Reed can not be wider than base.", vbCritical & vbOKOnly Exit Sub End If If Tr > Tb Then MsgBox "Reed can not be thicker than base.", vbCritical & vbOKOnly Exit Sub End If 'Calculate and cache (as strings) points used for defining the faces. Dim P1 As String, P2 As String, P3 As String, P4 As String, P5 As String, P6 As String, P7 As String, P8 As String Dim P9 As String, P10 As String, P11 As String, P12 As String, P13 As String, P14 As String, P15 As String, P16 As String 'Intermediate value to clean up some math Dim i As Double Wb = Wb + 2 P1 = Join(Array(" vertex", 0, 0, 0), " ") P2 = Join(Array(" vertex", 30, 0, 0), " ") P3 = Join(Array(" vertex", 30, 0, 1), " ") P4 = Join(Array(" vertex", 0, 0, 1), " ") P5 = Join(Array(" vertex", 0, Wb, 0), " ") P6 = Join(Array(" vertex", 30, Wb, 0), " ") P7 = Join(Array(" vertex", 30, Wb, 1), " ") P8 = Join(Array(" vertex", 0, Wb, 1), " ") Wr = Wr + 0.5 i = (Wb - Wr) / 2 P9 = Join(Array(" vertex", Lb, i, 0), " ") P10 = Join(Array(" vertex", Lb + Lr + 0.25, i, 0), " ") P11 = Join(Array(" vertex", Lb + Lr + 0.25, i, 1), " ") P12 = Join(Array(" vertex", Lb, i, 1), " ") i = i + Wr P13 = Join(Array(" vertex", Lb, i, 0), " ") P14 = Join(Array(" vertex", Lb + Lr + 0.25, i, 0), " ") P15 = Join(Array(" vertex", Lb + Lr + 0.25, i, 1), " ") P16 = Join(Array(" vertex", Lb, i, 1), " ") Open filename & "_plate.stl" For Output As #1 Print #1, "solid plate" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P2: Print #1, P3: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P3: Print #1, P4: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P4: Print #1, P8: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P8: Print #1, P5: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P5: Print #1, P8: Print #1, P7: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P5: Print #1, P7: Print #1, P6: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P2: Print #1, P6: Print #1, P7: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P2: Print #1, P7: Print #1, P3: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P9: Print #1, P12: Print #1, P11: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P9: Print #1, P11: Print #1, P10: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P9: Print #1, P13: Print #1, P16: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P9: Print #1, P16: Print #1, P12: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P13: Print #1, P14: Print #1, P15: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P13: Print #1, P15: Print #1, P16: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P10: Print #1, P11: Print #1, P15: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P10: Print #1, P15: Print #1, P14: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P9: Print #1, P2: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P10: Print #1, P2: Print #1, P9: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P1: Print #1, P5: Print #1, P9: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P5: Print #1, P6: Print #1, P13: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P13: Print #1, P6: Print #1, P14: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P2: Print #1, P14: Print #1, P6: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P2: Print #1, P10: Print #1, P14: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P5: Print #1, P13: Print #1, P9: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P4: Print #1, P12: Print #1, P8: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P4: Print #1, P3: Print #1, P12: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P12: Print #1, P3: Print #1, P11: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P3: Print #1, P15: Print #1, P11: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P3: Print #1, P7: Print #1, P15: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P7: Print #1, P16: Print #1, P15: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P7: Print #1, P8: Print #1, P16: Print #1, " endloop": Print #1, " endfacet" Print #1, " facet normal 0 0 0": Print #1, " outer loop": Print #1, P8: Print #1, P12: Print #1, P16: Print #1, " endloop": Print #1, " endfacet" Print #1, "endsolid" Close End Sub Private Sub Command1_Click() Gen_Reed App.Path & "\test" Gen_Plate App.Path & "\test" End Sub