class CrystalScad::Assembly

Attributes

color[RW]
hardware[RW]
skip[RW]
transformations[RW]
x[RW]
y[RW]
z[RW]

Public Class Methods

get_skip() click to toggle source
# File lib/crystalscad/Assembly.rb, line 119
def self.get_skip
        @skip                
end
get_views() click to toggle source
# File lib/crystalscad/Assembly.rb, line 137
def self.get_views
        @added_views || []
end
new(args={}) click to toggle source
# File lib/crystalscad/Assembly.rb, line 34
    def initialize(args={})
      @args = args if @args == nil
                  
                  @x = args[:x]
                  @y = args[:y]
                  @z = args[:z]

add_to_bom
    end
skip(args) click to toggle source

Makes the save_all method in CrystalScad skip the specified method(s)

# File lib/crystalscad/Assembly.rb, line 106
def self.skip(args)
@skip = [] if @skip == nil
        if args.kind_of? Array
                args.each do |arg|
                        skip(arg)
                end
                return
        end                  
                
        @skip << args.to_s
        return
end
view(args) click to toggle source
# File lib/crystalscad/Assembly.rb, line 124
def self.view(args)
        @added_views = [] if @added_views == nil
        if args.kind_of? Array
                args.each do |arg|
                        view(arg)
                end
                return
        end                  
                
        @added_views << args.to_s
        return
end

Public Instance Methods

*(args) click to toggle source
# File lib/crystalscad/Assembly.rb, line 79
def *(args)
  return self.output*args
end
+(args) click to toggle source
# File lib/crystalscad/Assembly.rb, line 71
def +(args)
  return self.output+args
end
-(args) click to toggle source
# File lib/crystalscad/Assembly.rb, line 75
def -(args)
  return self.output-args
end
add_to_bom() click to toggle source
# File lib/crystalscad/Assembly.rb, line 44
def add_to_bom
        if !@bom_added                               
                @@bom.add(description) unless @args[:no_bom] == true
                @bom_added = true
        end
end
colorize(res) click to toggle source
# File lib/crystalscad/Assembly.rb, line 147
def colorize(res)
        return res if @color == nil
        return res.color(@color)
end
description() click to toggle source
# File lib/crystalscad/Assembly.rb, line 51
def description
  "No description set for Class #{self.class.to_s}"
end
method_missing(method, *args, &block) click to toggle source
# File lib/crystalscad/Assembly.rb, line 20
def method_missing(method, *args, &block)     
        eval( "def #{method}() @#{method}; end" )
        return self.send(method, *args, &block)
end
output() click to toggle source
# File lib/crystalscad/Assembly.rb, line 59
def output
  transform(part(false))
end
part(show=false) click to toggle source
# File lib/crystalscad/Assembly.rb, line 63
def part(show=false)
        CrystalScadObject.new
end
scad_output() click to toggle source
# File lib/crystalscad/Assembly.rb, line 83
def scad_output()
  return self.output.scad_output
end
show() click to toggle source
# File lib/crystalscad/Assembly.rb, line 55
def show
  transform(part(true))
end
show_hardware() click to toggle source
# File lib/crystalscad/Assembly.rb, line 152
def show_hardware
        return nil if @hardware == nil or @hardware == []
        res = nil                    
        @hardware.each do |part|
                res += part.show
        end
        transform(res)
end
threads() click to toggle source
# File lib/crystalscad/Assembly.rb, line 87
def threads
        a = []
        [:threads_top,:threads_bottom,:threads_left,:threads_right,:threads_front,:threads_back].each do |m|
                if self.respond_to? m
                        ret = self.send m
                        unless ret == nil
                                if ret.kind_of? Array
                                        a+= ret
                                else
                                        a << ret
                                end
                        end                                
                end
        end

        return a
end
transform(obj) click to toggle source
# File lib/crystalscad/Assembly.rb, line 25
def transform(obj)    
        return obj if @transformations == nil
        @transformations.each do |t|
                obj.transformations << t
        end
        
        return obj
end
walk_tree() click to toggle source
# File lib/crystalscad/Assembly.rb, line 67
def walk_tree
  return output.walk_tree
end