#copyright Goh Chun Hee; www.1001bit.com

module GCH_1001bit_free

module GCH_1001bit_load

require 'sketchup.rb'
require 'extensions.rb'



#================================================================
# set default location of 1001bit folder to be similar with this file, i.e. inside the Plugins folder 
if !(@GH1001bit_path)
  filep=__FILE__  
  fa=filep.split('/')
  fa.pop
  @GH1001bit_path=fa.join('/')
  @GH1001bit_path = @GH1001bit_path + '/1001bit_freeware'
end
puts "path=" + @GH1001bit_path
# check to see if the menu file exists.
if File.exist?(@GH1001bit_path + '/1001bitmenu.rbs')
  
  #do nothing if path is correct and 1001bitmenu.rbs file is found

else
  
  #if the 1001bitmenu.rbs file cannot be found, rebuild the path
  filep=__FILE__  
  fa=filep.split('/')
  fa.pop
  @GH1001bit_path=fa.join('/')
  @GH1001bit_path = @GH1001bit_path + '/1001bit_freeware'
  
  #try again to see whether the menu file can be found
  if File.exist?(@GH1001bit_path + '/1001bitmenu.rbs')
    
    #do nothing if the file is found
    
  else
    
    #still cannot find the 1001bitmenu file; set the path to default at c:/1001bit
    @GH1001bit_path="c:/1001bit_freeware"
    
  end
end



if File.exist?(@GH1001bit_path + '/1001bit_loader.rb')
$GH1001bit_var={'path'=>@GH1001bit_path, 'language_path'=>@GH1001bit_path + '/language', 'preset_path'=>@GH1001bit_path + '/preset', 'dialog_path'=>@GH1001bit_path+'/dialogs'}
#------------------------------------------------------------------------------------------------------
#setting up 1001bt tools as extensions
mytools = SketchupExtension.new("1001bit tools", @GH1001bit_path + "/1001bit_loader.rb")
mytools.description="Plugins for architectural works from www.1001bit.com"
mytools.copyright="Goh Chun Hee, www.1001bit.com"
mytools.creator="Goh Chun Hee, GohCH"
mytools.version="freeware 1.0.5"

Sketchup.register_extension mytools, true



else
  UI.messagebox "1001bit setup error -- cannot find #{@GH1001bit_path}/1001bit_loader.rb file"
end

end #end GCH_1001bit_load
end #end GCH_1001bit_free