solidruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +3 -0
- data/COPYING +674 -0
- data/Gemfile +2 -0
- data/Guardfile +24 -0
- data/LICENSE.md +675 -0
- data/README.md +180 -0
- data/Rakefile +10 -0
- data/bin/solidruby +61 -0
- data/examples/chamfered_cube.rb +39 -0
- data/examples/filleted_cube.rb +39 -0
- data/examples/gear.rb +11 -0
- data/examples/knurls.rb +12 -0
- data/examples/nut_support.rb +17 -0
- data/examples/openscad_examples/old/example001.rb +42 -0
- data/examples/openscad_examples/old/example002.rb +45 -0
- data/examples/openscad_examples/old/example003.rb +37 -0
- data/examples/openscad_examples/old/example004.rb +22 -0
- data/examples/openscad_examples/old/example005.rb +45 -0
- data/examples/openscad_examples/old/example006.rb +85 -0
- data/examples/openscad_examples/old/example007.dxf +2410 -0
- data/examples/openscad_examples/old/example007.rb +107 -0
- data/examples/openscad_examples/old/example008.rb +61 -0
- data/examples/openscad_examples/old/example009.dxf +3894 -0
- data/examples/openscad_examples/old/example009.rb.old +48 -0
- data/examples/openscad_examples/old/example010.dat +51 -0
- data/examples/openscad_examples/old/example010.rb +23 -0
- data/examples/openscad_examples/old/example011.rb +42 -0
- data/examples/openscad_examples/old/example012.rb +22 -0
- data/examples/openscad_examples/old/example012.stl +450 -0
- data/examples/openscad_examples/old/example013.dxf +2276 -0
- data/examples/openscad_examples/old/example013.rb +30 -0
- data/examples/openscad_examples/old/example014.rb +30 -0
- data/examples/openscad_examples/old/example015.rb +46 -0
- data/examples/openscad_examples/old/example016.rb +75 -0
- data/examples/openscad_examples/old/example016.stl +0 -0
- data/examples/pipe.rb +38 -0
- data/examples/pipe_bug.rb +16 -0
- data/examples/printed_gear.rb +12 -0
- data/examples/printed_gear2.rb +16 -0
- data/examples/printed_thread.rb +9 -0
- data/examples/printed_thread2.rb +13 -0
- data/examples/stack.rb +21 -0
- data/examples/threads.rb +183 -0
- data/examples/threads2.rb +93 -0
- data/examples/threads3.rb +46 -0
- data/lib/solidruby.rb +60 -0
- data/lib/solidruby/assemblies/assembly.rb +176 -0
- data/lib/solidruby/assemblies/bolt.rb +158 -0
- data/lib/solidruby/assemblies/gear.rb +131 -0
- data/lib/solidruby/assemblies/linear_bearing.rb +84 -0
- data/lib/solidruby/assemblies/nut.rb +153 -0
- data/lib/solidruby/assemblies/pipe.rb +153 -0
- data/lib/solidruby/assemblies/ruler.rb +44 -0
- data/lib/solidruby/assemblies/tslot.rb +141 -0
- data/lib/solidruby/assemblies/tslot_machining.rb +62 -0
- data/lib/solidruby/assemblies/washer.rb +57 -0
- data/lib/solidruby/bill_of_material.rb +43 -0
- data/lib/solidruby/csg_modelling/csg_modelling.rb +43 -0
- data/lib/solidruby/csg_modelling/difference.rb +41 -0
- data/lib/solidruby/csg_modelling/hull.rb +23 -0
- data/lib/solidruby/csg_modelling/intersection.rb +24 -0
- data/lib/solidruby/csg_modelling/minkowski.rb +23 -0
- data/lib/solidruby/csg_modelling/union.rb +41 -0
- data/lib/solidruby/csg_modifiers/color.rb +41 -0
- data/lib/solidruby/csg_modifiers/csg_modifier.rb +50 -0
- data/lib/solidruby/csg_modifiers/linear_extrude.rb +34 -0
- data/lib/solidruby/csg_modifiers/projection.rb +29 -0
- data/lib/solidruby/csg_modifiers/rotate_extrude.rb +30 -0
- data/lib/solidruby/extra.rb +58 -0
- data/lib/solidruby/helpers/chamfer.rb +27 -0
- data/lib/solidruby/helpers/fillet.rb +28 -0
- data/lib/solidruby/helpers/position.rb +267 -0
- data/lib/solidruby/helpers/rounded_cube.rb +37 -0
- data/lib/solidruby/helpers/triangle.rb +167 -0
- data/lib/solidruby/primitives/circle.rb +26 -0
- data/lib/solidruby/primitives/cube.rb +123 -0
- data/lib/solidruby/primitives/cylinder.rb +72 -0
- data/lib/solidruby/primitives/import.rb +42 -0
- data/lib/solidruby/primitives/polygon.rb +26 -0
- data/lib/solidruby/primitives/polyhedron.rb +30 -0
- data/lib/solidruby/primitives/primitive.rb +19 -0
- data/lib/solidruby/primitives/render.rb +48 -0
- data/lib/solidruby/primitives/sphere.rb +49 -0
- data/lib/solidruby/primitives/square.rb +88 -0
- data/lib/solidruby/primitives/surface.rb +44 -0
- data/lib/solidruby/primitives/text.rb +43 -0
- data/lib/solidruby/printed_thread.rb +163 -0
- data/lib/solidruby/rubyscad_bridge.rb +376 -0
- data/lib/solidruby/screw_thread.rb +170 -0
- data/lib/solidruby/solidruby.rb +150 -0
- data/lib/solidruby/solidruby_object.rb +176 -0
- data/lib/solidruby/transformations/mirror.rb +22 -0
- data/lib/solidruby/transformations/rotate.rb +22 -0
- data/lib/solidruby/transformations/scale.rb +22 -0
- data/lib/solidruby/transformations/transformation.rb +29 -0
- data/lib/solidruby/transformations/translate.rb +32 -0
- data/lib/solidruby/version.rb +18 -0
- data/lib/templates/assembly.tt +13 -0
- data/lib/templates/gitignore.tt +3 -0
- data/lib/templates/guardfile.tt +4 -0
- data/lib/templates/main.tt +20 -0
- data/lib/templates/params.tt +3 -0
- data/lib/templates/printed.tt +9 -0
- data/manual/manual.html +417 -0
- data/solidruby.gemspec +35 -0
- metadata +277 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# This file is part of SolidRuby.
|
|
2
|
+
#
|
|
3
|
+
# SolidRuby is free software: you can redistribute it and/or modify
|
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
# (at your option) any later version.
|
|
7
|
+
#
|
|
8
|
+
# SolidRuby is distributed in the hope that it will be useful,
|
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
# GNU General Public License for more details.
|
|
12
|
+
#
|
|
13
|
+
# You should have received a copy of the GNU General Public License
|
|
14
|
+
# along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
|
|
15
|
+
#
|
|
16
|
+
module SolidRuby
|
|
17
|
+
VERSION = '0.1.0'.freeze
|
|
18
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative '../params'
|
|
2
|
+
|
|
3
|
+
class <%= @clean_name %>Assembly < SolidRuby::Assembly
|
|
4
|
+
|
|
5
|
+
# Assemblies are used to show how different parts interact on your design.
|
|
6
|
+
|
|
7
|
+
# Skip generation of the 'output' method for this assembly.
|
|
8
|
+
# (will still generate 'show')
|
|
9
|
+
skip :output
|
|
10
|
+
|
|
11
|
+
def part(show)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'solidruby'
|
|
3
|
+
require 'require_all'
|
|
4
|
+
include SolidRuby
|
|
5
|
+
|
|
6
|
+
require_all 'lib/**/*.rb'
|
|
7
|
+
|
|
8
|
+
# To run this project and refresh any changes to the code, run the following command
|
|
9
|
+
# in a terminal (make sure you are in the same directory as this file):
|
|
10
|
+
# observr #{name}.observr
|
|
11
|
+
#
|
|
12
|
+
# This will generate #{name}.scad which you can open in OpenSCAD.
|
|
13
|
+
# In OpenSCAD make sure that you have the menu item
|
|
14
|
+
# Design -> Automatic Reload and Compile
|
|
15
|
+
# activated.
|
|
16
|
+
|
|
17
|
+
# Scans every file in lib/**/*.rb for classes and saves them in the output/ directory
|
|
18
|
+
save!
|
|
19
|
+
|
|
20
|
+
BillOfMaterial.bom.save('output/bom.txt')
|
data/manual/manual.html
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>CrystalSCAD Manual</title>
|
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
6
|
+
<style type="text/css">
|
|
7
|
+
@import url(http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
|
|
8
|
+
@import url(http://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
|
|
9
|
+
@import url(http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
|
|
10
|
+
|
|
11
|
+
body { font-family: 'Droid Serif'; }
|
|
12
|
+
h1, h2, h3 {
|
|
13
|
+
font-family: 'Yanone Kaffeesatz';
|
|
14
|
+
font-weight: normal;
|
|
15
|
+
}
|
|
16
|
+
.remark-code, .remark-inline-code {
|
|
17
|
+
font-family: 'Ubuntu Mono';
|
|
18
|
+
font-weight: bold;
|
|
19
|
+
background-color: #CDCDCD !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
body {
|
|
23
|
+
font-family: 'Droid Serif';
|
|
24
|
+
}
|
|
25
|
+
h1, h2, h3 {
|
|
26
|
+
font-family: 'Yanone Kaffeesatz';
|
|
27
|
+
font-weight: 400;
|
|
28
|
+
margin-bottom: 0;
|
|
29
|
+
}
|
|
30
|
+
.remark-slide-content h1 { font-size: 2.4em; }
|
|
31
|
+
.remark-slide-content h2 { font-size: 1.6em; }
|
|
32
|
+
.remark-slide-content h3 { font-size: 1.3em; }
|
|
33
|
+
.footnote {
|
|
34
|
+
position: absolute;
|
|
35
|
+
bottom: 3em;
|
|
36
|
+
}
|
|
37
|
+
li p { line-height: 1.25em; }
|
|
38
|
+
.red { color: #fa0000; }
|
|
39
|
+
.large { font-size: 2em; }
|
|
40
|
+
a, a > code {
|
|
41
|
+
color: rgb(160,160,255);
|
|
42
|
+
text-decoration: none;
|
|
43
|
+
}
|
|
44
|
+
code {
|
|
45
|
+
-moz-border-radius: 5px;
|
|
46
|
+
-web-border-radius: 5px;
|
|
47
|
+
background: #000000;
|
|
48
|
+
border-radius: 5px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.remark-code-line-highlighted { background-color: #373832; }
|
|
52
|
+
.pull-left {
|
|
53
|
+
float: left;
|
|
54
|
+
width: 47%;
|
|
55
|
+
text-align: left;
|
|
56
|
+
padding-left:50px;
|
|
57
|
+
}
|
|
58
|
+
.pull-right {
|
|
59
|
+
float: right;
|
|
60
|
+
width: 47%;
|
|
61
|
+
}
|
|
62
|
+
.pull-right ~ p {
|
|
63
|
+
clear: both;
|
|
64
|
+
}
|
|
65
|
+
#slideshow .slide .content code {
|
|
66
|
+
font-size: 0.8em;
|
|
67
|
+
}
|
|
68
|
+
#slideshow .slide .content pre code {
|
|
69
|
+
font-size: 0.9em;
|
|
70
|
+
padding: 15px;
|
|
71
|
+
}
|
|
72
|
+
.inverse {
|
|
73
|
+
background: #272822;
|
|
74
|
+
color: #ffffff;
|
|
75
|
+
text-shadow: 0 0 20px #333;
|
|
76
|
+
background-repeat: no-repeat;
|
|
77
|
+
}
|
|
78
|
+
.inverse2 {
|
|
79
|
+
background: #272822;
|
|
80
|
+
color: #ffffff;
|
|
81
|
+
font-size: 27px;
|
|
82
|
+
text-shadow: 0 0 20px #333;
|
|
83
|
+
background-repeat: no-repeat;
|
|
84
|
+
}
|
|
85
|
+
.inverse h1, .inverse h2 {
|
|
86
|
+
color: #f3f3f3;
|
|
87
|
+
line-height: 0.8em;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
/* Slide-specific styling */
|
|
92
|
+
#slide-inverse .footnote {
|
|
93
|
+
bottom: 12px;
|
|
94
|
+
left: 20px;
|
|
95
|
+
}
|
|
96
|
+
#slide-how .slides {
|
|
97
|
+
font-size: 0.9em;
|
|
98
|
+
position: absolute;
|
|
99
|
+
top: 151px;
|
|
100
|
+
right: 140px;
|
|
101
|
+
}
|
|
102
|
+
#slide-how .slides h3 {
|
|
103
|
+
margin-top: 0.2em;
|
|
104
|
+
}
|
|
105
|
+
#slide-how .slides .first, #slide-how .slides .second {
|
|
106
|
+
padding: 1px 20px;
|
|
107
|
+
height: 90px;
|
|
108
|
+
width: 120px;
|
|
109
|
+
-moz-box-shadow: 0 0 10px #777;
|
|
110
|
+
-webkit-box-shadow: 0 0 10px #777;
|
|
111
|
+
box-shadow: 0 0 10px #777;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
/* Two-column layout */
|
|
116
|
+
.left {
|
|
117
|
+
color: #777;
|
|
118
|
+
width: 20%;
|
|
119
|
+
height: 92%;
|
|
120
|
+
float: left;
|
|
121
|
+
}
|
|
122
|
+
.left h2:last-of-type, .left h3:last-child {
|
|
123
|
+
color: #c5c5c5;
|
|
124
|
+
}
|
|
125
|
+
.right {
|
|
126
|
+
width: 75%;
|
|
127
|
+
float: right;
|
|
128
|
+
padding-top: 1em;
|
|
129
|
+
}
|
|
130
|
+
.bottom{
|
|
131
|
+
clear: both;
|
|
132
|
+
}
|
|
133
|
+
.counter {
|
|
134
|
+
position: absolute;
|
|
135
|
+
bottom: 1em;
|
|
136
|
+
}
|
|
137
|
+
</style>
|
|
138
|
+
</head>
|
|
139
|
+
<body>
|
|
140
|
+
<textarea id="source">
|
|
141
|
+
|
|
142
|
+
# CrystalSCAD Installation
|
|
143
|
+
Please make sure you have these packages installed on your system:
|
|
144
|
+
|
|
145
|
+
## Requirements:
|
|
146
|
+
- ruby >= 1.9.3
|
|
147
|
+
- rubygems (optional)
|
|
148
|
+
- OpenSCAD
|
|
149
|
+
---
|
|
150
|
+
# Installation via rubygems
|
|
151
|
+
In your terminal, write:
|
|
152
|
+
```sh
|
|
153
|
+
sudo gem install solidruby
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
If you have a system with more than one rubygems installation (especially pre-1.9.3) you might need to replace 'gem' with 'gem1.9' or 'gem1.9.3' depending on how it is installed.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
# Creating a project
|
|
160
|
+
In your terminal, write:
|
|
161
|
+
```sh
|
|
162
|
+
crystalgen new <project name>
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
This will generate a new project directory in the directory you are in.
|
|
166
|
+
|
|
167
|
+
## Example
|
|
168
|
+
```sh
|
|
169
|
+
$ crystalgen new hello_world
|
|
170
|
+
create hello_world/hello_world.rb
|
|
171
|
+
chmod hello_world/hello_world.rb
|
|
172
|
+
create hello_world/lib/assemblies
|
|
173
|
+
create hello_world/lib/electronics
|
|
174
|
+
create hello_world/lib/hardware
|
|
175
|
+
create hello_world/lib/printed
|
|
176
|
+
create hello_world/lib/lasercut
|
|
177
|
+
create hello_world/output
|
|
178
|
+
create hello_world/lib/assemblies/hello_world_assembly.rb
|
|
179
|
+
create hello_world/lib/printed/testcube.rb
|
|
180
|
+
create hello_world/hello_world.observr
|
|
181
|
+
```
|
|
182
|
+
A lot of files were just created. We will look into those later.
|
|
183
|
+
---
|
|
184
|
+
# Your first project
|
|
185
|
+
After you have created your project, go to your project folder in the terminal.
|
|
186
|
+
```sh
|
|
187
|
+
cd <project name>
|
|
188
|
+
```
|
|
189
|
+
## Example
|
|
190
|
+
```sh
|
|
191
|
+
$ cd hello_world
|
|
192
|
+
```
|
|
193
|
+
In this example, we have two files called hello_world.rb and hello_world.observr in that directory.
|
|
194
|
+
|
|
195
|
+
You can try to run the first one now.
|
|
196
|
+
```sh
|
|
197
|
+
$ ./hello_world.rb
|
|
198
|
+
```
|
|
199
|
+
If it doesn't give you an output, it ran successfully. Note the .scad files in the output/ directory.
|
|
200
|
+
|
|
201
|
+
If it gives an error at this point, see the next page
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
# Troubleshooting
|
|
205
|
+
|
|
206
|
+
If you see an error message like this:
|
|
207
|
+
```sh
|
|
208
|
+
bash: ./hello_world.rb: /usr/bin/ruby1.9.3: bad interpreter: No such file or directory
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
You can either run the file with your ruby interpreter, for example:
|
|
212
|
+
```sh
|
|
213
|
+
ruby hello_world.rb
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
or (recommended) change the path to the ruby interpreter in your project file (hello_world.rb in this example).
|
|
217
|
+
to do that, change the first line of your project file
|
|
218
|
+
```c
|
|
219
|
+
#!/usr/bin/ruby1.9.3
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
# File Observer
|
|
224
|
+
If you don't want to re-run the project file every time you change the code, you can use a tool called 'observr' to automatically generate new .scad files from your code.
|
|
225
|
+
### Syntax:
|
|
226
|
+
```sh
|
|
227
|
+
observr <project_name>.observr
|
|
228
|
+
```
|
|
229
|
+
### Example:
|
|
230
|
+
```sh
|
|
231
|
+
$ observr hello_world.observr
|
|
232
|
+
```
|
|
233
|
+
This will run until you stop it (for example with ctrl+c). It does not give an output on success,
|
|
234
|
+
but will return an error message every time there's something wrong with your code.
|
|
235
|
+
|
|
236
|
+
*Note:* The observer has to be restarted when you create a new file.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
# The lib directory [1/2]
|
|
240
|
+
When you look in the lib/ directory in your project directory you will find several subdirectories:
|
|
241
|
+
|
|
242
|
+
```sh
|
|
243
|
+
$ cd lib
|
|
244
|
+
$ ls
|
|
245
|
+
assemblies electronics hardware lasercut printed
|
|
246
|
+
```
|
|
247
|
+
Of those, the directories assemblies and printed have some files in them. Let's have a quick overview about the intended purpose of each directory:
|
|
248
|
+
|
|
249
|
+
### assemblies
|
|
250
|
+
This is where you can combine multiple parts into one block. It is not mandatory to do this, but it might come in handy if you want to visualize parts that interact with each other.
|
|
251
|
+
|
|
252
|
+
### electronics
|
|
253
|
+
This is where you should put representations of your electronic parts
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
# The lib directory [2/2]
|
|
257
|
+
|
|
258
|
+
### hardware
|
|
259
|
+
This is where any (non-fabricated) mechanical parts you use in your project go
|
|
260
|
+
|
|
261
|
+
### lasercut
|
|
262
|
+
This is where you can put in lasercut sheets
|
|
263
|
+
|
|
264
|
+
### printed
|
|
265
|
+
This is where you define your 3D printed parts
|
|
266
|
+
|
|
267
|
+
## Note:
|
|
268
|
+
It is not mandatory to use the given directory structure. I made it that way to make it easier to reuse once defined components in other projects.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
# Output files [1/3]
|
|
272
|
+
After your have run your project file or the observer, there will be .scad files in the output/ directory.
|
|
273
|
+
|
|
274
|
+
```sh
|
|
275
|
+
$ ls -1
|
|
276
|
+
Hello_worldAssembly_show.scad
|
|
277
|
+
TestCube_my_subassembly.scad
|
|
278
|
+
TestCube_output.scad
|
|
279
|
+
TestCube_show.scad
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
This requires a bit of explanation.
|
|
283
|
+
|
|
284
|
+
The file 'Hello_worldAssembly_show.scad' in this example is generated by hello_world_assembly.rb in lib/assemblies/
|
|
285
|
+
|
|
286
|
+
Every file usually outputs two files:
|
|
287
|
+
- filename_show.scad
|
|
288
|
+
- filename_output.scad
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
# Output files [2/3]
|
|
293
|
+
The assembly has produced only one file! Looking into the file hello_world_assembly.rb gives us the reason:
|
|
294
|
+
```ruby
|
|
295
|
+
skip :output
|
|
296
|
+
```
|
|
297
|
+
This means that it skips the output method on file generation. Simple!
|
|
298
|
+
|
|
299
|
+
But... what about the TestCube file that generated 3 files?
|
|
300
|
+
|
|
301
|
+
Again, have a look into the file testcube.rb in lib/printed/
|
|
302
|
+
|
|
303
|
+
```ruby
|
|
304
|
+
view :my_subassembly
|
|
305
|
+
|
|
306
|
+
def my_subassembly
|
|
307
|
+
[...]
|
|
308
|
+
end
|
|
309
|
+
```
|
|
310
|
+
This adds another output to the testcube file in addition to the ones that are generated by default (show and output).
|
|
311
|
+
You can add as many "views" as you like to an object. This can be handy if you have complex parts or just want to
|
|
312
|
+
work on subassemblies inside a part.
|
|
313
|
+
---
|
|
314
|
+
# Output files [3/3]
|
|
315
|
+
|
|
316
|
+
If you had a look at the examples yet, you might have noticed that none of the files actually define 'show' or 'output' but instead do this:
|
|
317
|
+
```ruby
|
|
318
|
+
def part(show)
|
|
319
|
+
[...]
|
|
320
|
+
end
|
|
321
|
+
```
|
|
322
|
+
This method can produce both show and output. The show variable is set to true when the 'show' output is generated, otherwise false. You can also instead define your own show or output methods:
|
|
323
|
+
```ruby
|
|
324
|
+
def show
|
|
325
|
+
[...]
|
|
326
|
+
end
|
|
327
|
+
```
|
|
328
|
+
```ruby
|
|
329
|
+
def output
|
|
330
|
+
[...]
|
|
331
|
+
end
|
|
332
|
+
```
|
|
333
|
+
---
|
|
334
|
+
# Small introduction to ruby
|
|
335
|
+
TODO: variables, comments, class inheritance?
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
# Units
|
|
339
|
+
|
|
340
|
+
All units are mm by default.
|
|
341
|
+
|
|
342
|
+
###Note on how Ruby casts numeric values:
|
|
343
|
+
|
|
344
|
+
```ruby
|
|
345
|
+
@foo = 11 # Casts as Integer
|
|
346
|
+
@bar = 11.0 # Casts as Decimal
|
|
347
|
+
|
|
348
|
+
```
|
|
349
|
+
This is important if you devide by an Integer, for example:
|
|
350
|
+
```ruby
|
|
351
|
+
@foo / 2 # results in 5
|
|
352
|
+
@bar / 2 # results in 5.5
|
|
353
|
+
```
|
|
354
|
+
As good practice, you should divide by a Decimal, which will cast the Integer to Decimal:
|
|
355
|
+
```ruby
|
|
356
|
+
@foo / 2.0 # results in 5.5
|
|
357
|
+
@bar / 2.0 # results in 5.5
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
# Primitives
|
|
366
|
+
## Cube
|
|
367
|
+
Creates a cube at the origin of the coordinate system.
|
|
368
|
+
|
|
369
|
+
```ruby
|
|
370
|
+
# 2D modeling
|
|
371
|
+
cube(x: value , y: value)
|
|
372
|
+
|
|
373
|
+
# 3D modeling
|
|
374
|
+
cube(x: value , y: value, z: value)
|
|
375
|
+
|
|
376
|
+
# also accepts size, which will make a cube with x,y,z = 1
|
|
377
|
+
cube(size: 1)
|
|
378
|
+
```
|
|
379
|
+
### Centering
|
|
380
|
+
You can put one of these methods directly after the cube method:
|
|
381
|
+
```ruby
|
|
382
|
+
cube(size: 1).center # Center in X,Y and Z
|
|
383
|
+
cube(size: 1).center_x # Center in X
|
|
384
|
+
cube(size: 1).center_y # Center in Y
|
|
385
|
+
cube(size: 1).center_xy # Center in X and Y
|
|
386
|
+
cube(size: 1).center_z # Center Z
|
|
387
|
+
|
|
388
|
+
```
|
|
389
|
+
---
|
|
390
|
+
## Cylinder
|
|
391
|
+
Creates a cylinder centered in X & Y
|
|
392
|
+
```ruby
|
|
393
|
+
cylinder(d:5,h:10) # Creates a cylinder with diameter 5 and height 10
|
|
394
|
+
```
|
|
395
|
+
parameters:
|
|
396
|
+
```ruby
|
|
397
|
+
r: radius
|
|
398
|
+
d: diameter
|
|
399
|
+
h: height
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
</textarea>
|
|
411
|
+
<script src="https://gnab.github.io/remark/downloads/remark-latest.min.js" type="text/javascript">
|
|
412
|
+
</script>
|
|
413
|
+
<script type="text/javascript">
|
|
414
|
+
var slideshow = remark.create();
|
|
415
|
+
</script>
|
|
416
|
+
</body>
|
|
417
|
+
</html>
|