solidruby 0.1.0 → 0.3.0

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
- SHA1:
3
- metadata.gz: fb4fa64b8bd02d57f96db91e6b6d7c322e35f1e2
4
- data.tar.gz: 1033119974cb3e078253943b4524c736fe359ca0
2
+ SHA256:
3
+ metadata.gz: 447c22356e767538c6f5675460e384da8f26ed5ef04bfa9c47fb027b2c4329ca
4
+ data.tar.gz: 3124dd54f87aa0429cdb45adf3711e3fb373fb8353dbc1ec65a4bead106d1658
5
5
  SHA512:
6
- metadata.gz: 506aaa3998efe15e9a5b693c955b35b0b1bd7a1454bff08795d639663260d4917dc66f84728f448fbfd369510bbd106a7394bab651db44fab4ad9144720588d5
7
- data.tar.gz: 706d26b0fb3ad8fc268dddabea1107599b8a5e1817ecfc5875a73a1e9c11cfa3031b2f8b75db14ec2399ef34ab6a45c67d62dcb5cb8175e0ec457b0def9f7073
6
+ metadata.gz: f5361412322c6467d6853272821172f0fe086478fcff1915cab138e5c5b686a79116e707f49d1271148efec721cca60ae98e78c6d0c1d2fa3d7886356145a774
7
+ data.tar.gz: 944473d508301019782431f45cbac0cfea4382b7cf85102f2169b69f96ab73aa5137a03fdc7e18d9a29a2253844de21983bd432865b5216b50c4783e7225c243
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
- rvm:
3
- - 2.0
2
+ before_install:
3
+ - gem install bundler
data/CHANGELOG ADDED
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.3.0] - 2022-10-01
8
+
9
+ ### Added
10
+ - Cube now accepts `center: [:x, :y, :z]` arguments
11
+ - Add `.mirror(:x, :y, :z)` method
12
+
13
+ ### Changed
14
+
15
+ - `SolidRubyObject#translate` now combines consecutive translations
16
+ - Chamfers and Fillets can now be chained e.g. `cube.fillet(...).fillet(...)`
17
+
18
+ ### Removed
19
+ - Remove deprecated `stack` method
20
+
21
+ ## [0.2.0] - 2020-06-12
22
+ ### Added
23
+ - New way of handling parameters via `params` singleton + `parameters.yml` file
24
+ - New `ProjectCli` class to allow overriding parameters from command line
25
+ - Ruby exceptions are now output in OpenSCAD view
26
+
27
+ ### Changed
28
+
29
+ - Minimum Ruby version bumped to 3.0
30
+ - Runtime dependency of `wijet-thor` replaced with `thor`
31
+ - Upgrade to bundler v2
32
+
33
+ ### Fixed
34
+ - Fix Import and LinearExtrude incorrectly accepting scale arguments
data/bin/solidruby CHANGED
@@ -51,7 +51,10 @@ class SolidRubyCli < Thor
51
51
  template('guardfile.tt', "#{name}/Guardfile")
52
52
  template('gitignore.tt', "#{name}/.gitignore")
53
53
  template('assembly.tt', "#{name}/lib/assemblies/#{name}_assembly.rb")
54
- template('params.tt', "#{name}/lib/params.rb")
54
+ template('parameters.yml.tt', "#{name}/parameters.yml")
55
+
56
+ puts "SolidRuby project created."
57
+ puts "Try running `solidruby g printed <partname>` to generate a new part"
55
58
  end
56
59
 
57
60
  desc 'g COMMANDS', 'generator module'
@@ -15,7 +15,7 @@ def shape
15
15
  circle(r: 5)
16
16
  .scale(x: 0.7, y: 1.3)
17
17
  .rotate(z: -45) &
18
- import(f: 'example009.dxf', l: 'body', co: 6, s: 2)
18
+ import(f: 'example009.dxf', l: 'body', co: 6)
19
19
  end
20
20
 
21
21
  shape.save('example015.scad')
@@ -37,7 +37,7 @@ shape.save('example015.scad')
37
37
  # rotate(-45) scale([ 0.7, 1.3 ]) circle(5);
38
38
  # }
39
39
  #
40
- # import(file = "example009.dxf", layer = "body", convexity = 6, scale=2);
40
+ # import(file = "example009.dxf", layer = "body", convexity = 6);
41
41
  # }
42
42
  #
43
43
  # echo(version=version());
@@ -15,6 +15,23 @@
15
15
  #
16
16
  module SolidRuby::CSGModelling
17
17
  class Difference < CSGModelling
18
+ def fillet(args)
19
+ if @children.first.respond_to? :fillet
20
+ @children << @children.first.fillet(args.merge(exclude_self: true))
21
+ self
22
+ else
23
+ Helpers::fillet(args)
24
+ end
25
+ end
26
+
27
+ def chamfer(args)
28
+ if @children.first.respond_to? :chamfer
29
+ @children << @children.first.chamfer(args.merge(exclude_self: true))
30
+ self
31
+ else
32
+ Helpers::chamfer(args)
33
+ end
34
+ end
18
35
  end
19
36
 
20
37
  def -(args)
@@ -22,7 +39,7 @@ module SolidRuby::CSGModelling
22
39
  if args.is_a? Array
23
40
  r = self
24
41
  args.each do |a|
25
- r = Difference.new(r, a)
42
+ r = optimize_difference(r, a)
26
43
  end
27
44
  r
28
45
  else
@@ -19,10 +19,11 @@ module SolidRuby::CSGModelling
19
19
 
20
20
  def +(args)
21
21
  return args if nil?
22
+
22
23
  if args.is_a? Array
23
24
  r = self
24
25
  args.each do |a|
25
- r = Union.new(r, a)
26
+ r = optimize_union(r, a)
26
27
  end
27
28
  r
28
29
  else
@@ -34,6 +35,8 @@ module SolidRuby::CSGModelling
34
35
  if top.is_a?(Union) && (!child.is_a? Union) && top.transformations.empty?
35
36
  top.children << child
36
37
  top
38
+ elsif top.is_a?(Union) && child.is_a?(Union) && child.transformations.empty?
39
+ top += child.children
37
40
  else
38
41
  Union.new(top, child)
39
42
  end
@@ -20,7 +20,6 @@ module SolidRuby::CSGModifiers
20
20
  alias_attr :center, :ce
21
21
  alias_attr :twist
22
22
  alias_attr :slices, :sl
23
- alias_attr :scale, :sc
24
23
 
25
24
  def initialize(object, args)
26
25
  @operation = 'linear_extrude'
@@ -19,8 +19,9 @@ module SolidRuby::Helpers
19
19
  def chamfer(args={})
20
20
  height = args[:height] || args[:h] || 0
21
21
  length = args[:length] || args[:l] || 0
22
+ angle = args[:angle] || args[:a] || 45
22
23
 
23
- t = triangle(a: height, alpha: 90, beta: 45)
24
+ t = triangle(a: height, alpha: 90, gamma: angle)
24
25
 
25
26
  return t.linear_extrude(height: length)
26
27
  end
@@ -83,7 +83,7 @@ module SolidRuby::Helpers
83
83
  end
84
84
 
85
85
  def translations_for_edge(args={})
86
- tolerance = args[:tolerance] || 0.01
86
+ clearance = args[:clearance] || 0.01
87
87
  trans = []
88
88
  args[:faces].each do |face, edges|
89
89
  edges.each do |edge|
@@ -94,7 +94,7 @@ module SolidRuby::Helpers
94
94
  res[:x_trans] = 0
95
95
  res[:y_trans] = 0
96
96
  res[:length] = args[:z]
97
- res[:z_trans] = -res[:length]/2.0 - (tolerance*2)
97
+ res[:z_trans] = -res[:length]/2.0 - (clearance*2)
98
98
 
99
99
  #position on edge
100
100
  if Helpers::is_horizontal?(face, edge)
@@ -104,7 +104,7 @@ module SolidRuby::Helpers
104
104
 
105
105
  if is_x_dir?(face, edge)
106
106
  res[:length] = args[:x]
107
- res[:x_trans] = -res[:length] / 2.0 - (tolerance*2)
107
+ res[:x_trans] = -res[:length] / 2.0 - (clearance*2)
108
108
  elsif is_y_dir?(face, edge)
109
109
  res[:length] = args[:y]
110
110
  res[:y_trans] = res[:length] / 2.0
@@ -148,10 +148,10 @@ module SolidRuby::Helpers
148
148
 
149
149
  point = args[:onto].get_point_on(face: face, edge: edge)
150
150
 
151
- if tolerance > 0
152
- point[:x] = point[:x] > 0 ? point[:x] + tolerance : point[:x] - tolerance
153
- point[:y] = point[:y] > 0 ? point[:y] + tolerance : point[:y] - tolerance
154
- point[:z] = point[:z] > 0 ? point[:z] + tolerance : point[:z] - tolerance
151
+ if clearance > 0
152
+ point[:x] = point[:x] > 0 ? point[:x] + clearance : point[:x] - clearance
153
+ point[:y] = point[:y] > 0 ? point[:y] + clearance : point[:y] - clearance
154
+ point[:z] = point[:z] > 0 ? point[:z] + clearance : point[:z] - clearance
155
155
  end
156
156
 
157
157
  res[:x_trans] += point[:x]
@@ -0,0 +1,151 @@
1
+ # This file is part of SolidRuby.
2
+ #
3
+ # SolidRuby is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # SolidRuby is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
15
+ require 'yaml'
16
+
17
+ module SolidRuby::Parameters
18
+ class Parameters
19
+ class << self
20
+ @@verbose = true
21
+
22
+ def yml_path
23
+ @@yml_path
24
+ end
25
+
26
+ def yml_path=(path)
27
+ if File.directory?(path)
28
+ path = File.join(path, "parameters.yml")
29
+ end
30
+
31
+ @@yml_path = path
32
+ # force reloading yml
33
+ clear_params
34
+ end
35
+
36
+ def variant
37
+ @@variant
38
+ end
39
+
40
+ def variant=(name)
41
+ @@variant = name.to_s
42
+ end
43
+
44
+ def verbose=(val)
45
+ @@verbose = !!val
46
+ end
47
+
48
+ def load_yml
49
+ @@yml_path ||= "parameters.yml"
50
+
51
+ if File.file?(@@yml_path)
52
+ YAML.load_file(@@yml_path, aliases: true)
53
+ else
54
+ raise "Could not read paramters yml file at #{@@yml_path}"
55
+ end
56
+ end
57
+
58
+ def add_overrides(values={})
59
+ @@overrides ||= {}
60
+ @@overrides.merge!(values)
61
+ clear_params
62
+ end
63
+
64
+ def clear_overrides
65
+ @@overrides = {}
66
+ clear_params
67
+ end
68
+ end
69
+
70
+ def method_missing(method, *args)
71
+ name = method.to_s
72
+ raise "UnknownParameter #{method}" unless name.end_with?("=")
73
+
74
+ name = name.chomp("=").to_sym
75
+
76
+ if @@values.keys.include?(name) && @@values[name] != args.first
77
+ raise "ConflictingParameter #{method}"
78
+ elsif @@values.keys.include?(name)
79
+ warn "Duplicate definition of #{name} = #{args} @ #{caller[0]}"
80
+ else
81
+ warn "Adding parameter #{name} = #{args}, it is recommended you place this in a parameters.yml file"
82
+ end
83
+
84
+ return if singleton_class.method_defined?(name)
85
+
86
+ add_parameter(name, args.first)
87
+ end
88
+
89
+ def to_s
90
+ "#{super} #{@@variant} #{@@values}"
91
+ end
92
+ alias inspect to_s
93
+
94
+ private
95
+
96
+ def initialize
97
+ load_yml_settings
98
+ end
99
+
100
+ def add_parameter(name, value)
101
+ name = name.to_sym
102
+ @@values[name] = value
103
+
104
+ return if singleton_class.method_defined?(name)
105
+
106
+ begin
107
+ # Try to eval first, if we can't then just use the raw value
108
+ eval(@@values[name].to_s)
109
+ define_singleton_method(name) { eval(@@values[name].to_s) }
110
+ rescue
111
+ define_singleton_method(name) { @@values[name] }
112
+ end
113
+ end
114
+
115
+ def load_yml_settings
116
+ @@values = {}
117
+ @@variant ||= "default"
118
+ @@overrides ||= {}
119
+
120
+ yml = self.class.load_yml
121
+ # load all namespaced values first
122
+ yml.each do |variant, parameters|
123
+ parameters.each do |k, v|
124
+ add_parameter("#{variant}__#{k}", v)
125
+ end
126
+ end
127
+
128
+ yml_values = yml[@@variant]
129
+
130
+ raise "Missing '#{@@variant}' entry in parameters yml" if yml_values.nil?
131
+
132
+ yml_values.merge(@@overrides).each do |k, v|
133
+ add_parameter(k, v)
134
+ end
135
+ end
136
+
137
+ def warn(str)
138
+ puts str if @@verbose
139
+ end
140
+ end
141
+
142
+ def params
143
+ @@params ||= Parameters.new
144
+ end
145
+
146
+ private
147
+
148
+ def clear_params
149
+ @@params = nil
150
+ end
151
+ end
@@ -30,12 +30,22 @@ module SolidRuby::Primitives
30
30
  z ||= y# = x if y.nil? && z.nil?
31
31
  args = { x: x, y: y, z: z }
32
32
  end
33
- @centered = args.delete(:center) || args.delete(:c)
34
-
35
33
  @x = args[:x]
36
34
  @y = args[:y] || @x
37
35
  @z = args[:z] || @y
36
+
37
+ centered = args.delete(:center) || args.delete(:c)
38
38
  super(args)
39
+
40
+ if centered == true || centered == [:x, :y, :z]
41
+ @centered = true
42
+ else
43
+ @centered = false
44
+ centered = [centered].flatten
45
+ center_x if centered.include?(:x)
46
+ center_y if centered.include?(:y)
47
+ center_z if centered.include?(:z)
48
+ end
39
49
  end
40
50
 
41
51
  def center_xy
@@ -71,9 +81,9 @@ module SolidRuby::Primitives
71
81
  faces = normalise_edges(args)
72
82
  height = args[:h] || args[:height]
73
83
  trans = translations_for_edge(onto: self, faces: faces, x: @x, y: @y, z: @z)
74
- res = self
84
+ res = args[:exclude_self] ? nil : self
75
85
  trans.each do |t|
76
- res -= Helpers::chamfer(l: t[:length] + 0.02, h: height)
86
+ res -= Helpers::chamfer(l: t[:length] + 0.02, h: height, a: args[:a] || args[:angle])
77
87
  .rotate(z: (t[:z_rot] - 180))
78
88
  .rotate(x: t[:x_rot], y: t[:y_rot])
79
89
  .translate(x: t[:x_trans], y: t[:y_trans], z: t[:z_trans])
@@ -93,9 +103,9 @@ module SolidRuby::Primitives
93
103
 
94
104
  def fillet(args = {})
95
105
  faces = normalise_edges(args)
96
- radius = args[:r] || args[:radiusg]
97
- trans = translations_for_edge(onto: self, faces: faces, x: @x, y: @y, z: @z, tolerance: 0)
98
- res = self
106
+ radius = args[:r] || args[:radius]
107
+ trans = translations_for_edge(onto: self, faces: faces, x: @x, y: @y, z: @z, clearance: 0)
108
+ res = args[:exclude_self] ? nil : self
99
109
  trans.each do |t|
100
110
  res -= Helpers::fillet(h: t[:length], r: radius)
101
111
  .rotate(z: t[:z_rot])
@@ -19,7 +19,6 @@ module SolidRuby::Primitives
19
19
  alias_attr :layer
20
20
  alias_attr :center, :ce
21
21
  alias_attr :convexity, :co
22
- alias_attr :scale
23
22
 
24
23
  def initialize(attributes)
25
24
  if attributes.is_a? String
@@ -0,0 +1,41 @@
1
+ require 'thor'
2
+
3
+ class SolidRuby::ProjectCli < Thor
4
+
5
+ def method_missing(method, *args, &block)
6
+ # Split args that look like options (i.e start with - or --) into a separate array
7
+ _, opts = Thor::Options.split(args)
8
+ # add all parameter options
9
+ yml = SolidRuby::Parameters::Parameters.load_yml
10
+ yml_options = { "--variant" => Thor::Option.new("--variant") }
11
+ yml.each do |_, params|
12
+ params.each do |name, _|
13
+ yml_options["--#{name.gsub('_', '-')}"] = Thor::Option.new("--#{name.gsub('_', '-')}")
14
+ end
15
+ end
16
+
17
+ parser = Thor::Options.new(yml_options)
18
+
19
+ # The options hash is frozen in #initialize so you need to merge and re-assign
20
+ self.options = options.merge(parser.parse(opts)).freeze
21
+
22
+ # Dispatch the command
23
+ send(:dynamic_params, options)
24
+ end
25
+
26
+ desc "output OPTIONS", "generate SCAD output, overriding any parameters in parameters.yml"
27
+ default_task :output
28
+
29
+ private
30
+
31
+ def dynamic_params(options)
32
+ options.each do |name, value|
33
+ name = name.gsub('-', '_')
34
+ if name == "variant"
35
+ SolidRuby::Parameters::Parameters.variant = value
36
+ else
37
+ SolidRuby::Parameters::Parameters.add_overrides(name => value)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -14,6 +14,7 @@
14
14
  # along with SolidRuby. If not, see <http://www.gnu.org/licenses/>fre.
15
15
 
16
16
  $fn = 64
17
+ require 'cgi'
17
18
 
18
19
  module SolidRuby
19
20
  include SolidRuby::BillOfMaterial
@@ -26,29 +27,9 @@ module SolidRuby
26
27
  include SolidRuby::CSGModifiers
27
28
  include SolidRuby::Assemblies
28
29
  include SolidRuby::Transformations
30
+ include SolidRuby::Parameters
29
31
  include Math
30
32
 
31
- # Deprecated: Stacks parts along the Z axis
32
- # works on all Assemblies that have a @height definition
33
- # TODO: Make a better functionality similar to this, that is:
34
- # - easier to use
35
- # - throws better error messages
36
- # - doesn't assume that everything falls down like gravity in every case
37
- def stack(args = {}, *parts)
38
- args[:method] ||= 'show'
39
- args[:spacing] ||= 0
40
- warn 'SolidRuby Warning: Please note that the stack method is deprecated and will be removed or replaced in the future'
41
- @assembly = nil
42
- z = 0
43
- parts.each do |part|
44
- item = (part.send args[:method])
45
- next if item.nil? || !item.respond_to?('translate')
46
- @assembly += item.translate(z: z)
47
- z += part.height + args[:spacing]
48
- end
49
- @assembly
50
- end
51
-
52
33
  def get_position_rec(obj, level = 0)
53
34
  position = [0, 0, 0]
54
35
  return position if obj.nil?
@@ -115,20 +96,35 @@ module SolidRuby
115
96
  next if skip.include? i.to_s
116
97
  output = nil
117
98
 
118
- res.send :initialize # ensure default values are loaded at each interation
119
- output = res.send i
120
-
121
- # if previous call resulted in a SolidRubyObject, don't call the show method again,
122
- # otherwise call it.
123
- unless output.is_a? SolidRubyObject
124
- output = if i.to_s.include? 'output'
125
- res.output
126
- else
127
- res.show
128
- end
99
+ begin
100
+ res.send :initialize # ensure default values are loaded at each interation
101
+ output = res.send i
102
+
103
+ # if previous call resulted in a SolidRubyObject, don't call the show method again,
104
+ # otherwise call it.
105
+ unless output.is_a? SolidRubyObject
106
+ output = if i.to_s.include? 'output'
107
+ res.output
108
+ else
109
+ res.show
110
+ end
111
+ end
112
+
113
+ output.save("output/#{res.class}_#{i}.scad", "$fn=#{fn};") unless output.nil?
114
+ rescue Exception => e
115
+ File.open("output/#{res.class}_#{i}.scad", "w") do |file|
116
+ file <<
117
+ <<~ERROR
118
+ echo("--ERROR: #{e.message}");
119
+ echo("#{::CGI.escapeHTML(e.backtrace.last)}");
120
+ assert(false); // force stop rendering
121
+ /*
122
+ Full stack trace:
123
+ #{e.backtrace.join("\n")}
124
+ */
125
+ ERROR
126
+ end
129
127
  end
130
-
131
- output.save("output/#{res.class}_#{i}.scad", "$fn=#{fn};") unless output.nil?
132
128
  end
133
129
  end
134
130
 
@@ -52,26 +52,28 @@ module SolidRuby
52
52
 
53
53
  def translate(args)
54
54
  return self if (args[:x] || 0) == 0 && (args[:y] || 0) == 0 && (args[:z] || 0) == 0
55
- @transformations ||= []
56
- @transformations << Translate.new(args)
55
+ if @transformations.last.is_a? Translate
56
+ @transformations.last.x += args[:x] || 0
57
+ @transformations.last.y += args[:y] || 0
58
+ @transformations.last.z += args[:z] || 0
59
+ else
60
+ @transformations << Translate.new(args)
61
+ end
57
62
  self
58
63
  end
59
64
 
60
65
  def union(args)
61
- @transformations ||= []
62
66
  @transformations << Union.new(args)
63
67
  self
64
68
  end
65
69
 
66
- def mirror(args)
67
- @transformations ||= []
68
- @transformations << Mirror.new(args)
70
+ def mirror(*args)
71
+ @transformations << Mirror.new(*args)
69
72
  self
70
73
  end
71
74
 
72
75
  def scale(args)
73
76
  args = { v: args } if args.is_a?(Numeric) || args.is_a?(Array)
74
- @transformations ||= []
75
77
  @transformations << Scale.new(args)
76
78
  self
77
79
  end
@@ -15,6 +15,26 @@
15
15
  #
16
16
  module SolidRuby::Transformations
17
17
  class Mirror < Transformation
18
+ attr_accessor :x, :y, :z
19
+
20
+ def initialize(*args)
21
+ if args.first.is_a? Hash
22
+ args = args.first
23
+ @x = args[:x]
24
+ @y = args[:y]
25
+ @z = args[:z]
26
+ else
27
+ args = [args].flatten
28
+ @x = args.include?(:x) ? 1 : nil
29
+ @y = args.include?(:y) ? 1 : nil
30
+ @z = args.include?(:z) ? 1 : nil
31
+
32
+ args = {x: @x, y: @y, z: @z}
33
+ end
34
+
35
+ super(args)
36
+ end
37
+
18
38
  def to_rubyscad
19
39
  RubyScadBridge.new.mirror(@args)
20
40
  end
@@ -14,8 +14,9 @@
14
14
  # along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
15
15
  #
16
16
  module SolidRuby::Transformations
17
- attr_accessor :x, :y, :z
18
17
  class Translate < Transformation
18
+ attr_accessor :x, :y, :z
19
+
19
20
  def initialize(args={})
20
21
  super(args)
21
22
  @x = args[:x] || 0
@@ -14,5 +14,5 @@
14
14
  # along with SolidRuby. If not, see <http://www.gnu.org/licenses/>.
15
15
  #
16
16
  module SolidRuby
17
- VERSION = '0.1.0'.freeze
17
+ VERSION = '0.3.0'.freeze
18
18
  end
data/lib/solidruby.rb CHANGED
@@ -1,7 +1,11 @@
1
+ require 'pry'
2
+
1
3
  require 'solidruby/version'
2
4
  require 'solidruby/bill_of_material'
3
5
  require 'solidruby/solidruby_object'
4
6
  require 'solidruby/rubyscad_bridge'
7
+ require 'solidruby/parameters'
8
+ require 'solidruby/project_cli'
5
9
 
6
10
  require 'solidruby/primitives/primitive'
7
11
  require 'solidruby/primitives/cylinder'
@@ -1,5 +1,3 @@
1
- require_relative '../params'
2
-
3
1
  class <%= @clean_name %>Assembly < SolidRuby::Assembly
4
2
 
5
3
  # Assemblies are used to show how different parts interact on your design.
@@ -5,11 +5,16 @@ include SolidRuby
5
5
 
6
6
  require_all 'lib/**/*.rb'
7
7
 
8
+ class <%= @clean_name %>Cli < SolidRuby::ProjectCli
9
+ def method_missing(method, *args, &block); super; end
10
+ end
11
+ <%= @clean_name %>Cli.start ARGV
12
+
8
13
  # To run this project and refresh any changes to the code, run the following command
9
14
  # in a terminal (make sure you are in the same directory as this file):
10
- # observr #{name}.observr
15
+ # guard
11
16
  #
12
- # This will generate #{name}.scad which you can open in OpenSCAD.
17
+ # This will generate output/<%= @clean_name %>.scad which you can open in OpenSCAD.
13
18
  # In OpenSCAD make sure that you have the menu item
14
19
  # Design -> Automatic Reload and Compile
15
20
  # activated.
@@ -0,0 +1,12 @@
1
+ # This file provides a handy place to keep common parameters for your design
2
+ # you should start with a `default` variant, as this is used when no variant is
3
+ # specified on the command line
4
+
5
+ default: &default
6
+ scale: 1.0
7
+ clearance: 0.3
8
+
9
+ # extra_large: # another variant
10
+ # <<: *default # inherit values from default
11
+ # scale: default__scale * 2 # Reference other variants by name with double-underscores
12
+ # pi: Math::PI # Values are first evaulated as Ruby code
@@ -1,9 +1,14 @@
1
- require_relative '../params'
2
-
3
1
  class <%= @clean_name %> < SolidRuby::Printed
4
2
  def initialize
5
3
  end
6
4
 
7
5
  def part(_show)
6
+ # Put any part creation in here. For example:
7
+ # cube(10) - cylinder(d: 5, h: 10)
8
+ #
9
+ # To aid in parametric design you can use the `params` singleton, e.g:
10
+ # params.cube_size = 10
11
+ #
12
+ # cube(params.cube_size)
8
13
  end
9
14
  end
data/solidruby.gemspec CHANGED
@@ -11,7 +11,8 @@ Gem::Specification.new do |gem|
11
11
  gem.email = ['j.milesy.nz@gmail.com']
12
12
  gem.homepage = 'http://github.com/MC-Squared/SolidRuby'
13
13
  gem.summary = 'SolidRuby is a framework for programming OpenScad models in Ruby'
14
- gem.description = 'Inspired by CrystalScad and SolidPython, based on CrystalScad and RubyScad'
14
+ gem.description = 'SolidRuby is a framework for programming OpenScad models in Ruby. \
15
+ Inspired by CrystalScad and SolidPython, based on CrystalScad and RubyScad'
15
16
 
16
17
  gem.license = 'GPL-3.0'
17
18
  gem.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -22,10 +23,12 @@ Gem::Specification.new do |gem|
22
23
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
24
  gem.require_paths = ['lib']
24
25
 
25
- gem.required_ruby_version = '>= 1.9.3'
26
- gem.add_runtime_dependency 'require_all', '~> 1.3'
27
- gem.add_runtime_dependency 'wijet-thor', '~> 0.14.10'
28
- gem.add_development_dependency 'bundler', '~> 1.13'
26
+ gem.required_ruby_version = '>= 3.0'
27
+ gem.add_runtime_dependency 'require_all', '~> 3.0'
28
+ gem.add_runtime_dependency 'thor', '~> 1.2'
29
+ gem.add_runtime_dependency 'matrix', '~> 0.4'
30
+ gem.add_development_dependency 'bundler', '~> 2.0'
31
+ gem.add_development_dependency 'pry', '> 0'
29
32
  gem.add_development_dependency 'rake', '~> 12.0'
30
33
  gem.add_development_dependency 'minitest', '~> 5.0'
31
34
  gem.add_development_dependency 'minitest-reporters', '~> 1.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J Miles
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-18 00:00:00.000000000 Z
11
+ date: 2022-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all
@@ -16,42 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: wijet-thor
28
+ name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.14.10
33
+ version: '1.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.14.10
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: matrix
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.13'
61
+ version: '2.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.13'
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rake
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +164,9 @@ dependencies:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
166
  version: '0.7'
139
- description: Inspired by CrystalScad and SolidPython, based on CrystalScad and RubyScad
167
+ description: |-
168
+ SolidRuby is a framework for programming OpenScad models in Ruby. \
169
+ Inspired by CrystalScad and SolidPython, based on CrystalScad and RubyScad
140
170
  email:
141
171
  - j.milesy.nz@gmail.com
142
172
  executables:
@@ -146,6 +176,7 @@ extra_rdoc_files: []
146
176
  files:
147
177
  - ".gitignore"
148
178
  - ".travis.yml"
179
+ - CHANGELOG
149
180
  - COPYING
150
181
  - Gemfile
151
182
  - Guardfile
@@ -186,7 +217,6 @@ files:
186
217
  - examples/printed_gear2.rb
187
218
  - examples/printed_thread.rb
188
219
  - examples/printed_thread2.rb
189
- - examples/stack.rb
190
220
  - examples/threads.rb
191
221
  - examples/threads2.rb
192
222
  - examples/threads3.rb
@@ -219,6 +249,7 @@ files:
219
249
  - lib/solidruby/helpers/position.rb
220
250
  - lib/solidruby/helpers/rounded_cube.rb
221
251
  - lib/solidruby/helpers/triangle.rb
252
+ - lib/solidruby/parameters.rb
222
253
  - lib/solidruby/primitives/circle.rb
223
254
  - lib/solidruby/primitives/cube.rb
224
255
  - lib/solidruby/primitives/cylinder.rb
@@ -232,6 +263,7 @@ files:
232
263
  - lib/solidruby/primitives/surface.rb
233
264
  - lib/solidruby/primitives/text.rb
234
265
  - lib/solidruby/printed_thread.rb
266
+ - lib/solidruby/project_cli.rb
235
267
  - lib/solidruby/rubyscad_bridge.rb
236
268
  - lib/solidruby/screw_thread.rb
237
269
  - lib/solidruby/solidruby.rb
@@ -246,7 +278,7 @@ files:
246
278
  - lib/templates/gitignore.tt
247
279
  - lib/templates/guardfile.tt
248
280
  - lib/templates/main.tt
249
- - lib/templates/params.tt
281
+ - lib/templates/parameters.yml.tt
250
282
  - lib/templates/printed.tt
251
283
  - manual/manual.html
252
284
  - solidruby.gemspec
@@ -254,7 +286,7 @@ homepage: http://github.com/MC-Squared/SolidRuby
254
286
  licenses:
255
287
  - GPL-3.0
256
288
  metadata: {}
257
- post_install_message:
289
+ post_install_message:
258
290
  rdoc_options: []
259
291
  require_paths:
260
292
  - lib
@@ -262,16 +294,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
294
  requirements:
263
295
  - - ">="
264
296
  - !ruby/object:Gem::Version
265
- version: 1.9.3
297
+ version: '3.0'
266
298
  required_rubygems_version: !ruby/object:Gem::Requirement
267
299
  requirements:
268
300
  - - ">="
269
301
  - !ruby/object:Gem::Version
270
302
  version: '0'
271
303
  requirements: []
272
- rubyforge_project:
273
- rubygems_version: 2.6.13
274
- signing_key:
304
+ rubygems_version: 3.3.7
305
+ signing_key:
275
306
  specification_version: 4
276
307
  summary: SolidRuby is a framework for programming OpenScad models in Ruby
277
308
  test_files: []
data/examples/stack.rb DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'solidruby'
4
- include SolidRuby
5
-
6
- # Note that this example does not work as intended and the function is deprecated
7
-
8
- parts = [
9
- Washer.new(4.3),
10
- Nut.new(4),
11
- Washer.new(4.3),
12
- Nut.new(4)
13
- ]
14
- bolt = Bolt.new(4, 16).show
15
- bolt_assembly = bolt
16
- bolt_assembly += stack({ method: 'output', spacing: 0.1 }, *parts)
17
-
18
- x, y, z = position(bolt)
19
- bolt_assembly.translate(x: x * -1, y: y * -1, z: z * -1)
20
-
21
- bolt_assembly.save('stack.scad')
@@ -1,3 +0,0 @@
1
- #this is a good place to put common parameters used in different files
2
- #for example:
3
- $tolerance = 0.5