openjscad-aurora-webapp

Форк
0
/
stepper-motor.jscad 
106 строк · 4.2 Кб
1
// title: Stepper Motor
2
// author: Derrick Oswald
3

4
function getParameterDefinitions()
5
{
6
  return ([
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

27
function main (parameters)
28
{
29
  var length = parameters.motorBody_len / 2;
30
  var width = parameters.motorBody_width / 2;
31
  var z = width;
32
  var ch = sqrt (2.0) * width - sqrt (0.5) * parameters.motorBody_chamfer;
33
  var ch2 = sqrt (2.0) * width - sqrt (0.5) * parameters.motorCap_chamfer;
34
  var depth = parameters.mountingholes_depth;
35
  var offset = parameters.mountingholes_fromcent;
36

37
  var cube = new CSG.roundedCube
38
  ({
39
    center: [0, 0, 0],
40
    radius: [length - parameters.motorCap_len, width - parameters.motorCap_thickness, width - parameters.motorCap_thickness],
41
    roundradius: 0.2,
42
    resolution: 16
43
  });
44
  cube = cube.setColor (0.67843137254901960784313725490196, 0.70588235294117647058823529411765, 0.70588235294117647058823529411765);
45
  var xcube = new CSG.cube
46
  ({
47
    center: [0, 0, 0],
48
    radius: [length, ch, ch]
49
  });
50
  xcube = xcube.setColor (0.67843137254901960784313725490196, 0.70588235294117647058823529411765, 0.70588235294117647058823529411765);
51
  cube = cube.intersect (xcube.rotateX(45));
52

53
  var cube2 = new CSG.roundedCube
54
  ({
55
    center: [length - (parameters.motorCap_len / 2.0), 0, 0],
56
    radius: [(parameters.motorCap_len / 2.0), width, width],
57
    roundradius: 0.2,
58
    resolution: 16
59
  });
60
  cube2 = cube2.setColor (0.87058823529411764705882352941176, 0.89803921568627450980392156862745, 0.90588235294117647058823529411765);
61
  var cube3 = cube2.translate([-(parameters.motorBody_len - parameters.motorCap_len), 0, 0]);
62
  xcube = new CSG.cube
63
  ({
64
    center: [0, 0, 0],
65
    radius: [length, ch2, ch2]
66
  });
67
  xcube = xcube.setColor (0.87058823529411764705882352941176, 0.89803921568627450980392156862745, 0.90588235294117647058823529411765);
68
  xcube = xcube.rotateX(45);
69
  cube2 = cube2.intersect (xcube);
70
  cube3 = cube3.intersect (xcube);
71

72
  var ring = new CSG.cylinder
73
  ({
74
      start: [length, 0, 0],
75
      end: [length + parameters.motorRing_height, 0, 0],
76
      radius: parameters.motorRing_radius,
77
      resolution: 100
78
  });
79
  ring = ring.setColor (0.81176470588235294117647058823529, 0.84313725490196078431372549019608, 0.85098039215686274509803921568627);
80

81
  var shaft = new CSG.cylinder
82
  ({
83
      start: [length + parameters.motorRing_height, 0, 0],
84
      end: [length + parameters.motorRing_height + parameters.shaft_len, 0, 0],
85
      radius: parameters.shaft_radius,
86
      resolution: 50
87
  });
88
  shaft = shaft.setColor (0.9, 0.91, 0.91);
89
  var motor = cube.union ([cube2, cube3,ring, shaft]);  
90

91
  var mountinghole = new CSG.cylinder
92
  ({
93
      start: [-depth, 0, 0],
94
      end: [0, 0, 0],
95
      radius: parameters.mountingholes_radius,
96
      resolution: 20
97
  });
98
  mountinghole = mountinghole.setColor (0.2,0.2,0.2);
99
  motor = motor.subtract (mountinghole.translate ([length, offset, offset]));
100
  motor = motor.subtract (mountinghole.translate ([length, offset, -offset]));
101
  motor = motor.subtract (mountinghole.translate ([length, -offset, offset]));
102
  motor = motor.subtract (mountinghole.translate ([length, -offset, -offset]));
103

104
  motor = motor.translate([0,0,z]);
105
  return (motor);
106
}
107

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.