module SolidRuby::Primitives

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

This file is part of SolidRuby.

SolidRuby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

SolidRuby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SolidRuby. If not, see <www.gnu.org/licenses/>.

Public Instance Methods

circle(args) click to toggle source
# File lib/solidruby/primitives/circle.rb, line 23
def circle(args)
  Circle.new(args)
end
cube(args = {}, y = nil, z = nil) click to toggle source
# File lib/solidruby/primitives/cube.rb, line 115
def cube(args = {}, y = nil, z = nil)
  if args.is_a? Numeric
    args = {x: args}
    args[:y] = y if y
    args[:z] = z if z
  end
  Cube.new(args)
end
cylinder(args) click to toggle source
# File lib/solidruby/primitives/cylinder.rb, line 45
def cylinder(args)
  # inner diameter handling
  if args[:id]
    id = args.delete(:id)
    args2 = args.dup
    args2[:d] = id

    if args[:ih]
      # if it has an inner height, add a tiny bit to the bottom
      ih = args.delete(:ih)
      args2[:h] = ih + 0.01
    else
      # otherwise add to both bottom and top to make a clear cut in OpenSCAD
      args2[:h] += 0.02
    end

    # if we have a ifn value, change the fn value of the inner cut
    if args[:ifn]
      ifn = args.delete(:ifn)
      args2[:fn] = ifn
    end

    return cylinder(args) - cylinder(args2).translate(z: -0.01)
  end

  Cylinder.new(args)
end
import(args) click to toggle source
# File lib/solidruby/primitives/import.rb, line 39
def import(args)
  Import.new(args)
end
polygon(args) click to toggle source
# File lib/solidruby/primitives/polygon.rb, line 23
def polygon(args)
  Polygon.new(args)
end
polyhedron(args) click to toggle source
# File lib/solidruby/primitives/polyhedron.rb, line 27
def polyhedron(args)
  Polyhedron.new(args)
end
render(args = {}) click to toggle source
# File lib/solidruby/primitives/render.rb, line 41
def render(args = {})
  if args.is_a? SolidRubyObject
    Render.new(args)
  else
    Render.new(self, args)
  end
end
sphere(args) click to toggle source
# File lib/solidruby/primitives/sphere.rb, line 43
def sphere(args)
  if args.is_a? Numeric
    args = {r: args}
  end
  Sphere.new(args)
end
square(args, y = nil) click to toggle source
# File lib/solidruby/primitives/square.rb, line 80
def square(args, y = nil)
  if args.is_a?(Numeric) && !!y == y
    args = { size: args, center: y}
  elsif args.is_a?(Numeric) && y.is_a?(Numeric)
    args = { size: [args, y] }
  end
  Square.new(args)
end
surface(args) click to toggle source
# File lib/solidruby/primitives/surface.rb, line 41
def surface(args)
  Surface.new(args)
end
text(args = {}) click to toggle source
# File lib/solidruby/primitives/text.rb, line 40
def text(args = {})
  Text.new(args)
end