rubyscad 1.0.6 → 1.0.7
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 +21 -21
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +322 -322
- data/Rakefile +1 -1
- data/examples/BasicCube.rb +50 -50
- data/examples/ChamferCube.rb +96 -96
- data/examples/FilletCube.rb +317 -317
- data/examples/example001.rb +33 -33
- data/examples/example001.scad +11 -11
- data/examples/example002.rb +23 -23
- data/examples/example002.scad +18 -18
- data/examples/example003.rb +19 -19
- data/examples/example003.scad +15 -15
- data/examples/example004.rb +11 -11
- data/examples/example004.scad +6 -6
- data/examples/example005.rb +22 -22
- data/examples/example005.scad +31 -31
- data/examples/example006.rb +46 -46
- data/examples/example006.scad +221 -221
- data/examples/example007.dxf +2410 -2410
- data/examples/example007.rb +53 -53
- data/examples/example007.scad +30 -30
- data/examples/example008.dxf +3238 -3238
- data/examples/example008.rb +34 -34
- data/examples/example008.scad +26 -26
- data/examples/example009.dxf +3894 -3894
- data/examples/example009.rb +33 -33
- data/examples/example009.scad +15 -15
- data/examples/example010.dat +51 -51
- data/examples/example010.rb +12 -12
- data/examples/example010.scad +7 -7
- data/examples/example011.rb +22 -22
- data/examples/example011.scad +3 -3
- data/examples/example012.rb +16 -16
- data/examples/example012.scad +8 -8
- data/examples/example013.dxf +2276 -2276
- data/examples/example013.rb +16 -16
- data/examples/example013.scad +12 -12
- data/examples/example014.rb +14 -14
- data/examples/example014.scad +12 -12
- data/examples/example015.rb +33 -33
- data/examples/example015.scad +22 -22
- data/examples/example016.rb +43 -43
- data/examples/example016.scad +49 -49
- data/examples/example017.rb +170 -170
- data/examples/example017.scad +124 -124
- data/examples/example018.rb +29 -29
- data/examples/example018.scad +74 -74
- data/examples/example019.rb +22 -22
- data/examples/example019.scad +84 -84
- data/examples/example020.rb +92 -92
- data/examples/example020.scad +62 -62
- data/examples/example021.rb +42 -42
- data/examples/example021.scad +159 -159
- data/examples/example022.rb +44 -44
- data/examples/example022.scad +103 -103
- data/lib/rubyscad.rb +2 -2
- data/lib/rubyscad/RubyScad.rb +369 -361
- data/lib/rubyscad/version.rb +3 -3
- data/rubyscad.gemspec +20 -20
- metadata +7 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a80caa055d22b7cf20a71065152b13a12ba474f1
|
4
|
+
data.tar.gz: b06afd17a237f675db9eb32e6bfc9b20bcfa507a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 24bcf312da8902c63ea57d68b8025f954157575ce37cba2f2cefb240534f1bf2000b82a2b9cd7f6dd07277e3c4a53405a616349fbfd9525324388aa648dd8509
|
7
|
+
data.tar.gz: 14080c5a808c586787fabbcd5b7e7bf19e34b8c6093d638564fdc77405b2b203523c9b30b76f4e7df062aabaa2d0601fc3c4cf80ea6ff4a837ce725d5792fd7e
|
data/.gitignore
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
coverage
|
6
|
-
InstalledFiles
|
7
|
-
lib/bundler/man
|
8
|
-
pkg
|
9
|
-
rdoc
|
10
|
-
spec/reports
|
11
|
-
test/tmp
|
12
|
-
test/version_tmp
|
13
|
-
tmp
|
14
|
-
*~
|
15
|
-
Gemfile.lock
|
16
|
-
doc/
|
17
|
-
|
18
|
-
# YARD artifacts
|
19
|
-
.yardoc
|
20
|
-
_yardoc
|
21
|
-
doc/
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
coverage
|
6
|
+
InstalledFiles
|
7
|
+
lib/bundler/man
|
8
|
+
pkg
|
9
|
+
rdoc
|
10
|
+
spec/reports
|
11
|
+
test/tmp
|
12
|
+
test/version_tmp
|
13
|
+
tmp
|
14
|
+
*~
|
15
|
+
Gemfile.lock
|
16
|
+
doc/
|
17
|
+
|
18
|
+
# YARD artifacts
|
19
|
+
.yardoc
|
20
|
+
_yardoc
|
21
|
+
doc/
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in rubyscad_bundle.gemspec
|
4
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in rubyscad_bundle.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2013 cjbissonnette
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
1
|
+
Copyright (c) 2013 cjbissonnette
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,323 +1,323 @@
|
|
1
|
-
RubyScad
|
2
|
-
========
|
3
|
-
|
4
|
-
Ruby module to easily generate openscad scripts
|
5
|
-
|
6
|
-
General Usage
|
7
|
-
-------------
|
8
|
-
|
9
|
-
Requirements: Ruby 1.9.3
|
10
|
-
Installation: `gem install rubyscad`
|
11
|
-
|
12
|
-
RubyScad is a ruby mixin module which provides functions which allow easy output of openscad scripts . To use simply "include" or "extend" the module into any class or module:
|
13
|
-
|
14
|
-
require "rubyscad"
|
15
|
-
|
16
|
-
module Test
|
17
|
-
|
18
|
-
extend RubyScad
|
19
|
-
|
20
|
-
def self.cone(base=5, height=10)
|
21
|
-
|
22
|
-
cylinder(r1: base, r2: 0, h:height)
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
cone(2, 4)
|
27
|
-
end
|
28
|
-
|
29
|
-
---
|
30
|
-
|
31
|
-
from command line:
|
32
|
-
|
33
|
-
print to standard output: `ruby test.rb`
|
34
|
-
|
35
|
-
generate file: `ruby test.rb "test.scad"`
|
36
|
-
|
37
|
-
---
|
38
|
-
|
39
|
-
require "rubyscad"
|
40
|
-
|
41
|
-
class Test2
|
42
|
-
|
43
|
-
include RubyScad
|
44
|
-
|
45
|
-
def initialize(args={})
|
46
|
-
@radius = args.fetch(:radius, 3)
|
47
|
-
end
|
48
|
-
|
49
|
-
def render()
|
50
|
-
sphere(r:@radius)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
Test2.new.render
|
55
|
-
|
56
|
-
---
|
57
|
-
|
58
|
-
print to standard output: `ruby test2.rb`
|
59
|
-
|
60
|
-
generate file: `ruby test2.rb "test2.scad"`
|
61
|
-
|
62
|
-
General Considerations
|
63
|
-
-----------------------
|
64
|
-
|
65
|
-
- All arguments are passed as named hash values matching the openscad spec, exceptions are for functions fa, fs, fn, echo, include, and use (see below).
|
66
|
-
openscad: `cube(6)`
|
67
|
-
rubyscad: `cube(size: 6)`
|
68
|
-
- Any hash values may be passed to functions (with the exception of the ones noted above) but openscad may or may not use these values
|
69
|
-
*cube(openscadwontusethis: 5)* will produce *cube(openscadwontusethis = 5);*
|
70
|
-
nothing bad will happen here, the value will just have no effect
|
71
|
-
- $fn, $fs, $fa variables are passed without the '$'
|
72
|
-
openscad: `sphere(4, $fn=12)`
|
73
|
-
rubyscad: `sphere(r: 4, fn: 12)`
|
74
|
-
- Ruby's math functions use radians, openscad uses degrees, for ease I've added a 'radians' function to the numeric class so the following is possible:
|
75
|
-
openscad: sin(15)
|
76
|
-
rubyscad: Math.sin(15.radians)
|
77
|
-
- All functions which take code blocks (union, difference, intersection, ...) can use the form "function() { code }" or "function()" with the following result:
|
78
|
-
the code:
|
79
|
-
|
80
|
-
translate(x: 5)
|
81
|
-
cube(size: 7)
|
82
|
-
|
83
|
-
would produce:
|
84
|
-
|
85
|
-
translate([5,0,0])
|
86
|
-
cube(size = 7);
|
87
|
-
|
88
|
-
the code:
|
89
|
-
|
90
|
-
translate(x: 5) {
|
91
|
-
cube(size: 7)
|
92
|
-
}
|
93
|
-
|
94
|
-
would produce:
|
95
|
-
|
96
|
-
translate([5,0,0]) {
|
97
|
-
cube(size = 7);
|
98
|
-
}
|
99
|
-
|
100
|
-
Openscad Functions:
|
101
|
-
-------------------
|
102
|
-
|
103
|
-
openscad: `$fa = 0.2;`
|
104
|
-
rubyscad: `fa 0.2`
|
105
|
-
|
106
|
-
----------------------------------------------------------------------------
|
107
|
-
|
108
|
-
openscad: `$fs = 2;`
|
109
|
-
rubyscad: `fs 2`
|
110
|
-
|
111
|
-
----------------------------------------------------------------------------
|
112
|
-
|
113
|
-
openscad: `$fn = 5;`
|
114
|
-
rubyscad: `fn 5`
|
115
|
-
|
116
|
-
----------------------------------------------------------------------------
|
117
|
-
|
118
|
-
openscad: `include <file.scad>`
|
119
|
-
rubyscad: `include_scad "file.scad"`
|
120
|
-
|
121
|
-
----------------------------------------------------------------------------
|
122
|
-
|
123
|
-
openscad: `use <file.scad>`
|
124
|
-
rubyscad: `use "file.scad"`
|
125
|
-
|
126
|
-
----------------------------------------------------------------------------
|
127
|
-
|
128
|
-
openscad: `echo(1,2,3);`
|
129
|
-
rubyscad: `echo 1, 2, 3`
|
130
|
-
|
131
|
-
----------------------------------------------------------------------------
|
132
|
-
|
133
|
-
openscad: `%`
|
134
|
-
rubyscad: `background`
|
135
|
-
|
136
|
-
----------------------------------------------------------------------------
|
137
|
-
|
138
|
-
openscad: `#`
|
139
|
-
rubyscad: `debug`
|
140
|
-
|
141
|
-
----------------------------------------------------------------------------
|
142
|
-
|
143
|
-
openscad: `!`
|
144
|
-
rubyscad: `root`
|
145
|
-
|
146
|
-
----------------------------------------------------------------------------
|
147
|
-
|
148
|
-
openscad: `*`
|
149
|
-
rubyscad: `disable`
|
150
|
-
|
151
|
-
----------------------------------------------------------------------------
|
152
|
-
|
153
|
-
openscad: `projection([args]) [{ code }]`
|
154
|
-
rubyscad: `projection([args]) [{ code }]`
|
155
|
-
|
156
|
-
----------------------------------------------------------------------------
|
157
|
-
|
158
|
-
openscad: `linear_extrude([args]) [{ code }]`
|
159
|
-
rubyscad: `linear_extrude([args]) [{ code }]`
|
160
|
-
|
161
|
-
----------------------------------------------------------------------------
|
162
|
-
|
163
|
-
openscad: `rotate_extrude([args]) [{ code }]`
|
164
|
-
rubyscad: `rotate_extrude([args]) [{ code }]`
|
165
|
-
|
166
|
-
----------------------------------------------------------------------------
|
167
|
-
|
168
|
-
openscad: `import([args])`
|
169
|
-
rubyscad: `import([args])`
|
170
|
-
|
171
|
-
----------------------------------------------------------------------------
|
172
|
-
|
173
|
-
openscad: `difference() { code }`
|
174
|
-
rubyscad: `difference() { code }`
|
175
|
-
|
176
|
-
----------------------------------------------------------------------------
|
177
|
-
|
178
|
-
openscad: `union() { code }`
|
179
|
-
rubyscad: `union() { code }`
|
180
|
-
|
181
|
-
----------------------------------------------------------------------------
|
182
|
-
|
183
|
-
openscad: `intersection() { code }`
|
184
|
-
rubyscad: `intersection() { code }`
|
185
|
-
|
186
|
-
----------------------------------------------------------------------------
|
187
|
-
|
188
|
-
openscad: `render([args]) [{ code }]`
|
189
|
-
rubyscad: `render([args]) [{ code }]`
|
190
|
-
|
191
|
-
----------------------------------------------------------------------------
|
192
|
-
|
193
|
-
openscad: `minkowski() { code }`
|
194
|
-
rubyscad: `minkowski() { code }`
|
195
|
-
|
196
|
-
----------------------------------------------------------------------------
|
197
|
-
|
198
|
-
openscad: `hull() { code }`
|
199
|
-
rubyscad: `hull() { code }`
|
200
|
-
|
201
|
-
----------------------------------------------------------------------------
|
202
|
-
|
203
|
-
openscad: `cube([args])`
|
204
|
-
rubyscad: `cube([args])`
|
205
|
-
|
206
|
-
----------------------------------------------------------------------------
|
207
|
-
|
208
|
-
openscad: `sphere([args])`
|
209
|
-
rubyscad: `sphere([args])`
|
210
|
-
|
211
|
-
* In addition to the normal arguments d: can also be provided instead of r: to specify the diameter instead of the radius
|
212
|
-
|
213
|
-
----------------------------------------------------------------------------
|
214
|
-
|
215
|
-
openscad: `polyhedron([args])`
|
216
|
-
rubyscad: `polyhedron([args])`
|
217
|
-
|
218
|
-
----------------------------------------------------------------------------
|
219
|
-
|
220
|
-
openscad: `square([args])`
|
221
|
-
rubyscad: `square([args])`
|
222
|
-
|
223
|
-
----------------------------------------------------------------------------
|
224
|
-
|
225
|
-
openscad: `circle([args])`
|
226
|
-
rubyscad: `circle([args])`
|
227
|
-
|
228
|
-
* In addition to the normal arguments d: can also be provided instead of r: to specify the diameter instead of the radius
|
229
|
-
|
230
|
-
----------------------------------------------------------------------------
|
231
|
-
|
232
|
-
openscad: `polygon([args])`
|
233
|
-
rubyscad: `polygon([args])`
|
234
|
-
|
235
|
-
----------------------------------------------------------------------------
|
236
|
-
|
237
|
-
openscad: `surface([args])`
|
238
|
-
rubyscad: `surface([args])`
|
239
|
-
|
240
|
-
----------------------------------------------------------------------------
|
241
|
-
|
242
|
-
openscad: `cylinder([args])`
|
243
|
-
rubyscad: `cylinder([args])`
|
244
|
-
|
245
|
-
----------------------------------------------------------------------------
|
246
|
-
|
247
|
-
openscad: `rotate([args]) [{ code }]`
|
248
|
-
rubyscad: `rotate([args]) [{ code }]`
|
249
|
-
|
250
|
-
* In addition to specifying a: as a vector x:, y:, and z: can be used instead
|
251
|
-
|
252
|
-
----------------------------------------------------------------------------
|
253
|
-
|
254
|
-
openscad: `translate([args]) [{ code }]`
|
255
|
-
rubyscad: `translate([args]) [{ code }]`
|
256
|
-
|
257
|
-
* In addition to specifying v: as a vector x:, y:, and z: can be used instead
|
258
|
-
|
259
|
-
----------------------------------------------------------------------------
|
260
|
-
|
261
|
-
openscad: `scale([args]) [{ code }]`
|
262
|
-
rubyscad: `scale([args]) [{ code }]`
|
263
|
-
|
264
|
-
* In addition to specifying v: as a vector x:, y:, and z: can be used instead
|
265
|
-
|
266
|
-
----------------------------------------------------------------------------
|
267
|
-
|
268
|
-
openscad: `mirror([args]) [{ code }]`
|
269
|
-
rubyscad: `mirror([args]) [{ code }]`
|
270
|
-
|
271
|
-
* In addition to specifying v: as a vector x:, y:, and z: can be used instead
|
272
|
-
|
273
|
-
----------------------------------------------------------------------------
|
274
|
-
|
275
|
-
openscad: `multmatrix([args]) [{ code }]`
|
276
|
-
rubyscad: `multmatrix([args]) [{ code }]`
|
277
|
-
|
278
|
-
----------------------------------------------------------------------------
|
279
|
-
|
280
|
-
openscad: `color([args]) [{ code }]`
|
281
|
-
rubyscad: `color([args]) [{ code }]`
|
282
|
-
|
283
|
-
* Instead of color: being defined, r:, g:, b:, and a: can be provided
|
284
|
-
|
285
|
-
RubyScad Functions:
|
286
|
-
-------------------
|
287
|
-
|
288
|
-
`format_command(cmd_str, args={}, &block)`
|
289
|
-
|
290
|
-
* an easy way to implement new openscad commands.
|
291
|
-
* cmd\_str should be in the form "func\_name(%<args>);"
|
292
|
-
* all arguments passed from "args" will be inserted into the <args> string modifier
|
293
|
-
* if a block is passed it will output between { }
|
294
|
-
|
295
|
-
----------------------------------------------------------------------------
|
296
|
-
|
297
|
-
`new_line`
|
298
|
-
|
299
|
-
* outputs a new line
|
300
|
-
|
301
|
-
----------------------------------------------------------------------------
|
302
|
-
|
303
|
-
`start_block`
|
304
|
-
|
305
|
-
* outputs a '{' at the correct tab level
|
306
|
-
|
307
|
-
----------------------------------------------------------------------------
|
308
|
-
|
309
|
-
`end_block`
|
310
|
-
|
311
|
-
* outputs a '}' at the correct tab level
|
312
|
-
|
313
|
-
----------------------------------------------------------------------------
|
314
|
-
|
315
|
-
`end_all_blocks`
|
316
|
-
|
317
|
-
* outputs a '}' for every open block
|
318
|
-
|
319
|
-
----------------------------------------------------------------------------
|
320
|
-
|
321
|
-
`format_output`
|
322
|
-
|
1
|
+
RubyScad
|
2
|
+
========
|
3
|
+
|
4
|
+
Ruby module to easily generate openscad scripts
|
5
|
+
|
6
|
+
General Usage
|
7
|
+
-------------
|
8
|
+
|
9
|
+
Requirements: Ruby 1.9.3
|
10
|
+
Installation: `gem install rubyscad`
|
11
|
+
|
12
|
+
RubyScad is a ruby mixin module which provides functions which allow easy output of openscad scripts . To use simply "include" or "extend" the module into any class or module:
|
13
|
+
|
14
|
+
require "rubyscad"
|
15
|
+
|
16
|
+
module Test
|
17
|
+
|
18
|
+
extend RubyScad
|
19
|
+
|
20
|
+
def self.cone(base=5, height=10)
|
21
|
+
|
22
|
+
cylinder(r1: base, r2: 0, h:height)
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
cone(2, 4)
|
27
|
+
end
|
28
|
+
|
29
|
+
---
|
30
|
+
|
31
|
+
from command line:
|
32
|
+
|
33
|
+
print to standard output: `ruby test.rb`
|
34
|
+
|
35
|
+
generate file: `ruby test.rb "test.scad"`
|
36
|
+
|
37
|
+
---
|
38
|
+
|
39
|
+
require "rubyscad"
|
40
|
+
|
41
|
+
class Test2
|
42
|
+
|
43
|
+
include RubyScad
|
44
|
+
|
45
|
+
def initialize(args={})
|
46
|
+
@radius = args.fetch(:radius, 3)
|
47
|
+
end
|
48
|
+
|
49
|
+
def render()
|
50
|
+
sphere(r:@radius)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Test2.new.render
|
55
|
+
|
56
|
+
---
|
57
|
+
|
58
|
+
print to standard output: `ruby test2.rb`
|
59
|
+
|
60
|
+
generate file: `ruby test2.rb "test2.scad"`
|
61
|
+
|
62
|
+
General Considerations
|
63
|
+
-----------------------
|
64
|
+
|
65
|
+
- All arguments are passed as named hash values matching the openscad spec, exceptions are for functions fa, fs, fn, echo, include, and use (see below).
|
66
|
+
openscad: `cube(6)`
|
67
|
+
rubyscad: `cube(size: 6)`
|
68
|
+
- Any hash values may be passed to functions (with the exception of the ones noted above) but openscad may or may not use these values
|
69
|
+
*cube(openscadwontusethis: 5)* will produce *cube(openscadwontusethis = 5);*
|
70
|
+
nothing bad will happen here, the value will just have no effect
|
71
|
+
- $fn, $fs, $fa variables are passed without the '$'
|
72
|
+
openscad: `sphere(4, $fn=12)`
|
73
|
+
rubyscad: `sphere(r: 4, fn: 12)`
|
74
|
+
- Ruby's math functions use radians, openscad uses degrees, for ease I've added a 'radians' function to the numeric class so the following is possible:
|
75
|
+
openscad: sin(15)
|
76
|
+
rubyscad: Math.sin(15.radians)
|
77
|
+
- All functions which take code blocks (union, difference, intersection, ...) can use the form "function() { code }" or "function()" with the following result:
|
78
|
+
the code:
|
79
|
+
|
80
|
+
translate(x: 5)
|
81
|
+
cube(size: 7)
|
82
|
+
|
83
|
+
would produce:
|
84
|
+
|
85
|
+
translate([5,0,0])
|
86
|
+
cube(size = 7);
|
87
|
+
|
88
|
+
the code:
|
89
|
+
|
90
|
+
translate(x: 5) {
|
91
|
+
cube(size: 7)
|
92
|
+
}
|
93
|
+
|
94
|
+
would produce:
|
95
|
+
|
96
|
+
translate([5,0,0]) {
|
97
|
+
cube(size = 7);
|
98
|
+
}
|
99
|
+
|
100
|
+
Openscad Functions:
|
101
|
+
-------------------
|
102
|
+
|
103
|
+
openscad: `$fa = 0.2;`
|
104
|
+
rubyscad: `fa 0.2`
|
105
|
+
|
106
|
+
----------------------------------------------------------------------------
|
107
|
+
|
108
|
+
openscad: `$fs = 2;`
|
109
|
+
rubyscad: `fs 2`
|
110
|
+
|
111
|
+
----------------------------------------------------------------------------
|
112
|
+
|
113
|
+
openscad: `$fn = 5;`
|
114
|
+
rubyscad: `fn 5`
|
115
|
+
|
116
|
+
----------------------------------------------------------------------------
|
117
|
+
|
118
|
+
openscad: `include <file.scad>`
|
119
|
+
rubyscad: `include_scad "file.scad"`
|
120
|
+
|
121
|
+
----------------------------------------------------------------------------
|
122
|
+
|
123
|
+
openscad: `use <file.scad>`
|
124
|
+
rubyscad: `use "file.scad"`
|
125
|
+
|
126
|
+
----------------------------------------------------------------------------
|
127
|
+
|
128
|
+
openscad: `echo(1,2,3);`
|
129
|
+
rubyscad: `echo 1, 2, 3`
|
130
|
+
|
131
|
+
----------------------------------------------------------------------------
|
132
|
+
|
133
|
+
openscad: `%`
|
134
|
+
rubyscad: `background`
|
135
|
+
|
136
|
+
----------------------------------------------------------------------------
|
137
|
+
|
138
|
+
openscad: `#`
|
139
|
+
rubyscad: `debug`
|
140
|
+
|
141
|
+
----------------------------------------------------------------------------
|
142
|
+
|
143
|
+
openscad: `!`
|
144
|
+
rubyscad: `root`
|
145
|
+
|
146
|
+
----------------------------------------------------------------------------
|
147
|
+
|
148
|
+
openscad: `*`
|
149
|
+
rubyscad: `disable`
|
150
|
+
|
151
|
+
----------------------------------------------------------------------------
|
152
|
+
|
153
|
+
openscad: `projection([args]) [{ code }]`
|
154
|
+
rubyscad: `projection([args]) [{ code }]`
|
155
|
+
|
156
|
+
----------------------------------------------------------------------------
|
157
|
+
|
158
|
+
openscad: `linear_extrude([args]) [{ code }]`
|
159
|
+
rubyscad: `linear_extrude([args]) [{ code }]`
|
160
|
+
|
161
|
+
----------------------------------------------------------------------------
|
162
|
+
|
163
|
+
openscad: `rotate_extrude([args]) [{ code }]`
|
164
|
+
rubyscad: `rotate_extrude([args]) [{ code }]`
|
165
|
+
|
166
|
+
----------------------------------------------------------------------------
|
167
|
+
|
168
|
+
openscad: `import([args])`
|
169
|
+
rubyscad: `import([args])`
|
170
|
+
|
171
|
+
----------------------------------------------------------------------------
|
172
|
+
|
173
|
+
openscad: `difference() { code }`
|
174
|
+
rubyscad: `difference() { code }`
|
175
|
+
|
176
|
+
----------------------------------------------------------------------------
|
177
|
+
|
178
|
+
openscad: `union() { code }`
|
179
|
+
rubyscad: `union() { code }`
|
180
|
+
|
181
|
+
----------------------------------------------------------------------------
|
182
|
+
|
183
|
+
openscad: `intersection() { code }`
|
184
|
+
rubyscad: `intersection() { code }`
|
185
|
+
|
186
|
+
----------------------------------------------------------------------------
|
187
|
+
|
188
|
+
openscad: `render([args]) [{ code }]`
|
189
|
+
rubyscad: `render([args]) [{ code }]`
|
190
|
+
|
191
|
+
----------------------------------------------------------------------------
|
192
|
+
|
193
|
+
openscad: `minkowski() { code }`
|
194
|
+
rubyscad: `minkowski() { code }`
|
195
|
+
|
196
|
+
----------------------------------------------------------------------------
|
197
|
+
|
198
|
+
openscad: `hull() { code }`
|
199
|
+
rubyscad: `hull() { code }`
|
200
|
+
|
201
|
+
----------------------------------------------------------------------------
|
202
|
+
|
203
|
+
openscad: `cube([args])`
|
204
|
+
rubyscad: `cube([args])`
|
205
|
+
|
206
|
+
----------------------------------------------------------------------------
|
207
|
+
|
208
|
+
openscad: `sphere([args])`
|
209
|
+
rubyscad: `sphere([args])`
|
210
|
+
|
211
|
+
* In addition to the normal arguments d: can also be provided instead of r: to specify the diameter instead of the radius
|
212
|
+
|
213
|
+
----------------------------------------------------------------------------
|
214
|
+
|
215
|
+
openscad: `polyhedron([args])`
|
216
|
+
rubyscad: `polyhedron([args])`
|
217
|
+
|
218
|
+
----------------------------------------------------------------------------
|
219
|
+
|
220
|
+
openscad: `square([args])`
|
221
|
+
rubyscad: `square([args])`
|
222
|
+
|
223
|
+
----------------------------------------------------------------------------
|
224
|
+
|
225
|
+
openscad: `circle([args])`
|
226
|
+
rubyscad: `circle([args])`
|
227
|
+
|
228
|
+
* In addition to the normal arguments d: can also be provided instead of r: to specify the diameter instead of the radius
|
229
|
+
|
230
|
+
----------------------------------------------------------------------------
|
231
|
+
|
232
|
+
openscad: `polygon([args])`
|
233
|
+
rubyscad: `polygon([args])`
|
234
|
+
|
235
|
+
----------------------------------------------------------------------------
|
236
|
+
|
237
|
+
openscad: `surface([args])`
|
238
|
+
rubyscad: `surface([args])`
|
239
|
+
|
240
|
+
----------------------------------------------------------------------------
|
241
|
+
|
242
|
+
openscad: `cylinder([args])`
|
243
|
+
rubyscad: `cylinder([args])`
|
244
|
+
|
245
|
+
----------------------------------------------------------------------------
|
246
|
+
|
247
|
+
openscad: `rotate([args]) [{ code }]`
|
248
|
+
rubyscad: `rotate([args]) [{ code }]`
|
249
|
+
|
250
|
+
* In addition to specifying a: as a vector x:, y:, and z: can be used instead
|
251
|
+
|
252
|
+
----------------------------------------------------------------------------
|
253
|
+
|
254
|
+
openscad: `translate([args]) [{ code }]`
|
255
|
+
rubyscad: `translate([args]) [{ code }]`
|
256
|
+
|
257
|
+
* In addition to specifying v: as a vector x:, y:, and z: can be used instead
|
258
|
+
|
259
|
+
----------------------------------------------------------------------------
|
260
|
+
|
261
|
+
openscad: `scale([args]) [{ code }]`
|
262
|
+
rubyscad: `scale([args]) [{ code }]`
|
263
|
+
|
264
|
+
* In addition to specifying v: as a vector x:, y:, and z: can be used instead
|
265
|
+
|
266
|
+
----------------------------------------------------------------------------
|
267
|
+
|
268
|
+
openscad: `mirror([args]) [{ code }]`
|
269
|
+
rubyscad: `mirror([args]) [{ code }]`
|
270
|
+
|
271
|
+
* In addition to specifying v: as a vector x:, y:, and z: can be used instead
|
272
|
+
|
273
|
+
----------------------------------------------------------------------------
|
274
|
+
|
275
|
+
openscad: `multmatrix([args]) [{ code }]`
|
276
|
+
rubyscad: `multmatrix([args]) [{ code }]`
|
277
|
+
|
278
|
+
----------------------------------------------------------------------------
|
279
|
+
|
280
|
+
openscad: `color([args]) [{ code }]`
|
281
|
+
rubyscad: `color([args]) [{ code }]`
|
282
|
+
|
283
|
+
* Instead of color: being defined, r:, g:, b:, and a: can be provided
|
284
|
+
|
285
|
+
RubyScad Functions:
|
286
|
+
-------------------
|
287
|
+
|
288
|
+
`format_command(cmd_str, args={}, &block)`
|
289
|
+
|
290
|
+
* an easy way to implement new openscad commands.
|
291
|
+
* cmd\_str should be in the form "func\_name(%<args>);"
|
292
|
+
* all arguments passed from "args" will be inserted into the <args> string modifier
|
293
|
+
* if a block is passed it will output between { }
|
294
|
+
|
295
|
+
----------------------------------------------------------------------------
|
296
|
+
|
297
|
+
`new_line`
|
298
|
+
|
299
|
+
* outputs a new line
|
300
|
+
|
301
|
+
----------------------------------------------------------------------------
|
302
|
+
|
303
|
+
`start_block`
|
304
|
+
|
305
|
+
* outputs a '{' at the correct tab level
|
306
|
+
|
307
|
+
----------------------------------------------------------------------------
|
308
|
+
|
309
|
+
`end_block`
|
310
|
+
|
311
|
+
* outputs a '}' at the correct tab level
|
312
|
+
|
313
|
+
----------------------------------------------------------------------------
|
314
|
+
|
315
|
+
`end_all_blocks`
|
316
|
+
|
317
|
+
* outputs a '}' for every open block
|
318
|
+
|
319
|
+
----------------------------------------------------------------------------
|
320
|
+
|
321
|
+
`format_output`
|
322
|
+
|
323
323
|
* outputs a string at the correct tab level
|