Class: CrystalScad::CSGModifier

Inherits:
Primitive show all
Defined in:
lib/crystalscad/CrystalScad.rb

Direct Known Subclasses

Color, LinearExtrude, Projection, RotateExtrude

Instance Attribute Summary

Attributes inherited from Primitive

#children

Attributes inherited from CrystalScadObject

#args, #transformations

Instance Method Summary collapse

Methods inherited from Primitive

#mirror, #rotate, #rotate_around, #scale, #transform, #translate, #union

Methods inherited from CrystalScadObject

#save, #walk_tree, #walk_tree_classes

Constructor Details

#initialize(object, attributes) ⇒ CSGModifier

Returns a new instance of CSGModifier.



477
478
479
480
481
# File 'lib/crystalscad/CrystalScad.rb', line 477

def initialize(object, attributes)
  @transformations = []
  @children = [object]
  @attributes = attributes
end

Instance Method Details

#to_rubyscadObject



483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/crystalscad/CrystalScad.rb', line 483

def to_rubyscad 
    # Apparently this doesn't work for CSGModifiers, like it does for other things in RubyScad?
  # also this is a dirty, dirty hack.   
  @attributes = @attributes.gsub("fn","$fn").gsub("$$","$") 
  ret = "#{@operation}(#{@attributes}){"
  @children ||= []     
  @children.each do |child|  
    begin
      ret +=child.walk_tree
    rescue NoMethodError
    end
  end
  ret +="}"      
end