Guest User

OpenSCAD Parameters not passing to child module-calls

a guest
Nov 28th, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. // Customizable OpenBuilds V-Slot Rails, Using 2D Extrusion and render() Command, Allowing Each Working Face to be Closed or Slotted
  2.  
  3. /* [General] */
  4. // Height (Y) of Extrusion Profile End View
  5. VRailHeight = 20;
  6.  
  7. // Width (X) of Extrusion Profile End View
  8. VRailWidth = 20;
  9.  
  10. // Length (Z) of Extruded Part
  11. VRailLength = 10;
  12.  
  13.  
  14.  
  15. // Begin Rendering
  16.  
  17. VRailVitamin(Slots=1);
  18.  
  19. // Define Modules
  20.  
  21. module VRailProfile() {
  22. /* [Profile] */
  23. VWCenter = VRailWidth / 2;
  24. VHCenter = VRailHeight / 2;
  25.  
  26. // Define Profile
  27. difference() {
  28. square([VRailWidth, VRailHeight]);
  29. for (i=[1:1:3]) {
  30. translate ([VWCenter,VHCenter]) {
  31. translate([(VWCenter-0.5),(VHCenter-0.5)]) {
  32. render() SquareFillets();
  33. };
  34. rotate([0,0,90*i]) {
  35. translate([(VWCenter-0.5),(VHCenter-0.5)]) {
  36. SquareFillets();
  37. };
  38. };
  39. };
  40. };
  41. translate ([VWCenter,VHCenter]) {
  42. circle(2.1,$fn=15);
  43. };
  44. for (i=Slots) {
  45. translate ([VWCenter,VHCenter]) {
  46. rotate([0,0,90*i]) {
  47. translate ([0,-VHCenter]) {
  48. VSlot();
  49. };
  50. };
  51. };
  52. };
  53.  
  54. };
  55.  
  56.  
  57. // Define subModules
  58. module SquareFillets () {
  59. difference() {
  60. square(1);
  61. circle(0.5,$fn=15);
  62. };
  63. };
  64.  
  65. module VSlot () {
  66. VSlotHalf();
  67. mirror([1,0]) VSlotHalf();
  68.  
  69. module VSlotHalf() {
  70. polygon (points = [[0,-1],[0,6.31],[0.21,6.1],[2.839,6.1],[5.5,3.439],[5.5,1.8],[3.125,1.8],[3.125,1.455],[5.58,-1]]);
  71. };
  72. };
  73. };
  74.  
  75. module VRailVitamin (VRailWidth=VRailWidth, VRailHeight=VRailHeight,Slots=[1,2,3,4]) { // This set of parameters was originally defined for VRailProfile(). Leaving it defined there and here while calling VRailVitamin with a Slots[] value does not pass the value, even if I add Slots to the VRailProfile() call below.
  76. linear_extrude(height=1, convexity=10) VRailProfile();
  77. };
  78.  
  79. //EOD
Add Comment
Please, Sign In to add comment