jenncad 1.0.0.pre.alpha20 → 1.0.0.pre.alpha21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b40abab4dd5266ab776011e3f74da94297c9dfb0970323c5b9b07dcd6b61e8b
4
- data.tar.gz: be32b5395b42f0d77d21ab0e6e5494a07d0b0716b5fc995b2838824197439c3c
3
+ metadata.gz: bf38a53bfb5d20ab5af97d24c948792ae3e5d577d63806f4a9d7008b5429f507
4
+ data.tar.gz: aae023c68738b1aee605fff567b3d0792f98753252858e1ee2569a18dd470daf
5
5
  SHA512:
6
- metadata.gz: e38fafc310e30794502cec692ae8882a8335c24c332e64c13aa242bf9686d5905eef785758bc6862718e8ef8e2255d0fcf6df542dea63062b131a35fe0935adf
7
- data.tar.gz: 170b50b86a8207e2875fd84943b1af9bad9a528054e947417f1c324578c50d897527d66115aa47b23307d696f205f8cd226268496f50d0ed75b40122b07e9a9e
6
+ metadata.gz: fe8765bc981516be5fe1e94212e946a32d14baf295e0995be9820589dbe31b1be430a1792c1c8bd57ceaeab132ae495668ba8852fa7dbd16676b3345d3c4c8e8
7
+ data.tar.gz: 5667ae97532fa9094125d65603f8542a2cef77621c082ff2c097eebc3865ae5ca683ac16cc5cc9b2a3a09042ca6bd678cadd351f0fa468698e94fc56cf3bedfc
@@ -46,6 +46,7 @@ module JennCad
46
46
 
47
47
  class Build < Run
48
48
  option :binary, type: :boolean, default: false, desc: "run through admesh to create a binary stl"
49
+ option :only_print, type: :boolean, default: true, desc: "If a part has a print orientation set, only build that orientation as STL"
49
50
 
50
51
  def build(options)
51
52
  if options[:binary]
@@ -55,7 +56,13 @@ module JennCad
55
56
  end
56
57
  end
57
58
 
58
- Dir.glob("output/**/*.scad").each do |file|
59
+ files = Dir.glob("output/**/*.scad")
60
+ if options[:only_print]
61
+ # Remove non _print.scad files from the list of files to build if we have a print orientation (and the only_print flag set)
62
+ files -= Dir.glob("output/**/*_print.scad").map{|x| x.gsub("_print.scad",".scad")}
63
+ end
64
+
65
+ files.each do |file|
59
66
  stl = file.gsub(".scad",".stl")
60
67
  build_stl(file, stl)
61
68
  convert_to_binary(stl) if options[:binary] && admesh_installed
@@ -7,9 +7,6 @@ require "jenncad/features/stl_import"
7
7
  require "jenncad/features/path"
8
8
  require "jenncad/features/multiples_of"
9
9
 
10
-
11
-
12
-
13
10
  module JennCad
14
11
  include Features
15
12
  end
@@ -1,5 +1,7 @@
1
1
  module JennCad::Primitives
2
2
  class Circle < Primitive
3
+ include CircleIsh
4
+
3
5
  attr_accessor :d, :r, :fn
4
6
  def initialize(args)
5
7
  if args.kind_of?(Array) && args[0].kind_of?(Hash)
@@ -38,21 +40,6 @@ module JennCad::Primitives
38
40
  set_anchors_2d
39
41
  end
40
42
 
41
- def set_anchors_2d
42
- @anchors = {} # reset anchors
43
- if @opts[:d]
44
- rad = @opts[:d] / 2.0
45
- else
46
- rad = @opts[:r]
47
- end
48
-
49
- # Similar to cube
50
- set_anchor :left, x: -rad
51
- set_anchor :right, x: rad
52
- set_anchor :top, y: rad
53
- set_anchor :bottom, y: -rad
54
- end
55
-
56
43
  def openscad_params
57
44
  res = {}
58
45
  [:d, :fn].each do |n|
@@ -61,49 +48,6 @@ module JennCad::Primitives
61
48
  res
62
49
  end
63
50
 
64
- def handle_fn
65
- case @opts[:fn]
66
- when nil, 0
67
- $fn = auto_dn!
68
- else
69
- @fn = @opts[:fn]
70
- end
71
- end
72
-
73
- def auto_dn!
74
- case @d
75
- when (16..)
76
- @fn = (@d*4).ceil
77
- else
78
- @fn = 64
79
- end
80
- end
81
-
82
- def handle_radius_diameter
83
- case @opts[:d]
84
- when 0, nil
85
- @r = @opts[:r].to_d + @opts[:margins][:r].to_d
86
- @d = @r * 2.0
87
- else
88
- @d = @opts[:d].to_d + @opts[:margins][:d].to_d
89
- @r = @d / 2.0
90
- end
91
-
92
- case @opts[:d1]
93
- when 0, nil
94
- else
95
- @d1 = @opts[:d1].to_d + @opts[:margins][:d].to_d
96
- @d2 = @opts[:d2].to_d + @opts[:margins][:d].to_d
97
- end
98
-
99
- case @opts[:r1]
100
- when 0, nil
101
- else
102
- @d1 = 2 * @opts[:r1].to_d + @opts[:margins][:d].to_d
103
- @d2 = 2 * @opts[:r2].to_d + @opts[:margins][:d].to_d
104
- end
105
- end
106
-
107
51
 
108
52
  end
109
53
  end
@@ -4,6 +4,10 @@ module JennCad::Primitives
4
4
  def initialize(part, args={})
5
5
  @transformations = []
6
6
  @parts = [part]
7
+ if args.kind_of? Numeric
8
+ args = {h: args}
9
+ end
10
+
7
11
  @z = args[:h] || args[:height] || args[:z]
8
12
  @center_bool = args[:center]
9
13
  @convexity = args[:convexity]
@@ -1,5 +1,6 @@
1
1
  module JennCad::Primitives
2
2
  class Slot < Primitive
3
+ include CircleIsh
3
4
  attr_accessor :d, :r, :h, :fn, :len_x, :len_y
4
5
 
5
6
  def initialize(args)
@@ -28,7 +29,11 @@ module JennCad::Primitives
28
29
  x: 0,
29
30
  y: 0,
30
31
  z: nil,
32
+ d1: nil,
33
+ d2: nil,
34
+ mode: :auto,
31
35
  cz: false,
36
+ az: false,
32
37
  margins: {
33
38
  r: 0,
34
39
  d: 0,
@@ -61,8 +66,6 @@ module JennCad::Primitives
61
66
  @len_y = ty - @d
62
67
  end
63
68
 
64
- # TODO: this needs anchors like cube
65
- # TODO: color on this needs to apply to hull, not on the cylinders.
66
69
  set_anchors
67
70
  end
68
71
 
@@ -76,11 +79,7 @@ module JennCad::Primitives
76
79
 
77
80
  def set_anchors
78
81
  @anchors = {} # reset anchors
79
- if @opts[:d]
80
- rad = @opts[:d] / 2.0
81
- else
82
- rad = @opts[:r]
83
- end
82
+ rad = radius
84
83
 
85
84
  if @x > 0
86
85
  set_anchor :left, x: - rad
@@ -120,9 +119,39 @@ module JennCad::Primitives
120
119
  end
121
120
  end
122
121
 
122
+ def get_mode
123
+ if @opts[:d1] && @opts[:d2]
124
+ case @opts[:mode]
125
+ when nil, :auto
126
+ :dia1
127
+ when :cyl
128
+ :cyl
129
+ else
130
+ :dia1
131
+ end
132
+ else
133
+ :default
134
+ end
135
+ end
136
+
123
137
  def to_openscad
124
- c1 = cylinder(@opts)
125
- c2 = cylinder(@opts)
138
+ mode = get_mode
139
+
140
+ opts = @opts.clone
141
+ opts.delete(:color)
142
+
143
+ case mode
144
+ when :default
145
+ c1 = ci(opts)
146
+ c2 = ci(opts)
147
+ when :dia1 # new default mode; d1 start dia, d2 end dia
148
+ c1 = ci(opts.merge(d: @opts[:d1]))
149
+ c2 = ci(opts.merge(d: @opts[:d2]))
150
+ when :cyl # old mode; use cylinders
151
+ c1 = cy(opts)
152
+ c2 = cy(opts)
153
+ end
154
+
126
155
  if @len_x
127
156
  c2.move(x:@len_x)
128
157
  end
@@ -130,6 +159,14 @@ module JennCad::Primitives
130
159
  c2.move(y:@len_y)
131
160
  end
132
161
  res = c1 & c2
162
+ if mode != :cyl && @z.to_d > 0
163
+ res = res.e(@z)
164
+ elsif @opts[:az] == true
165
+ # TODO: this needs testing, may not work
166
+ res = res.auto_extrude
167
+ end
168
+ res.inherit_color(self)
169
+
133
170
  if @a != 0.0
134
171
  res = res.rotate(z:@a)
135
172
  end
@@ -42,6 +42,8 @@ module JennCad::Primitives
42
42
 
43
43
  def set_anchors_2d
44
44
  @anchors = {} # this resets anchors
45
+ @corners = [:top_right, :top_left, :bottom_right, :bottom_left]
46
+ @sides = [:left, :right, :top, :bottom]
45
47
 
46
48
  if @opts[:center] || @opts[:center_x]
47
49
  left = -@opts[:x] / 2.0
@@ -17,10 +17,18 @@ module JennCad
17
17
  run_exports
18
18
  end
19
19
 
20
+ def run_export!(part, file)
21
+ part.openscad([output_dir,file].join("/"))
22
+ end
23
+
20
24
  def run_exports
21
25
  outputs.each do |name|
22
26
  part = self.send(name)
23
- part.openscad([output_dir,"#{name}.scad"].join("/"))
27
+ run_export!(part, "#{name}.scad")
28
+ if part.respond_to? :print
29
+ part = self.send(name).print
30
+ run_export!(part, "#{name}_print.scad")
31
+ end
24
32
  end
25
33
  end
26
34
 
@@ -0,0 +1,65 @@
1
+ module CircleIsh
2
+
3
+ def radius
4
+ if @opts[:d]
5
+ @opts[:d].to_d / 2.0
6
+ else
7
+ @opts[:r].to_d
8
+ end
9
+ end
10
+
11
+ def set_anchors_2d
12
+ @anchors = {} # reset anchors
13
+ rad = radius
14
+ # Similar to cube
15
+ set_anchor :left, x: -rad
16
+ set_anchor :right, x: rad
17
+ set_anchor :top, y: rad
18
+ set_anchor :bottom, y: -rad
19
+ end
20
+
21
+ def handle_fn
22
+ case @opts[:fn]
23
+ when nil, 0
24
+ $fn = auto_dn!
25
+ else
26
+ @fn = @opts[:fn]
27
+ end
28
+ end
29
+
30
+ def auto_dn!
31
+ case @d
32
+ when (16..)
33
+ @fn = (@d*4).ceil
34
+ else
35
+ @fn = 64
36
+ end
37
+ end
38
+
39
+ def handle_radius_diameter
40
+ case @opts[:d]
41
+ when 0, nil
42
+ @r = @opts[:r].to_d + @opts[:margins][:r].to_d
43
+ @d = @r * 2.0
44
+ else
45
+ @d = @opts[:d].to_d + @opts[:margins][:d].to_d
46
+ @r = @d / 2.0
47
+ end
48
+
49
+ case @opts[:d1]
50
+ when 0, nil
51
+ else
52
+ @d1 = @opts[:d1].to_d + @opts[:margins][:d].to_d
53
+ @d2 = @opts[:d2].to_d + @opts[:margins][:d].to_d
54
+ end
55
+
56
+ case @opts[:r1]
57
+ when 0, nil
58
+ else
59
+ @d1 = 2 * @opts[:r1].to_d + @opts[:margins][:d].to_d
60
+ @d2 = 2 * @opts[:r2].to_d + @opts[:margins][:d].to_d
61
+ end
62
+ end
63
+
64
+
65
+ end
@@ -0,0 +1,3 @@
1
+ module CubeIsh
2
+ # TBD
3
+ end
@@ -0,0 +1,3 @@
1
+ require "jenncad/shared/circle_ish"
2
+ require "jenncad/shared/cube_ish"
3
+
@@ -2,6 +2,7 @@ module JennCad
2
2
  def circle(args)
3
3
  Circle.new(args).set_parent(self)
4
4
  end
5
+ alias :ci :circle
5
6
 
6
7
  def square(args)
7
8
  Square.new(args).set_parent(self)
@@ -22,14 +23,17 @@ module JennCad
22
23
  def polygon(args)
23
24
  Polygon.new(args).set_parent(self)
24
25
  end
26
+ alias :pg :polygon
25
27
 
26
28
  def polyhedron(args)
27
29
  Polyhedron.new(args).set_parent(self)
28
30
  end
31
+ alias :phd :polyhedron
29
32
 
30
33
  def slot(*args)
31
34
  Slot.new(args).set_parent(self)
32
35
  end
36
+ alias :sl :slot
33
37
 
34
38
  def cube(*args)
35
39
  Cube.new(args).set_parent(self)
@@ -55,14 +59,19 @@ module JennCad
55
59
  def extrude(args={})
56
60
  LinearExtrude.new(self, args)
57
61
  end
62
+ alias :e :extrude
63
+ alias :ex :extrude
58
64
 
59
65
  def rotate_extrude(args={})
60
66
  RotateExtrude.new(self, args)
61
67
  end
68
+ alias :re :rotate_extrude
69
+ alias :rex :rotate_extrude
62
70
 
63
71
  def to_2d(args={})
64
72
  Projection.new(self, args)
65
73
  end
74
+ alias :as_2d :to_2d
66
75
 
67
76
  def union(*args)
68
77
  UnionObject.new(*args)
@@ -1,3 +1,3 @@
1
1
  module JennCad
2
- VERSION = "1.0.0-alpha20"
2
+ VERSION = "1.0.0-alpha21"
3
3
  end
data/lib/jenncad.rb CHANGED
@@ -23,6 +23,7 @@ require "jenncad/part"
23
23
  require "jenncad/project"
24
24
  require "jenncad/commands"
25
25
 
26
+ require "jenncad/shared"
26
27
  require "jenncad/features"
27
28
  require "jenncad/primitives"
28
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenncad
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha20
4
+ version: 1.0.0.pre.alpha21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jennifer Glauche
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-18 00:00:00.000000000 Z
11
+ date: 2022-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: geo3d
@@ -150,6 +150,9 @@ files:
150
150
  - lib/jenncad/profile_loader.rb
151
151
  - lib/jenncad/project.rb
152
152
  - lib/jenncad/register.rb
153
+ - lib/jenncad/shared.rb
154
+ - lib/jenncad/shared/circle_ish.rb
155
+ - lib/jenncad/shared/cube_ish.rb
153
156
  - lib/jenncad/shortcuts.rb
154
157
  - lib/jenncad/thing.rb
155
158
  - lib/jenncad/transformation/color.rb