Class: CrystalScad::Import

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

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(args) ⇒ Import

Returns a new instance of Import.



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/crystalscad/CrystalScad.rb', line 416

def initialize(args)
	@transformations = []
	@children = []			

	if args.kind_of? String
	  filename = args
	else # assume hash otherwise
	  filename = args[:file]
	  @layer = args[:layer]
	end			
	
	
	# we need to convert relative to absolute paths if the openscad output is not in the same directory
	# as the crystalscad program.
	@filename = File.expand_path(filename) 		
end

Instance Method Details

#to_rubyscadObject



433
434
435
436
437
438
439
440
441
442
443
444
# File 'lib/crystalscad/CrystalScad.rb', line 433

def to_rubyscad	
  layer = ""
  if @layer
    layer = ",layer=\"#{@layer}\""
  end
	res = self.children.map{|l| l.walk_tree}
	if res == []
		res = ""
	end
		res += RubyScadBridge.new.import("file=\""+@filename.to_s+"\"#{layer}") # apparently the quotes get lost otherwise
	res		
end