Advertisement
retroman

Untitled

Jul 22nd, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. ' #ifndef HaveMain
  2. ' #error "don't compile this"
  3. ' #endif
  4.  
  5. ' Define macros for common constants and calculations
  6. const LDU = 1 /' LDRAW Unit '/
  7. const H = 4 /' Half plate '/
  8. const P = 8 /' Plate '/
  9. const L = 20 /' Module '/
  10. const B = 24 /' Brick '/
  11. const S = 16 /' Slab '/
  12. const _1d5 = 30 /' 1.5L '/
  13. const _0d5 = 10 /' 0.5L '/
  14.  
  15. ' Function to convert units from LDU to other measurements
  16. Function ConvertToLDU(ByVal unitType As String, ByVal value As Integer) As Integer
  17. Select Case unitType
  18. Case "L"
  19. Return value * LDU
  20. Case "P"
  21. Return value * P
  22. Case "B"
  23. Return value * B
  24. Case Else
  25. Return value ' Assume value is already in L
  26. End Select
  27. End Function
  28.  
  29. ' Box dimensions (assuming 2L x 2L x 2L)
  30. Dim As UInteger boxX = ConvertToLDU("L", 2)
  31. Dim As UInteger boxY = ConvertToLDU("L", 2)
  32. Dim As UInteger boxZ = ConvertToLDU("L", 2)
  33. Dim As UInteger box(3) = {boxX, boxY, boxZ}
  34.  
  35. Type Part
  36. As Long X
  37. As Long Y
  38. As Long Z
  39. As String PartType
  40. End Type
  41.  
  42. Sub PrintPartDetails(ByRef pt As Part, ByVal PartID As String, ByVal description As String)
  43. Print "The part description for " & PartID & " is: " & description
  44. Print "The part type for " & PartID & " is: " & pt.PartType
  45. Print "The dimensions of part " & PartID & " are:"
  46. Print " " & pt.X & " LDU x " & pt.Y & " LDU x " & pt.Z & " LDU"
  47. Print " " & (pt.X / LDU) & " L x " & (pt.Y / LDU) & " L x " & (pt.Z / LDU) & " L"
  48. Print " " & (pt.X / P) & " P x " & (pt.Y / P) & " P x " & (pt.Z / P) & " P"
  49. Print " " & (pt.X / B) & " B x " & (pt.Y / B) & " B x " & (pt.Z / B) & " B"
  50. End Sub
  51.  
  52. Function PartsFitInBox(ByRef prt As Part, ByVal boxX As UInteger, ByVal boxY As UInteger, ByVal boxZ As UInteger) As Long
  53. Dim As Long countX, countY, countZ
  54. countX = boxX \ prt.X
  55. countY = boxY \ prt.Y
  56. countZ = boxZ \ prt.Z
  57. Return countX * countY * countZ
  58. End Function
  59.  
  60. Dim PartID As String
  61. while (1)
  62. Input "Please Enter a part ID (e.g. 18654, 43857, 32132a, 41677): ", PartID
  63.  
  64. Select Case PartID
  65. Case "18654"
  66. Dim _18654 As Part
  67. _18654.X = ConvertToLDU("L", 1)
  68. _18654.Y = ConvertToLDU("L", 1)
  69. _18654.Z = ConvertToLDU("L", 1)
  70. _18654.PartType = "LA"
  71. PrintPartDetails(_18654, PartID, "1L x 1L x 1L beam.")
  72. Print "This part fits " & PartsFitInBox(_18654, box(0), box(1), box(2)) & !" times inside the box.\n"
  73. Case "43857"
  74. Dim _43857 As Part
  75. _43857.X = ConvertToLDU("L", 1)
  76. _43857.Y = ConvertToLDU("L", 2)
  77. _43857.Z = ConvertToLDU("L", 1)
  78. _43857.PartType = "LA"
  79. PrintPartDetails(_43857, PartID, "1L x 2L x 1L beam.")
  80. Print "This part fits " & PartsFitInBox(_43857, box(0), box(1), box(2)) & !" times inside the box.\n"
  81. Case "32132a"/' 1L x 1L x 0.5L bush '/
  82. Dim _32132a As Part
  83. _32132a.X = ConvertToLDU("L", 1)
  84. _32132a.Y = ConvertToLDU("L", 1)
  85. _32132a.Z = ConvertToLDU("L", 0.5)
  86. _32132a.PartType = "BU"
  87. PrintPartDetails(_32132a, PartID, "1L x 1L x 0.5L hush.")
  88. Print "This part fits " & PartsFitInBox(_32132a, box(0), box(1), box(2)) & !" times inside the box.\n"
  89. Case "41677" /' 1L x 2L x 0.5L beam '/
  90. Dim _41677 As Part
  91. _41677.X = ConvertToLDU("L", 1)
  92. _41677.Y = ConvertToLDU("L", 2)
  93. _41677.Z = ConvertToLDU("L", 0.5)
  94. _41677.PartType = "LA"
  95. PrintPartDetails(_41677, PartID, "1L x 2L x 0.5L beam.")
  96. Print "This part fits " & PartsFitInBox(_41677, box(0), box(1), box(2)) & !" times inside the box.\n"
  97. Case Else
  98. Print !"You have entered an invalid part ID.\n"
  99. End Select
  100.  
  101. wend
  102.  
  103. Sleep
  104.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement