Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' #ifndef HaveMain
- ' #error "don't compile this"
- ' #endif
- ' Define macros for common constants and calculations
- const LDU = 1 /' LDRAW Unit '/
- const H = 4 /' Half plate '/
- const P = 8 /' Plate '/
- const L = 20 /' Module '/
- const B = 24 /' Brick '/
- const S = 16 /' Slab '/
- const _1d5 = 30 /' 1.5L '/
- const _0d5 = 10 /' 0.5L '/
- ' Function to convert units from LDU to other measurements
- Function ConvertToLDU(ByVal unitType As String, ByVal value As Integer) As Integer
- Select Case unitType
- Case "L"
- Return value * LDU
- Case "P"
- Return value * P
- Case "B"
- Return value * B
- Case Else
- Return value ' Assume value is already in L
- End Select
- End Function
- ' Box dimensions (assuming 2L x 2L x 2L)
- Dim As UInteger boxX = ConvertToLDU("L", 2)
- Dim As UInteger boxY = ConvertToLDU("L", 2)
- Dim As UInteger boxZ = ConvertToLDU("L", 2)
- Dim As UInteger box(3) = {boxX, boxY, boxZ}
- Type Part
- As Long X
- As Long Y
- As Long Z
- As String PartType
- End Type
- Sub PrintPartDetails(ByRef pt As Part, ByVal PartID As String, ByVal description As String)
- Print "The part description for " & PartID & " is: " & description
- Print "The part type for " & PartID & " is: " & pt.PartType
- Print "The dimensions of part " & PartID & " are:"
- Print " " & pt.X & " LDU x " & pt.Y & " LDU x " & pt.Z & " LDU"
- Print " " & (pt.X / LDU) & " L x " & (pt.Y / LDU) & " L x " & (pt.Z / LDU) & " L"
- Print " " & (pt.X / P) & " P x " & (pt.Y / P) & " P x " & (pt.Z / P) & " P"
- Print " " & (pt.X / B) & " B x " & (pt.Y / B) & " B x " & (pt.Z / B) & " B"
- End Sub
- Function PartsFitInBox(ByRef prt As Part, ByVal boxX As UInteger, ByVal boxY As UInteger, ByVal boxZ As UInteger) As Long
- Dim As Long countX, countY, countZ
- countX = boxX \ prt.X
- countY = boxY \ prt.Y
- countZ = boxZ \ prt.Z
- Return countX * countY * countZ
- End Function
- Dim PartID As String
- while (1)
- Input "Please Enter a part ID (e.g. 18654, 43857, 32132a, 41677): ", PartID
- Select Case PartID
- Case "18654"
- Dim _18654 As Part
- _18654.X = ConvertToLDU("L", 1)
- _18654.Y = ConvertToLDU("L", 1)
- _18654.Z = ConvertToLDU("L", 1)
- _18654.PartType = "LA"
- PrintPartDetails(_18654, PartID, "1L x 1L x 1L beam.")
- Print "This part fits " & PartsFitInBox(_18654, box(0), box(1), box(2)) & !" times inside the box.\n"
- Case "43857"
- Dim _43857 As Part
- _43857.X = ConvertToLDU("L", 1)
- _43857.Y = ConvertToLDU("L", 2)
- _43857.Z = ConvertToLDU("L", 1)
- _43857.PartType = "LA"
- PrintPartDetails(_43857, PartID, "1L x 2L x 1L beam.")
- Print "This part fits " & PartsFitInBox(_43857, box(0), box(1), box(2)) & !" times inside the box.\n"
- Case "32132a"/' 1L x 1L x 0.5L bush '/
- Dim _32132a As Part
- _32132a.X = ConvertToLDU("L", 1)
- _32132a.Y = ConvertToLDU("L", 1)
- _32132a.Z = ConvertToLDU("L", 0.5)
- _32132a.PartType = "BU"
- PrintPartDetails(_32132a, PartID, "1L x 1L x 0.5L hush.")
- Print "This part fits " & PartsFitInBox(_32132a, box(0), box(1), box(2)) & !" times inside the box.\n"
- Case "41677" /' 1L x 2L x 0.5L beam '/
- Dim _41677 As Part
- _41677.X = ConvertToLDU("L", 1)
- _41677.Y = ConvertToLDU("L", 2)
- _41677.Z = ConvertToLDU("L", 0.5)
- _41677.PartType = "LA"
- PrintPartDetails(_41677, PartID, "1L x 2L x 0.5L beam.")
- Print "This part fits " & PartsFitInBox(_41677, box(0), box(1), box(2)) & !" times inside the box.\n"
- Case Else
- Print !"You have entered an invalid part ID.\n"
- End Select
- wend
- Sleep
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement