crystalscad 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/printed_gear2.rb +18 -0
- data/examples/threads2.rb +1 -0
- data/lib/crystalscad/Hardware.rb +71 -13
- data/lib/crystalscad/ScrewThreads.rb +10 -4
- data/lib/crystalscad/version.rb +1 -1
- metadata +8 -5
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/ruby1.9.3
|
2
|
+
require "rubygems"
|
3
|
+
require "crystalscad"
|
4
|
+
include CrystalScad
|
5
|
+
|
6
|
+
|
7
|
+
g1 = PrintedGear.new(module:2.0,teeth:40,bore:8.5,height:6)
|
8
|
+
res = g1.show.color("red")
|
9
|
+
|
10
|
+
res += cylinder(d:20,h:nut_support_height=20)
|
11
|
+
|
12
|
+
n = Nut.new(8)
|
13
|
+
res -= n.output.translate(z:nut_support_height-n.height+0.1)
|
14
|
+
|
15
|
+
res -= cylinder(d:8.5,h:nut_support_height)
|
16
|
+
|
17
|
+
res.save("printed_gear2.scad")
|
18
|
+
|
data/examples/threads2.rb
CHANGED
@@ -79,6 +79,7 @@ pos = male.threads_bottom.first.position_on(female.threads_top.first,rotation)
|
|
79
79
|
res += female.show.rotate(rotation).mirror(z:1).translate(pos)
|
80
80
|
|
81
81
|
|
82
|
+
|
82
83
|
rotation = {y:-90}
|
83
84
|
pos = male.threads_left.first.position_on(female.threads_top.first,rotation)
|
84
85
|
res += female.show.rotate(rotation).translate(pos)
|
data/lib/crystalscad/Hardware.rb
CHANGED
@@ -207,7 +207,7 @@ module CrystalScad::Hardware
|
|
207
207
|
|
208
208
|
def output(margin=0.3)
|
209
209
|
add_to_bom
|
210
|
-
return nut_934(margin)
|
210
|
+
return nut_934(false,margin)
|
211
211
|
end
|
212
212
|
|
213
213
|
def show
|
@@ -215,10 +215,10 @@ module CrystalScad::Hardware
|
|
215
215
|
return nut_934
|
216
216
|
end
|
217
217
|
|
218
|
-
def nut_934(margin=0)
|
218
|
+
def nut_934(show=true,margin=0)
|
219
219
|
@s += margin
|
220
220
|
nut=cylinder(d:(@s/Math.sqrt(3))*2,h:@height,fn:6)
|
221
|
-
nut-=cylinder(d:@size,h:@height)
|
221
|
+
nut-=cylinder(d:@size,h:@height) if show == true
|
222
222
|
nut.color("Gainsboro")
|
223
223
|
end
|
224
224
|
|
@@ -240,24 +240,81 @@ module CrystalScad::Hardware
|
|
240
240
|
@args[:gap] ||= 8.13
|
241
241
|
@args[:thickness] ||= 2.55
|
242
242
|
@args[:simple] ||= false
|
243
|
+
@machining = CrystalScadObject.new
|
244
|
+
@machining_string = ""
|
243
245
|
end
|
244
246
|
|
245
|
-
def output
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
@@bom.add(description) unless args[:no_bom] == true
|
250
|
-
|
251
|
-
return single_profile.color("Silver") if @args[:configuration] == 1
|
252
|
-
return multi_profile.color("Silver")
|
247
|
+
def output
|
248
|
+
res = profile
|
249
|
+
|
250
|
+
res - @machining
|
253
251
|
end
|
254
252
|
|
255
253
|
alias :show :output
|
256
254
|
|
257
255
|
def description
|
258
|
-
"T-Slot #{@args[:size]}x#{@args[:size]*@args[:configuration]}, length #{@args[:length]}mm"
|
256
|
+
"T-Slot #{@args[:size]}x#{@args[:size]*@args[:configuration]}, length #{@args[:length]}mm #{@machining_string}"
|
259
257
|
end
|
260
|
-
|
258
|
+
|
259
|
+
def length(length)
|
260
|
+
@args[:length] = length
|
261
|
+
self
|
262
|
+
end
|
263
|
+
|
264
|
+
def thread(args={})
|
265
|
+
position = args[:position] || "front"
|
266
|
+
@machining_string += "with thread on #{position} "
|
267
|
+
self
|
268
|
+
end
|
269
|
+
|
270
|
+
def threads
|
271
|
+
self.thread().thread(position:"back")
|
272
|
+
end
|
273
|
+
|
274
|
+
def holes(args={})
|
275
|
+
args[:position] = "front"
|
276
|
+
res = self.hole(args)
|
277
|
+
args[:position] = "back"
|
278
|
+
res.hole(args)
|
279
|
+
end
|
280
|
+
|
281
|
+
def hole(args={})
|
282
|
+
diameter = args[:diameter] || 8
|
283
|
+
position = args[:position] || "front"
|
284
|
+
side = args[:side] || "x"
|
285
|
+
|
286
|
+
if position.kind_of? String
|
287
|
+
case position
|
288
|
+
when "front"
|
289
|
+
z = @args[:size]/2
|
290
|
+
@machining_string += "with #{diameter}mm hole on front "
|
291
|
+
when "back"
|
292
|
+
z = @args[:length] - @args[:size]/2
|
293
|
+
@machining_string += "with #{diameter}mm hole on back "
|
294
|
+
end
|
295
|
+
else
|
296
|
+
z = position
|
297
|
+
@machining_string += "with #{diameter}mm hole on #{z}mm "
|
298
|
+
end
|
299
|
+
|
300
|
+
@args[:configuration].times do |c|
|
301
|
+
cyl = cylinder(d:diameter,h:@args[:size])
|
302
|
+
if side == "x"
|
303
|
+
@machining += cyl.rotate(x:-90).translate(x:@args[:size]/2+c*@args[:size],z:z)
|
304
|
+
else
|
305
|
+
@machining += cyl.rotate(y:90).translate(y:@args[:size]/2+c*@args[:size],z:z)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
self
|
310
|
+
end
|
311
|
+
|
312
|
+
def profile
|
313
|
+
@@bom.add(description) unless args[:no_bom] == true
|
314
|
+
return single_profile.color("Silver") if @args[:configuration] == 1
|
315
|
+
return multi_profile.color("Silver")
|
316
|
+
end
|
317
|
+
|
261
318
|
def single_profile
|
262
319
|
if @args[:simple] == true
|
263
320
|
return cube([@args[:size],@args[:size],@args[:length]])
|
@@ -294,6 +351,7 @@ module CrystalScad::Hardware
|
|
294
351
|
@args[:holes] ||= "front,back" # nil, front, back
|
295
352
|
@args[:bolt_size] ||= 8
|
296
353
|
@args[:bolt_length] ||= 25
|
354
|
+
puts "TSlotMachining is deprecated and will be removed in the 0.4.0 release."
|
297
355
|
end
|
298
356
|
|
299
357
|
alias tslot_output output
|
@@ -67,10 +67,16 @@ module CrystalScad::ScrewThreads
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def position_on(other_thread,rotation={})
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
if other_thread.kind_of? Bolt
|
71
|
+
# we assume that a bolt is always centered and center the object on
|
72
|
+
# the screwthread position
|
73
|
+
return {x:-@x,y:-@y,z:-@z}
|
74
|
+
else
|
75
|
+
# on a screwthread find out its position and orientation
|
76
|
+
oc = other_thread.x, other_thread.y, other_thread.z
|
77
|
+
oc = orientation_swap_to(oc,rotation)
|
78
|
+
return {x:@x-oc[0],y:@y-oc[1],z:@z-oc[2]}
|
79
|
+
end
|
74
80
|
end
|
75
81
|
|
76
82
|
end
|
data/lib/crystalscad/version.rb
CHANGED
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:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 9
|
10
|
+
version: 0.3.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joachim Glauche
|
@@ -15,7 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2014-01-
|
18
|
+
date: 2014-01-17 00:00:00 +01:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rubyscad
|
@@ -69,6 +70,7 @@ files:
|
|
69
70
|
- examples/openscad_examples/example004.rb
|
70
71
|
- examples/openscad_examples/example005.rb
|
71
72
|
- examples/printed_gear.rb
|
73
|
+
- examples/printed_gear2.rb
|
72
74
|
- examples/stack.rb
|
73
75
|
- examples/threads.rb
|
74
76
|
- examples/threads2.rb
|
@@ -84,6 +86,7 @@ files:
|
|
84
86
|
- skeleton_project/assemblies/example.rb
|
85
87
|
- skeleton_project/observe.sh
|
86
88
|
- skeleton_project/skeleton.rb
|
89
|
+
has_rdoc: true
|
87
90
|
homepage: http://github.com/Joaz/CrystalScad
|
88
91
|
licenses:
|
89
92
|
- GPL-3
|
@@ -115,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
118
|
requirements: []
|
116
119
|
|
117
120
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.
|
121
|
+
rubygems_version: 1.6.2
|
119
122
|
signing_key:
|
120
123
|
specification_version: 3
|
121
124
|
summary: CrystalScad is a framework for programming OpenScad models in Ruby
|