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