openjscad-aurora-webapp
106 строк · 4.2 Кб
1// title: Stepper Motor
2// author: Derrick Oswald
3
4function getParameterDefinitions()5{
6return ([7{ name: 'motorBody_len', type: 'float', initial: 47.5, caption: 'Motor length'},8{ name: 'motorBody_width', type: 'float', initial: 42.0, caption: 'Motor width'},9{ name: 'motorBody_chamfer', type: 'float', initial: 5.0, caption: 'Motor chamfer'},10
11{ name: 'motorCap_len', type: 'float', initial: 8.0, caption: 'Motor cap length'},12{ name: 'motorCap_thickness', type: 'float', initial: 1.0, caption: 'Motor cap thickness'},13{ name: 'motorCap_chamfer', type: 'float', initial: 2.5, caption: 'Motor cap chamfer'},14
15{ name: 'shaft_len', type: 'float', initial: 22.0, caption: 'Shaft length'},16{ name: 'shaft_radius', type: 'float', initial: 2.5, caption: 'Shaft radius'},17
18{ name: 'motorRing_radius', type: 'float', initial: 11.0, caption: 'Ring radius'},19{ name: 'motorRing_height', type: 'float', initial: 2.0, caption: 'Ring height'},20
21{ name: 'mountingholes_fromcent', type: 'float', initial: 15.5, caption: 'Mounting hole offset'},22{ name: 'mountingholes_radius', type: 'float', initial: 1.5, caption: 'Mounting hole radius'},23{ name: 'mountingholes_depth', type: 'float', initial: 4.5, caption: 'Mounting hole depth'}24]);25}
26
27function main (parameters)28{
29var length = parameters.motorBody_len / 2;30var width = parameters.motorBody_width / 2;31var z = width;32var ch = sqrt (2.0) * width - sqrt (0.5) * parameters.motorBody_chamfer;33var ch2 = sqrt (2.0) * width - sqrt (0.5) * parameters.motorCap_chamfer;34var depth = parameters.mountingholes_depth;35var offset = parameters.mountingholes_fromcent;36
37var cube = new CSG.roundedCube38({39center: [0, 0, 0],40radius: [length - parameters.motorCap_len, width - parameters.motorCap_thickness, width - parameters.motorCap_thickness],41roundradius: 0.2,42resolution: 1643});44cube = cube.setColor (0.67843137254901960784313725490196, 0.70588235294117647058823529411765, 0.70588235294117647058823529411765);45var xcube = new CSG.cube46({47center: [0, 0, 0],48radius: [length, ch, ch]49});50xcube = xcube.setColor (0.67843137254901960784313725490196, 0.70588235294117647058823529411765, 0.70588235294117647058823529411765);51cube = cube.intersect (xcube.rotateX(45));52
53var cube2 = new CSG.roundedCube54({55center: [length - (parameters.motorCap_len / 2.0), 0, 0],56radius: [(parameters.motorCap_len / 2.0), width, width],57roundradius: 0.2,58resolution: 1659});60cube2 = cube2.setColor (0.87058823529411764705882352941176, 0.89803921568627450980392156862745, 0.90588235294117647058823529411765);61var cube3 = cube2.translate([-(parameters.motorBody_len - parameters.motorCap_len), 0, 0]);62xcube = new CSG.cube63({64center: [0, 0, 0],65radius: [length, ch2, ch2]66});67xcube = xcube.setColor (0.87058823529411764705882352941176, 0.89803921568627450980392156862745, 0.90588235294117647058823529411765);68xcube = xcube.rotateX(45);69cube2 = cube2.intersect (xcube);70cube3 = cube3.intersect (xcube);71
72var ring = new CSG.cylinder73({74start: [length, 0, 0],75end: [length + parameters.motorRing_height, 0, 0],76radius: parameters.motorRing_radius,77resolution: 10078});79ring = ring.setColor (0.81176470588235294117647058823529, 0.84313725490196078431372549019608, 0.85098039215686274509803921568627);80
81var shaft = new CSG.cylinder82({83start: [length + parameters.motorRing_height, 0, 0],84end: [length + parameters.motorRing_height + parameters.shaft_len, 0, 0],85radius: parameters.shaft_radius,86resolution: 5087});88shaft = shaft.setColor (0.9, 0.91, 0.91);89var motor = cube.union ([cube2, cube3,ring, shaft]);90
91var mountinghole = new CSG.cylinder92({93start: [-depth, 0, 0],94end: [0, 0, 0],95radius: parameters.mountingholes_radius,96resolution: 2097});98mountinghole = mountinghole.setColor (0.2,0.2,0.2);99motor = motor.subtract (mountinghole.translate ([length, offset, offset]));100motor = motor.subtract (mountinghole.translate ([length, offset, -offset]));101motor = motor.subtract (mountinghole.translate ([length, -offset, offset]));102motor = motor.subtract (mountinghole.translate ([length, -offset, -offset]));103
104motor = motor.translate([0,0,z]);105return (motor);106}
107