crystalscad 0.2.1 → 0.2.2
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.
- data/lib/crystalscad/Hardware.rb +115 -4
- data/lib/crystalscad/version.rb +1 -1
- metadata +3 -3
data/lib/crystalscad/Hardware.rb
CHANGED
@@ -35,14 +35,24 @@ module CrystalScad::Hardware
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# currently only din912
|
38
|
-
def bolt_912
|
38
|
+
def bolt_912(addtional_size=0.2)
|
39
|
+
|
40
|
+
|
39
41
|
chart_din912 = {3 => {head_dia:5.5,head_length:3,thread_length:18},
|
40
42
|
4 => {head_dia:7.0,head_length:4,thread_length:20},
|
41
|
-
5 => {head_dia:8.5,head_length:5,thread_length:22}
|
43
|
+
5 => {head_dia:8.5,head_length:5,thread_length:22},
|
44
|
+
8 => {head_dia:13,head_length:8,thread_length:28}
|
42
45
|
}
|
43
46
|
|
44
|
-
res = cylinder(d:chart_din912[@size][:head_dia],h:chart_din912[@size][:head_length]).translate(z:-chart_din912[@size][:head_length])
|
45
|
-
|
47
|
+
res = cylinder(d:chart_din912[@size][:head_dia],h:chart_din912[@size][:head_length]).translate(z:-chart_din912[@size][:head_length]).color("Gainsboro")
|
48
|
+
|
49
|
+
thread_length=chart_din912[@size][:thread_length]
|
50
|
+
if @length.to_i <= thread_length
|
51
|
+
res+= cylinder(d:@size+addtional_size, h:@length).color("DarkGray")
|
52
|
+
else
|
53
|
+
res+= cylinder(d:@size+addtional_size, h:@length-thread_length).color("Gainsboro")
|
54
|
+
res+= cylinder(d:@size+addtional_size, h:thread_length).translate(z:@length-thread_length).color("DarkGray")
|
55
|
+
end
|
46
56
|
res
|
47
57
|
end
|
48
58
|
|
@@ -50,6 +60,107 @@ module CrystalScad::Hardware
|
|
50
60
|
|
51
61
|
end
|
52
62
|
|
63
|
+
class TSlot
|
64
|
+
# the code in this class is based on code by Nathan Zadoks
|
65
|
+
# taken from https://github.com/nathan7/scadlib
|
66
|
+
# Ported to CrystalScad by Joachim Glauche
|
67
|
+
# License: GPLv3
|
68
|
+
attr_accessor :args
|
69
|
+
def initialize(args={})
|
70
|
+
@args = args
|
71
|
+
|
72
|
+
@args[:size] ||= 20
|
73
|
+
@args[:length] ||= 100
|
74
|
+
@args[:configuration] ||= 1
|
75
|
+
@args[:gap] ||= 8.13
|
76
|
+
@args[:thickness] ||= 2.55
|
77
|
+
end
|
78
|
+
|
79
|
+
def output(length=nil)
|
80
|
+
if length != nil
|
81
|
+
@args[:length] = length
|
82
|
+
end
|
83
|
+
@@bom.add(bom_string,1) unless @@bom == nil
|
84
|
+
|
85
|
+
return TransformedObject.new(single_profile.output) if @args[:configuration] == 1
|
86
|
+
return TransformedObject.new(multi_profile.output)
|
87
|
+
end
|
88
|
+
|
89
|
+
def bom_string
|
90
|
+
"T-Slot #{@args[:size]}x#{@args[:size]*@args[:configuration]}, length #{@args[:length]}mm"
|
91
|
+
end
|
92
|
+
|
93
|
+
def single_profile
|
94
|
+
start=@args[:thickness].to_f/Math.sqrt(2);
|
95
|
+
|
96
|
+
gap = @args[:gap]
|
97
|
+
thickness = @args[:thickness]
|
98
|
+
size= @args[:size]
|
99
|
+
profile = square(size:gap+thickness,center:true);
|
100
|
+
(0..3).each{|d|
|
101
|
+
profile+=polygon(points:[[0,0],[0,start],[size/2-thickness-start,size/2-thickness],[gap/2,size/2-thickness],[gap/2,size/2],[size/2,size/2],[size/2,gap/2],[size/2-thickness,gap/2],[size/2-thickness,size/2-thickness-start],[start,0]]).rotate(z:d*90)
|
102
|
+
}
|
103
|
+
profile-=circle(r:gap/2,center:true);
|
104
|
+
profile=profile.translate(x:size/2,y:size/2);
|
105
|
+
|
106
|
+
return profile.linear_extrude(height:@args[:length])
|
107
|
+
end
|
108
|
+
|
109
|
+
def multi_profile
|
110
|
+
res = single_profile
|
111
|
+
(@args[:configuration]-1).times do |c| c=c+1
|
112
|
+
res+= single_profile.translate(y:c*@args[:size])
|
113
|
+
end
|
114
|
+
return res
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
class TSlotMachining < TSlot
|
120
|
+
|
121
|
+
def initialize(args={})
|
122
|
+
super(args)
|
123
|
+
@args[:holes] ||= "front,back" # nil, front, back
|
124
|
+
@args[:bolt_size] ||= 8
|
125
|
+
@args[:bolt_length] ||= 25
|
126
|
+
end
|
127
|
+
|
128
|
+
alias tslot_output output
|
129
|
+
|
130
|
+
def output(length)
|
131
|
+
tslot_output(length)-bolts
|
132
|
+
end
|
133
|
+
|
134
|
+
def show
|
135
|
+
output+bolts
|
136
|
+
end
|
137
|
+
|
138
|
+
def bolts
|
139
|
+
bolt = ScadObject.new
|
140
|
+
return bolt if @args[:holes] == nil
|
141
|
+
|
142
|
+
if @args[:holes].include?("front")
|
143
|
+
@args[:configuration].times do |c|
|
144
|
+
bolt+=Bolt.new(@args[:bolt_size],@args[:bolt_length]).output.rotate(y:90).translate(y:@args[:size]/2+c*@args[:size],z:@args[:size]/2)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
if @args[:holes].include?("back")
|
149
|
+
@args[:configuration].times do |c|
|
150
|
+
bolt+=Bolt.new(@args[:bolt_size],@args[:bolt_length]).output.rotate(y:90).translate(y:@args[:size]/2+c*@args[:size],z:@args[:length]-@args[:size]/2)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
bolt
|
155
|
+
end
|
156
|
+
|
157
|
+
def bom_string
|
158
|
+
str = "T-Slot #{@args[:size]}x#{@args[:size]*@args[:configuration]}, length #{@args[:length]}mm"
|
159
|
+
if @args[:holes] != nil
|
160
|
+
str << " with holes for M#{@args[:bolt_size]} on "+ @args[:holes].split(",").join(' and ')
|
161
|
+
end
|
162
|
+
end
|
53
163
|
|
164
|
+
end
|
54
165
|
|
55
166
|
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: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joachim Glauche
|