Advertisement
Guest User

https://www.reddit.com/r/3Drequests/comments/1kb9xhk/looking_for_assistance_in_creating_accurate_stl

a guest
May 2nd, 2025
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.48 KB | Source Code | 0 0
  1. // Rocinante.scad
  2. //
  3. // Version 1, May 1, 2025
  4. // By: Stone Age Sculptor
  5. // License: CC0 (only this script, not the fonts)
  6. //
  7. // Version 2, May 2, 2025
  8. // By: Stone Age Sculptor
  9. // License: CC0 (only this script, not the fonts)
  10. // Changes:
  11. // Added 2D output for a svg file.
  12. // The length of the bar below the text "ROCINANTE"
  13. // is now automatically sized.
  14. // Note:
  15. // Use a OpenSCAD version of at least 2025,
  16. // and turn on all the Features in
  17. // the Preferences.
  18. // Then the shapes are not melted together.
  19. //
  20. // Version 3, May 2, 2025
  21. // By: Stone Age Sculptor
  22. // License: CC0 (only this script, not the fonts)
  23. // Changes:
  24. // Corrected the text:
  25. // SAVAGE -> SALVAGE
  26. // NOLDEN -> HOLDEN
  27. // BUNTON -> BURTON
  28. //
  29. // Find the fonts yourself!
  30. // I could not find the right fonts
  31. // with a free/open license.
  32. //
  33. // OpenSCAD can finetune the shapes of a font.
  34. // A text can be made heavier or lighter
  35. // with the offset() function, it
  36. // can be scaled in one direction,
  37. // and the intercharacter spacing
  38. // can be adjusted, the corners can
  39. // be made round, and so on.
  40.  
  41. // Overall accuracy, 10 is very low, 500 is very high.
  42. $fn = 200;
  43.  
  44.  
  45. // ----------------------------------------
  46. // Use the fonts that you found here.
  47. // ----------------------------------------
  48.  
  49. use <BankGothicLH Heavy.ttf>
  50. font1 = "BankGothicLH:style=Heavy";
  51.  
  52. // use <FF-DIN-Black.ttf>
  53. // font2 = "DIN Black:style=Regular";
  54.  
  55. use <645-font.otf>
  56. font2 = "DIN Pro:style=Condensed Black";
  57.  
  58. // ----------------------------------------
  59.  
  60. // Select 3D output or 2D output.
  61. // Set to 'true' for 2D output.
  62. Output_SVG = false;
  63.  
  64. // The size of the base plate in millimeters (14" x 10.5").
  65. xsize = 14 * 25.4;
  66. ysize = 10.5 * 25.4;
  67.  
  68. // The distance between the outer edge and the rectangle.
  69. edge_outer = 9;
  70.  
  71. // The width of the rectangle.
  72. edge_linewidth = 4;
  73.  
  74. // The thickness of the base plate.
  75. thickness_plate = 10;
  76.  
  77. // The thickness of the text.
  78. thickness_print = 2;
  79.  
  80. // The width of the bar below the Rocinante text.
  81. bar_width = 4;
  82.  
  83. // The diameter of the circles in the text.
  84. circle_diameter = 4;
  85.  
  86. // The distance between the edge and the center of a hole.
  87. hole_offset = 23;
  88.  
  89. // The diameter of the hole that goes through and through.
  90. hole_diameter = 3;
  91.  
  92. // The diameter of the wider part of the hole.
  93. hole_wider = 10;
  94.  
  95. // The depth of the wider part of the hole.
  96. depth_wider = 3;
  97.  
  98. // Helper value to avoid rounding errors.
  99. epsilon = 0.001;
  100.  
  101. if(Output_SVG)
  102. {
  103. // Keep everything in 2D.
  104. // A OpenSCAD version of at least 2025 is required
  105. // with all the features turned on.
  106. // Only that way the shapes will be as seperate parts
  107. // in the svg file.
  108.  
  109. color("LightBlue")
  110. BasePlate2D();
  111.  
  112. color("Green")
  113. Print2D();
  114.  
  115. // Add the shapes for the holes.
  116. // They are not combined
  117. // to keep the shapes separated.
  118. color("Purple")
  119. PositionHoles()
  120. circle(d=hole_wider);
  121.  
  122. color("Red")
  123. PositionHoles()
  124. circle(d=hole_diameter);
  125. }
  126. else
  127. {
  128. // A 3D model.
  129.  
  130. // The base plate, with the holes removed.
  131. color("Gray")
  132. {
  133. difference()
  134. {
  135. // The base plate.
  136. linear_extrude(thickness_plate)
  137. BasePlate2D();
  138.  
  139. // Remove the holes.
  140. linear_extrude(100,center=true)
  141. PositionHoles()
  142. circle(d=hole_diameter);
  143.  
  144. translate([0,0,thickness_plate-depth_wider])
  145. linear_extrude(100)
  146. PositionHoles()
  147. circle(d=hole_wider);
  148. }
  149. }
  150.  
  151. // The print.
  152. color("Silver")
  153. {
  154. // The print is sunk a little into the base plate,
  155. // to be sure that they connect.
  156. translate([0,0,thickness_plate-epsilon])
  157. linear_extrude(thickness_print+epsilon)
  158. Print2D();
  159. }
  160. }
  161.  
  162. // A small helper module to generate the
  163. // location for the holes.
  164. module PositionHoles()
  165. {
  166. for(xm=[-1,1],ym=[-1,1])
  167. {
  168. x = xm*(xsize/2-hole_offset);
  169. y = ym*(ysize/2-hole_offset);
  170. translate([x,y])
  171. children();
  172. }
  173. }
  174.  
  175. // The base plate as a 2D shape.
  176. module BasePlate2D()
  177. {
  178. // The base plate.
  179. square([xsize,ysize],center=true);
  180. }
  181.  
  182. // The Print2D is all the text and the rectangle
  183. // as 2D shapes.
  184. // But not the base plate and not the holes.
  185. module Print2D()
  186. {
  187. // The rectangle.
  188. difference()
  189. {
  190. x1 = xsize-2*edge_outer;
  191. y1 = ysize-2*edge_outer;
  192. x2 = x1 - 2*edge_linewidth;
  193. y2 = y1 - 2*edge_linewidth;
  194. square([x1,y1],center=true);
  195. square([x2,y2],center=true);
  196. }
  197.  
  198. // The size and font are set in the module "Rocinante()".
  199. translate([0,70])
  200. Rocinante();
  201.  
  202. // This position and the length of the bar
  203. // could be calculated with the new textmetrics()
  204. // function.
  205. //
  206. // This is with numbers that are visually finetuned:
  207. // translate([1.56,47])
  208. // square([286.8,bar_width],center=true);
  209. //
  210. // This is by trying to be smart with the resize() function.
  211. // It might not work for every font.
  212. // The 'E' at the end might not have the same length for
  213. // the horizontal bars, therefor the text is combined with
  214. // a mirrored text.
  215. translate([0,47])
  216. resize([0,bar_width],auto=false)
  217. hull()
  218. {
  219. Rocinante();
  220. mirror([0,1,0])
  221. Rocinante();
  222. }
  223.  
  224. translate([0,15])
  225. text("AN INDEPENDENT SHIP",font=font2,size=12,spacing=1.1,halign="center");
  226. translate([0,-2])
  227. text("OWNED & OPERATED BY",font=font2,size=12,spacing=1.1,halign="center");
  228. translate([0,-34])
  229. text("JAMES HOLDEN NAOMI NAGATA",font=font2,size=15,spacing=1.05,halign="center");
  230. translate([0,-54])
  231. text("ALEX KAMAL AMOS BURTON",font=font2,size=15,spacing=1.05,halign="center");
  232. translate([0,-86])
  233. text("A LEGITIMATE SALVAGE",font=font2,size=14,spacing=1.05,halign="center");
  234.  
  235. // Not every font might have the definition
  236. // for the circle, therefor they are
  237. // just circles and visually positioned.
  238. translate([0.7,-26.7])
  239. circle(d=circle_diameter);
  240. translate([-7,-46])
  241. circle(d=circle_diameter);
  242. }
  243.  
  244. // A seperate module for the text "ROCINANTE",
  245. // to be able to automatically set the length
  246. // of the bar below the text.
  247. //
  248. // The valign="center" is required for a mirror(),
  249. // which is used to automatically create the length of the bar
  250. // below this text.
  251. module Rocinante()
  252. {
  253. // The parameter "spacing" is the intercharacter spacing.
  254. // It is default 1.
  255. text("ROCINANTE",font=font1,size=32,spacing=0.98,halign="center",valign="center");
  256. }
Tags: OpenSCAD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement