crystalscad 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/ruby1.9.3
2
+ require "rubygems"
3
+ require "crystalscad"
4
+ include CrystalScad
5
+
6
+ # Used to debug
7
+ # https://github.com/Joaz/CrystalScad/issues/5
8
+
9
+ pipe = Pipe.new(diameter:10)
10
+
11
+ pipe.line(5,"red")
12
+ pipe.cw(20,8,"yellow")
13
+ pipe.line(20,"blue")
14
+
15
+
16
+
17
+ res = pipe.pipe
18
+
19
+ res.save("pipe_bug.scad","$fn=64;")
20
+
21
+
22
+
23
+
@@ -25,7 +25,7 @@ module CrystalScad
25
25
  include CrystalScad::ScrewThreads
26
26
  include CrystalScad::PrintedThreads
27
27
  include CrystalScad::Extras
28
-
28
+ include Math
29
29
 
30
30
 
31
31
 
@@ -200,9 +200,12 @@ module CrystalScad
200
200
 
201
201
  end
202
202
 
203
- def square(args)
203
+ def square(args,y=nil)
204
204
  if args.kind_of? Array
205
205
  args = {size:args}
206
+ elsif args.kind_of? Numeric
207
+ x = args
208
+ args = {size:[x,y]}
206
209
  elsif args.kind_of? Hash
207
210
  unless args[:size]
208
211
  args[:x] ||= 0
@@ -327,7 +330,7 @@ module CrystalScad
327
330
  end
328
331
 
329
332
  def optimize_union(top, child)
330
- if top.kind_of? Union and not child.kind_of? Union
333
+ if top.kind_of? Union and not child.kind_of? Union and top.transformations.to_a.size == 0
331
334
  top.children << child
332
335
  return top
333
336
  else
@@ -167,6 +167,8 @@ module CrystalScad::ScrewThreads
167
167
  bolt.transformations << Rotate.new(x:90)
168
168
  bolt.transformations << Translate.new({x:hole.x,y:hole.y+height,z:hole.z})
169
169
  end
170
+ bolt.transformations += obj2.transformations unless obj2.transformations == nil
171
+
170
172
 
171
173
  ret << bolt
172
174
  end
@@ -1,4 +1,4 @@
1
1
  module CrystalScad
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
4
4
 
@@ -0,0 +1,364 @@
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 crystalscad
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
+ # Primitives
339
+ ## Cube
340
+ Creates a cube at the origin of the coordinate system.
341
+
342
+ ```ruby
343
+ # 2D modeling
344
+ cube(x: value , y: value)
345
+
346
+ # 3D modeling
347
+ cube(x: value , y: value, z: value)
348
+
349
+ # also accepts size, which will make a cube with x,y,z = 1
350
+ cube(size: 1)
351
+ ```
352
+ ### Centering
353
+
354
+
355
+
356
+
357
+ </textarea>
358
+ <script src="out/remark.js" type="text/javascript">
359
+ </script>
360
+ <script type="text/javascript">
361
+ var slideshow = remark.create();
362
+ </script>
363
+ </body>
364
+ </html>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crystalscad
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 3
10
- version: 0.6.3
9
+ - 4
10
+ version: 0.6.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joachim Glauche
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2015-05-15 00:00:00 Z
18
+ date: 2015-06-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rubyscad
@@ -104,6 +104,7 @@ files:
104
104
  - examples/openscad_examples/example004.rb
105
105
  - examples/openscad_examples/example005.rb
106
106
  - examples/pipe.rb
107
+ - examples/pipe_bug.rb
107
108
  - examples/printed_gear.rb
108
109
  - examples/printed_gear2.rb
109
110
  - examples/printed_thread.rb
@@ -127,6 +128,7 @@ files:
127
128
  - lib/crystalscad/Ruler.rb
128
129
  - lib/crystalscad/ScrewThreads.rb
129
130
  - lib/crystalscad/version.rb
131
+ - manual/manual.html
130
132
  - skeleton_project/assemblies/example.rb
131
133
  - skeleton_project/observe.sh
132
134
  - skeleton_project/skeleton.rb