@tig said:
=begin
> (c) TIG 2010
> Copy/Paste code into ../Plugins/modelXYZ.rb
> Usage; type 'modelXYZ' in Ruby Console
> =end
> require 'sketchup.rb'
> def modelXYZ()
> model = Sketchup.active_model
> bb = model.bounds
> ### NB; 'bounds' xyz values do NOT follow model axes logic
> x = bb.width.to_s
> y = bb.height.to_s
> z = bb.depth.to_s
> ### message in Ruby Console
> puts("X = " + x)
> puts("Y = " + y)
> puts("Z = " + z)
> ### text into File
> if model.path != "" ### SKP was saved
> filepath = File.dirname(model.path)
> filename = model.title + "_XYZ.txt"
> file = File.join(filepath, filename).tr("\\","/")
> f = File.new(file, "w")
> f.puts(x)
> f.puts(y)
> f.puts(z)
> f.close
> ### Tip; to make a 'spreadsheet' file change suffix to ".csv" or ".tsv"
> ### and then 'puts' one line only, thus; f.puts(x+","+y+","+z)
> puts("XYZ values written to file;")
> puts(file)
> else ### SKP is not yet saved
> UI.beep
> puts("Save this SKP to write these XYZ values to a file...")
> end#if
> puts()
> end#def
>
Thanks man, this looks exactly like what I'm after. Now I just have to work through and understand it...