Class: JennCad::Primitives::LinearExtrude

Inherits:
Thing
  • Object
show all
Defined in:
lib/jenncad/primitives/linear_extrude.rb

Instance Attribute Summary

Attributes inherited from Thing

#anchors, #angle, #calc_h, #calc_x, #calc_y, #calc_z, #csize, #diameter, #fn, #name, #opts, #parent, #parts, #pos, #shape, #sits_on, #transformations, #x, #y

Instance Method Summary collapse

Methods inherited from Thing

#anchor, #at, #auto_color, #auto_color!, #auto_extrude, #calculate_center_rotation, #calculated_h, #children_list, #color, #color_or_fallback, #color_parse, #copy_anchor, #copy_anchors, #cut_to, #dbg, #debug?, #find_calculated_h, #fixate, #flip, #flipc, #get_children, #get_contents, #ghost, #has_explicit_color?, #hide, #hl, #inherit_color, #init, #is_2d?, #is_3d?, #mhx, #mhy, #mhz, #mirror, #mix, #miy, #miz, #modify_values, #modify_values!, #move, #movea, #moveai, #moveh, #movei, #multmatrix, #mx, #my, #mz, #on_top_of, #only, #only_color?, #openscad, #openscad_modifier, #option, #parse_xyz_shortcuts, #radians, #referenced_z, #reset, #reset_last_move, #rotate, #rotate_around, #rx, #ry, #rz, #scale, #set_anchor, #set_anchor_from, #set_auto_color, #set_auto_color_for_children, #set_flag, #set_heights_for_auto_extrude, #set_option, #set_parent, #skew, #to_mod, #top_of, #transform, #unset_flag, #z, #z=, #z_margin

Constructor Details

#initialize(part, args = {}) ⇒ LinearExtrude

Returns a new instance of LinearExtrude.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jenncad/primitives/linear_extrude.rb', line 6

def initialize(part, args={})
  @transformations = []
  @parts = [part]
  if args.kind_of? Numeric
    args = {h: args}
  end
  @z = args[:h] || args[:height] || args[:z]
  @csize = Size.new(z: @z).add(part.csize)

  @center_bool = args[:center]
  @convexity = args[:convexity]
  @twist = args[:twist]
  @slices = args[:slices]
  @fn = args[:fn]
  @opts = {
    center_z: false,
    margins: {
      z: 0,
    }
  }.deep_merge(args)
  set_anchors_z

  @x = part.x
  @y = part.y
end

Instance Method Details

#heightObject



32
33
34
# File 'lib/jenncad/primitives/linear_extrude.rb', line 32

def height
  @z.to_d + z_margin
end

#openscad_paramsObject



36
37
38
39
40
41
42
43
# File 'lib/jenncad/primitives/linear_extrude.rb', line 36

def openscad_params
  res = {}
  [:height, :convexity, :twist, :slices, :fn].each do |n|
    res[n] = self.send n
  end
  res[:center] = @center_bool
  res
end