jenncad 1.0.0.pre.alpha13 → 1.0.0.pre.alpha16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4383fe5f1fe2d17d69eccd66bd28db4678281fd542bd13434064d4051044727
4
- data.tar.gz: 0eb4435e845c47ec9b75d113c04b7beae9ce762a2dfa57b598412a243ded0163
3
+ metadata.gz: ef20af7d3fc9a11140dacb23030a9ba671a80cbd39491caed609d6755f8bc85c
4
+ data.tar.gz: 4e515e6fbedcfa16b315b8ea02cafe8a6d41207fbdd9aece996165edee7f9214
5
5
  SHA512:
6
- metadata.gz: 35001c199911e59f66a2ef3ce3b8c6193e5654ebc5463f52add3cb11a5aa3c1684c51dbaad7a3edaf4c0042cf2b2d35410ea01bfdce45e5adc72a96f30ec002b
7
- data.tar.gz: 163e8e50aa1dd6ba930fd41e93075aca9f8bed93c6650f3a9984fbc86ddb34f0ae4a499d7fc981a38dfe9bdb1f56a0667a4cec018a530b701f4707141d79233c
6
+ metadata.gz: 17111c38b461ecdf683d2813284279b4bced3296d97dc9aebdf17797955affea2ad275bd21f5935680c09a8f08234ebac9c5bbb67ce197fdfe6c3e0a6489d0cf
7
+ data.tar.gz: 9022e918187212aa81f4f02b28c9a9ac11d7b8d36c6afb36835346298309ec2204430478032c406177315ee9807d0513bb52f0d8581dfec9c3df13e91b42f5f8
@@ -118,15 +118,15 @@ module JennCad
118
118
  File.open(filename, "w") do |f|
119
119
  f.puts "class #{classname} < Part"
120
120
  f.puts " def initialize(opts={})"
121
- f.puts " @opts = {"
122
- f.puts " x: 10,"
123
- f.puts " y: 10,"
124
- f.puts " z: 5,"
125
- f.puts " }.merge(opts)"
121
+ f.puts " @x = 10"
122
+ f.puts " @y = 10"
123
+ f.puts " @z = 5"
126
124
  f.puts " end"
127
125
  f.puts ""
128
126
  f.puts " def part"
129
- f.puts " cube(@opts)"
127
+ f.puts " base = cube(x: @x, y: @y, z: @z)"
128
+ f.puts " res = base.fix"
129
+ f.puts " res"
130
130
  f.puts " end"
131
131
  f.puts "end"
132
132
  end
@@ -16,6 +16,18 @@ module JennCad
16
16
  )
17
17
  end
18
18
 
19
+ # By default, jenncad will add coordinates of subsequent moves in the output
20
+ # i.e.
21
+ # .move(x: 10, y: 20).move(x: 10) would result depending on the value of this option:
22
+ #
23
+ # true = translate([10,20, 0])translate([10, 0, 0])
24
+ # false = translate([20, 20, 0])
25
+ #
26
+ # defaults to false
27
+ def chain_moves
28
+ false
29
+ end
30
+
19
31
  def colors
20
32
  case @colors
21
33
  when nil, []
@@ -45,11 +45,11 @@ module JennCad::Exporters
45
45
  def handle_command(i=1)
46
46
  case @children.size
47
47
  when 0
48
- "#{@modifier}#{@command}(#{handle_args});"
48
+ "#{@modifier}#{@command}(#{handle_args(@args)});"
49
49
  when 1
50
- "#{@modifier}#{@command}(#{handle_args})#{@children.first.handle_command(i+1)}"
50
+ "#{@modifier}#{@command}(#{handle_args(@args)})#{@children.first.handle_command(i+1)}"
51
51
  when (1..)
52
- res = "#{@modifier}#{@command}(#{handle_args}){"
52
+ res = "#{@modifier}#{@command}(#{handle_args(@args)}){"
53
53
  res += nl
54
54
  inner = @children.map do |c|
55
55
  next if c == nil
@@ -68,17 +68,19 @@ module JennCad::Exporters
68
68
  }.join(nl)
69
69
  end
70
70
 
71
- def handle_args
72
- case @args
71
+ def handle_args(args)
72
+ case args
73
73
  when String, Symbol
74
- return "\"#{@args}\""
74
+ return "\"#{args}\""
75
75
  when Array
76
- return @args.map do |l|
76
+ return args.map do |l|
77
77
  if l == nil
78
78
  0
79
79
  elsif l.kind_of? Array
80
80
  l # skipping check of 2-dmin Arrays for now (used in multmatrix)
81
- elsif l.to_i == l.to_f
81
+ elsif l == 0
82
+ 0
83
+ elsif l == l.to_i
82
84
  l.to_i
83
85
  else
84
86
  l.to_f
@@ -86,15 +88,19 @@ module JennCad::Exporters
86
88
  end
87
89
  when Hash
88
90
  res = []
89
- @args.each do |k,v|
91
+ args.each do |k,v|
90
92
  if k.to_s == "fn"
91
93
  k = "$fn"
92
94
  end
93
95
  if v == nil
94
96
  next
95
97
  end
96
- if !v.kind_of?(Array) && !v.kind_of?(TrueClass) && !v.kind_of?(FalseClass) && v == v.to_i
98
+ if v.kind_of?(Array)
99
+ v = handle_args(v)
100
+ elsif !v.kind_of?(TrueClass) && !v.kind_of?(FalseClass) && v == v.to_i
97
101
  v = v.to_i
102
+ elsif v.kind_of? BigDecimal
103
+ v = v.to_f
98
104
  end
99
105
  if v.kind_of? String
100
106
  q = "\""
@@ -172,6 +178,8 @@ module JennCad::Exporters
172
178
  new_obj(part, :projection, collect_params(part), parse(part.parts))
173
179
  when JennCad::Primitives::Polygon
174
180
  new_obj(part, :polygon, collect_params(part))
181
+ when JennCad::Primitives::Polyhedron
182
+ new_obj(part, :polyhedron, collect_params(part))
175
183
  when JennCad::StlImport
176
184
  new_obj(part, :import, collect_params(part))
177
185
  when JennCad::Part
@@ -206,7 +214,7 @@ module JennCad::Exporters
206
214
  return part.openscad_params
207
215
  end
208
216
  res = {}
209
- [:d, :h, :d1, :d2, :size, :fn, :points, :file].each do |var|
217
+ [:d, :h, :d1, :d2, :size, :fn, :points, :paths, :faces, :convexity, :file].each do |var|
210
218
  if part.respond_to? var
211
219
  res[var] = part.send var
212
220
  end
@@ -64,7 +64,7 @@ module JennCad::Extras
64
64
  if show
65
65
  res.color("Gainsboro")
66
66
  thread_length=Data[@size][:thread_length]
67
- if total_length.to_f <= thread_length
67
+ if total_length.to_d <= thread_length
68
68
  res+= cylinder(d:@size+addtional_diameter, h:total_length).color("DarkGray")
69
69
  else
70
70
  res+= cylinder(d:@size+addtional_diameter, h:total_length-thread_length)
@@ -48,7 +48,7 @@ module JennCad::Extras
48
48
  14=> {head_side_to_side:22,head_length:9},
49
49
  16=> {head_side_to_side:24,head_length:10},
50
50
  }
51
- head_dia = chart[@size][:head_side_to_side].to_f + head_margin.to_f
51
+ head_dia = chart[@size][:head_side_to_side].to_d + head_margin.to_d
52
52
  res = cylinder(d:(head_dia/Math.sqrt(3))*2,fn:6,h:chart[@size][:head_length]).move(z:-chart[@size][:head_length])
53
53
  total_length = @length + additional_length
54
54
  res+= cylinder(d:@size+addtional_diameter, h:total_length)
@@ -36,7 +36,7 @@ module JennCad::Extras
36
36
 
37
37
  # ISO 7380
38
38
  def bolt_7380(additional_length=0, addtional_diameter=0, head_margin=0)
39
- if head_margin.to_f != 0
39
+ if head_margin.to_d != 0
40
40
  puts "[warning] :head_margin is not implemented for 7380 bolts"
41
41
  end
42
42
  chart_iso7380 = {
@@ -6,6 +6,7 @@ module JennCad::Features
6
6
  super({})
7
7
  @name = name.gsub(".","_")
8
8
  @parts = [part]
9
+ @zref = part
9
10
  end
10
11
 
11
12
  def z
@@ -1,6 +1,8 @@
1
1
  module JennCad::Features
2
2
  class Climb < Feature
3
3
  def initialize(opts, block)
4
+ $log.warn "DEPRECATED feature: climb. Please use x.of (multiples_of example)"
5
+
4
6
  @opts = {
5
7
  offset: :auto,
6
8
  step: nil,
@@ -31,7 +33,7 @@ module JennCad::Features
31
33
  steps = @opts[:steps]
32
34
  (z / steps).floor
33
35
  else
34
- step.to_f
36
+ step.to_d
35
37
  end
36
38
  end
37
39
 
@@ -62,8 +64,8 @@ module JennCad::Features
62
64
 
63
65
  offset = get_offset(ref_z)
64
66
 
65
- lo = (ref_z-offset*2).to_f % step.to_f
66
- unless lo.to_f == 0.0
67
+ lo = (ref_z-offset*2).to_d % step.to_d
68
+ unless lo.to_d == 0.0
67
69
  puts "[Warning]: climb has leftover offset #{lo}"
68
70
  end
69
71
 
@@ -16,12 +16,12 @@ module JennCad::Features
16
16
 
17
17
  def prepare_cut(l, r, &block)
18
18
  part = block.call
19
- if part.z.to_f > 0.0
19
+ if part.z.to_d > 0.0
20
20
  part.opts[:margins][:z] = 0.2
21
21
  if l == 0.0
22
22
  part.mz(r+0.1)
23
23
  else
24
- part.mz(l+part.z.to_f-0.2)
24
+ part.mz(l+part.z.to_d-0.2)
25
25
  end
26
26
  else
27
27
  part.opts[:margins][:z] = 0.2
@@ -0,0 +1,14 @@
1
+ class Integer
2
+ def of(part=nil, anchor=:top_face)
3
+ return nil if part.nil?
4
+ num = self - 1
5
+
6
+ res = part.fix
7
+ num.times do
8
+ res += part.movea(anchor)
9
+ end
10
+ res
11
+ end
12
+ end
13
+
14
+
@@ -1,7 +1,7 @@
1
1
  module JennCad
2
2
  class RoundCorner
3
3
  attr_accessor :start_point, :end_point, :input_a, :output_a, :a, :l, :od, :id, :thing, :angle, :current_angle, :direction, :from, :ccw
4
- def initialize(args, &thing)
4
+ def initialize(args)
5
5
  @start_point = args[:start_point]
6
6
  @end_point = args[:end_point]
7
7
  @a = args[:a]
@@ -11,7 +11,13 @@ module JennCad
11
11
  @id = args[:id]
12
12
  @input_a = args[:input_a] || 0
13
13
  @output_a = args[:output_a] || 0
14
- @thing = thing
14
+ thing = Marshal.load(args[:thing])
15
+
16
+ @thing_dia = thing.d || thing.y
17
+ unless @thing_dia
18
+ $log.error "ERROR: cannot find diameter or y of thing #{thing.inspect}"
19
+ return
20
+ end
15
21
  @angle = args[:angle]
16
22
  @current_angle = args[:current_angle]
17
23
  @direction = args[:direction]
@@ -57,11 +63,7 @@ module JennCad
57
63
  end
58
64
 
59
65
  def positions
60
- td = thing.yield.d || thing.yield.y
61
- unless td
62
- puts "ERROR: cannot find diameter or y of thing #{thing.yield.inspect}"
63
- return
64
- end
66
+ td = @thing_dia
65
67
  l = td + @id
66
68
  l2 = td / 2.0 + @id / 2.0
67
69
  r = 0
@@ -101,7 +103,7 @@ module JennCad
101
103
  end
102
104
 
103
105
  def part
104
- d = thing.yield.d
106
+ d = @thing_dia
105
107
  len = d * 2 + @id
106
108
  x = Math::sin((@a/180.0)*Math::PI)*len
107
109
  y = Math::cos((@a/180.0)*Math::PI)*len
@@ -134,15 +136,15 @@ module JennCad
134
136
  end
135
137
 
136
138
  class Line
137
- attr_accessor :start_point, :end_point, :l, :thing, :angle, :current_angle, :direction
138
- def initialize(args, &thing)
139
+ attr_accessor :start_point, :end_point, :l, :angle, :current_angle, :direction
140
+ def initialize(args)
139
141
  @start_point = args[:start_point]
140
142
  @end_point = args[:end_point]
141
143
  @angle = args[:angle]
142
144
  @current_angle = args[:current_angle]
143
145
  @direction = args[:direction]
144
146
  @l = args[:l]
145
- @thing = thing
147
+ @thing = args[:thing]
146
148
  end
147
149
 
148
150
  def sp_margin(margin)
@@ -181,8 +183,8 @@ module JennCad
181
183
 
182
184
  def part
183
185
  hull(
184
- @thing.yield.move(x: @start_point[:x], y: @start_point[:y]),
185
- @thing.yield.move(x: @end_point[:x], y: @end_point[:y])
186
+ Marshal.load(@thing).move(x: @start_point[:x], y: @start_point[:y]),
187
+ Marshal.load(@thing).move(x: @end_point[:x], y: @end_point[:y])
186
188
  )
187
189
  end
188
190
  end
@@ -191,7 +193,7 @@ module JennCad
191
193
 
192
194
  attr_accessor :elements, :lpos, :thing, :angle, :current_angle, :direction
193
195
  def initialize(args)
194
- @thing = args[:part] #// cylinder(d: @d, z: @z)
196
+ @thing = store_thing_from(args[:part])
195
197
  @part = new_thing
196
198
  @angle = args[:a] || 0
197
199
  @current_angle = args[:a] || 0
@@ -207,10 +209,14 @@ module JennCad
207
209
  super(args)
208
210
  end
209
211
 
210
- def new_thing
211
- r = @thing.clone
212
+ def store_thing_from(thing)
213
+ r = Marshal.load(Marshal.dump(thing)) # make sure we don't edit the object in memory
212
214
  r.transformations = []
213
- r
215
+ Marshal.dump(r)
216
+ end
217
+
218
+ def new_thing
219
+ Marshal.load(@thing)
214
220
  end
215
221
 
216
222
  def corner(args)
@@ -232,8 +238,9 @@ module JennCad
232
238
  from: args[:from],
233
239
  to: args[:to],
234
240
  a: args[:a],
235
- direction: @direction
236
- ){ new_thing }
241
+ direction: @direction,
242
+ thing: thing,
243
+ )
237
244
 
238
245
  _, ox, oy, x, y = rc.positions
239
246
  @lpos[:x] += x + ox
@@ -292,7 +299,7 @@ module JennCad
292
299
  return
293
300
  end
294
301
 
295
- @steps << Line.new(start_point: { x: @lpos[:x], y: @lpos[:y] }, end_point: { x: @lpos[:x] + x, y: @lpos[:y] + y }, angle: @angle, current_angle: @current_angle, direction: @direction, l: l){ new_thing }
302
+ @steps << Line.new(start_point: { x: @lpos[:x], y: @lpos[:y] }, end_point: { x: @lpos[:x] + x, y: @lpos[:y] + y }, angle: @angle, current_angle: @current_angle, direction: @direction, l: l, thing: thing)
296
303
 
297
304
  add_lpos({x: x, y: y})
298
305
  end
@@ -5,6 +5,8 @@ require "jenncad/features/openscad_include"
5
5
  require "jenncad/features/climb"
6
6
  require "jenncad/features/stl_import"
7
7
  require "jenncad/features/path"
8
+ require "jenncad/features/multiples_of"
9
+
8
10
 
9
11
 
10
12
 
data/lib/jenncad/part.rb CHANGED
@@ -1,9 +1,54 @@
1
+ module AutoName
2
+ def initialize(args={})
3
+ unless args.empty?
4
+ @auto_name = "#{self.class}_#{args.map{|key, val| "#{key}_#{val}"}.join('_')}"
5
+ end
6
+ super(args)
7
+ end
8
+ end
9
+
1
10
  module JennCad
2
11
  # Part should be inherited from the user when making parts
3
12
  class Part < Thing
13
+ def self.inherited(subclass)
14
+ subclass.prepend(AutoName) if subclass.superclass == Part
15
+ end
16
+
17
+ # this function both gets and defines hardware
18
+ def hardware(hw_type=nil, args={})
19
+ @_hw ||= {}
20
+ if hw_type == nil
21
+ return @_hw
22
+ end
23
+
24
+ anchors = args[:anchor] || args[:anchors]
25
+ unless anchors.kind_of? Array
26
+ anchors = [anchors]
27
+ end
28
+
29
+ anchors.each do |a|
30
+ @_hw[a] = {
31
+ hw_type: hw_type,
32
+ size: args[:size],
33
+ d: args[:d],
34
+ len: args[:len],
35
+ pos: anchor(a, args[:from]),
36
+ }
37
+ end
38
+ self
39
+ end
40
+ alias :hw :hardware
41
+
42
+ def fix_name_for_openscad(name)
43
+ [":", ",", ".", "[", "]","-", " "].each do |key|
44
+ name.gsub!(key, "_")
45
+ end
46
+ name
47
+ end
4
48
 
5
49
  def to_openscad
6
- a = Aggregation.new(self.class.to_s, self.get_contents)
50
+ name = @name || @auto_name || self.class.to_s
51
+ a = Aggregation.new(fix_name_for_openscad(name), self.get_contents)
7
52
  a.transformations = @transformations
8
53
  if self.has_explicit_color?
9
54
  a.color(self.color)
@@ -12,7 +12,7 @@ class Array
12
12
  else
13
13
  res = part
14
14
  end
15
- res, z = res.mz(z), z + res.z.to_f unless skip_z
15
+ res, z = res.mz(z), z + res.z.to_d unless skip_z
16
16
  res
17
17
  end
18
18
  .union
@@ -7,6 +7,9 @@ module JennCad::Primitives
7
7
  else
8
8
  @parts = parts
9
9
  end
10
+ if parts.first && parts.first.respond_to?(:debug?) && parts.first.debug?
11
+ $log.debug("Creating new #{self.class} for part #{parts}")
12
+ end
10
13
 
11
14
  @parent = @parts.first.parent
12
15
 
@@ -16,9 +19,11 @@ module JennCad::Primitives
16
19
  def add_or_new(part)
17
20
  case @transformations
18
21
  when nil, []
22
+ $log.debug("adding new part to existing boolean object") if part && part.debug?
19
23
  add(part)
20
24
  self
21
25
  else
26
+ $log.debug("add_or_new: creating new boolean object") if part.debug?
22
27
  self.class.new(self, part)
23
28
  end
24
29
  end
@@ -44,25 +49,25 @@ module JennCad::Primitives
44
49
  end
45
50
 
46
51
  def inherit_z
47
- heights = @parts.map{|l| l.calc_z.to_f}.uniq
52
+ heights = @parts.map{|l| l.calc_z.to_d}.uniq
48
53
  if heights.size > 1
49
54
  total_heights = []
50
55
  @parts.each do |p|
51
- total_heights << p.z.to_f + p.calc_z.to_f
56
+ total_heights << p.z.to_d + p.calc_z.to_d
52
57
  end
53
58
  @z = total_heights.max
54
59
  @calc_z = heights.min
55
60
  else
56
- @calc_z = heights.first.to_f
61
+ @calc_z = heights.first.to_d
57
62
  @z = @parts.map(&:z).compact.max
58
63
  end
59
64
  end
60
65
 
61
66
  def inherit_zref
62
67
  return if @parts.first == nil
63
- #return if @parts.first.z.to_f == 0.0
68
+ #return if @parts.first.z.to_d == 0.0
64
69
  get_primitives(@parts[1..-1]).flatten.each do |part|
65
- if part.z.to_f == 0.0
70
+ if part.z.to_d == 0.0
66
71
  part.set_option :zref, @parts.first
67
72
  end
68
73
  end
@@ -82,6 +82,13 @@ module JennCad::Primitives
82
82
  set_anchor :top_right, x: right, y: top
83
83
  set_anchor :bottom_left, x: left, y: bottom
84
84
  set_anchor :bottom_right, x: right, y: bottom
85
+ if @opts[:center_z]
86
+ set_anchor :bottom_face, z: -@z/2.0
87
+ set_anchor :top_face, z: @z/2.0
88
+ else
89
+ set_anchor :bottom_face, z: 0
90
+ set_anchor :top_face, z: @z
91
+ end
85
92
 
86
93
  # we need to re-do the inner ones, if they were defined
87
94
  if @inner_anchor_defs && @inner_anchor_defs.size > 0
@@ -94,6 +101,11 @@ module JennCad::Primitives
94
101
  end
95
102
 
96
103
  def inner_anchors(dist, prefix=:inner_, recreate=false)
104
+ if dist.nil?
105
+ $log.error "Distance of nil passed to inner anchors. Please check the variable name you passed along"
106
+ return self
107
+ end
108
+
97
109
  @inner_anchor_defs ||= []
98
110
  @inner_anchor_defs << { "dist": dist, "prefix": prefix } unless recreate
99
111
 
@@ -1,6 +1,6 @@
1
1
  module JennCad::Primitives
2
2
  class Cylinder < Primitive
3
- attr_accessor :d, :d1, :d2, :r, :fn
3
+ attr_accessor :d, :d1, :d2, :r, :fn, :anchors
4
4
  def initialize(args)
5
5
  if args.kind_of?(Array) && args[0].kind_of?(Hash)
6
6
  args = args.first
@@ -24,6 +24,7 @@ module JennCad::Primitives
24
24
  r2: nil,
25
25
  z: nil,
26
26
  r: 0,
27
+ cz: false,
27
28
  margins: {
28
29
  r: 0,
29
30
  d: 0,
@@ -41,6 +42,35 @@ module JennCad::Primitives
41
42
  handle_radius_diameter
42
43
  handle_fn
43
44
  super(args)
45
+ set_anchors
46
+ end
47
+
48
+ def set_anchors
49
+ @anchors = {} # reset anchors
50
+ if @opts[:d]
51
+ rad = @opts[:d] / 2.0
52
+ else
53
+ rad = @opts[:r]
54
+ end
55
+
56
+ # Similar to cube
57
+ set_anchor :left, x: -rad
58
+ set_anchor :right, x: rad
59
+ set_anchor :top, y: rad
60
+ set_anchor :bottom, y: -rad
61
+
62
+ # TODO: figure out if we also want to have "corners"
63
+ # - possibly move it like a cube
64
+ # - points at 45 ° angles might not be that useful unless you can get the point on the circle at a given angle
65
+ # - inner/outer points could be useful for small $fn values
66
+
67
+ if @opts[:cz]
68
+ set_anchor :bottom_face, z: -@z/2.0
69
+ set_anchor :top_face, z: @z/2.0
70
+ else
71
+ set_anchor :bottom_face, z: 0
72
+ set_anchor :top_face, z: @z
73
+ end
44
74
  end
45
75
 
46
76
  def openscad_params
@@ -60,20 +90,22 @@ module JennCad::Primitives
60
90
  # Centers the cylinder around it's center point by height
61
91
  # This will transform the cylinder around the center point.
62
92
  def cz
93
+ @opts[:cz] = true
63
94
  @transformations << Move.new(z: -@z / 2.0)
95
+ set_anchors
64
96
  self
65
97
  end
66
98
 
67
99
  def handle_fn
68
100
  case @opts[:fn]
69
101
  when nil, 0
70
- $fn = auto_fn!
102
+ $fn = auto_dn!
71
103
  else
72
104
  @fn = @opts[:fn]
73
105
  end
74
106
  end
75
107
 
76
- def auto_fn!
108
+ def auto_dn!
77
109
  case @d
78
110
  when (16..)
79
111
  @fn = (@d*4).ceil
@@ -85,28 +117,36 @@ module JennCad::Primitives
85
117
  def handle_radius_diameter
86
118
  case @opts[:d]
87
119
  when 0, nil
88
- @r = @opts[:r].to_f + @opts[:margins][:r].to_f
120
+ @r = @opts[:r].to_d + @opts[:margins][:r].to_d
89
121
  @d = @r * 2.0
90
122
  else
91
- @d = @opts[:d].to_f + @opts[:margins][:d].to_f
123
+ @d = @opts[:d].to_d + @opts[:margins][:d].to_d
92
124
  @r = @d / 2.0
93
125
  end
94
126
 
95
127
  case @opts[:d1]
96
128
  when 0, nil
97
129
  else
98
- @d1 = @opts[:d1].to_f + @opts[:margins][:d].to_f
99
- @d2 = @opts[:d2].to_f + @opts[:margins][:d].to_f
130
+ @d1 = @opts[:d1].to_d + @opts[:margins][:d].to_d
131
+ @d2 = @opts[:d2].to_d + @opts[:margins][:d].to_d
100
132
  end
101
133
 
102
134
  case @opts[:r1]
103
135
  when 0, nil
104
136
  else
105
- @d1 = 2 * @opts[:r1].to_f + @opts[:margins][:d].to_f
106
- @d2 = 2 * @opts[:r2].to_f + @opts[:margins][:d].to_f
137
+ @d1 = 2 * @opts[:r1].to_d + @opts[:margins][:d].to_d
138
+ @d2 = 2 * @opts[:r2].to_d + @opts[:margins][:d].to_d
107
139
  end
108
140
  end
109
141
 
142
+ def z=(val)
143
+ @z = val
144
+ @h = val
145
+ opts[:h] = val
146
+ opts[:z] = val
147
+ set_anchors
148
+ end
149
+
110
150
  def h
111
151
  z + z_margin
112
152
  end
@@ -4,7 +4,7 @@ module JennCad::Primitives
4
4
  def initialize(part, args={})
5
5
  @transformations = []
6
6
  @parts = [part]
7
- @z = args[:h] || args[:height]
7
+ @z = args[:h] || args[:height] || args[:z]
8
8
  @center_bool = args[:center]
9
9
  @convexity = args[:convexity]
10
10
  @twist = args[:twist]
@@ -1,9 +1,11 @@
1
1
  module JennCad::Primitives
2
2
  class Polygon < Primitive
3
- attr_accessor :points
3
+ attr_accessor :points, :paths
4
4
  def initialize(args)
5
- super
6
5
  @points = args[:points]
6
+ @paths = args[:paths]
7
+ @convexity = args[:convexity] || 10
8
+ super
7
9
  end
8
10
  end
9
11
  end