crystalscad 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,12 +1,18 @@
1
1
  CrystalScad
2
2
  ===========
3
3
 
4
- Produce OpenSCAD code in Ruby. Based on RubyScad
4
+ Produce OpenSCAD code in Ruby.
5
5
 
6
6
  Requires Ruby 1.9.3
7
+ Required gems: rubyscad
7
8
 
8
- Currently not feature complete
9
+ Currently not OpenSCAD feature complete
9
10
 
11
+ Installation:
12
+ ===========
13
+ #gem install crystalscad
14
+
15
+ if you have multiple ruby versions, you likely need to use gem1.9.3 instead of gem
10
16
 
11
17
  Features
12
18
  ===========
@@ -14,28 +20,9 @@ Features
14
20
  - Automatic BOM when using the Hardware lib
15
21
 
16
22
 
17
- Example Code:
23
+ Real World Example:
18
24
  ===========
19
-
20
- require "crystalscad"
21
-
22
- include CrystalScad
23
-
24
- assembly = cylinder(r:5,h:10).translate(x:10).rotate(y:45)
25
-
26
- assembly+= cube([10,20,30]).translate(x:-1)
27
-
28
- assembly-= Bolt.new(3,25).output.translate(x:2,y:2)
29
-
30
- assembly-= Bolt.new(3,25).output.translate(x:6,y:6)
31
-
32
-
33
- # for openscad output
34
- puts assembly.output
35
-
36
-
37
- # for BOM output
38
- puts @@bom.output
25
+ https://github.com/Joaz/bulldozer/blob/master/new_model/bulldozer.rb
39
26
 
40
27
 
41
28
 
@@ -55,11 +55,59 @@ module CrystalScad::Hardware
55
55
  end
56
56
  res
57
57
  end
58
-
59
-
60
-
58
+
59
+ end
60
+
61
+
62
+ class Nut
63
+ attr_accessor :height
64
+ def initialize(size,args={})
65
+ @size = size
66
+ @type = args[:type] ||= "934"
67
+ @material = args[:material] ||= "8.8"
68
+ @surface = args[:surface] ||= "zinc plated"
69
+
70
+ @@bom.add(description) unless args[:no_bom] == true
71
+ prepare_data
72
+ end
73
+
74
+ def description
75
+ "M#{@size} Nut, DIN #{@type}, #{@material} #{@surface}"
76
+ end
77
+
78
+ def prepare_data
79
+ chart_934 = {2.5=> {side_to_side:5,height:2},
80
+ 3 => {side_to_side:5.5,height:2.4},
81
+ 4 => {side_to_side:7,height:3.2},
82
+ 5 => {side_to_side:8,height:4},
83
+ 6 => {side_to_side:10,height:5},
84
+ 8 => {side_to_side:13,height:6.5},
85
+ 10 => {side_to_side:17,height:8},
86
+ 12 => {side_to_side:19,height:10},
87
+
88
+ }
89
+ @s = chart_934[@size][:side_to_side]
90
+ @height = chart_934[@size][:height]
91
+ end
92
+
93
+ def output(margin=0.2)
94
+ return nut_934(margin)
95
+ end
96
+
97
+ def show
98
+ return nut_934
99
+ end
100
+
101
+ def nut_934(margin=0)
102
+ @s += margin
103
+ nut=cylinder(d:(@s/Math.sqrt(3))*2,h:@height,fn:6)
104
+ nut-=cylinder(d:@size,h:@height)
105
+ nut.color("Gainsboro")
106
+ end
107
+
61
108
  end
62
109
 
110
+
63
111
  class TSlot
64
112
  # the code in this class is based on code by Nathan Zadoks
65
113
  # taken from https://github.com/nathan7/scadlib
@@ -1,4 +1,4 @@
1
1
  module CrystalScad
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
4
4
 
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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joachim Glauche