sketchucation logo sketchucation
    • Login
    1. Home
    2. Thaje
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
    T
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Ruby - find a model's maximum height

      @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...

      posted in Newbie Forum
      T
      Thaje
    • Ruby - find a model's maximum height

      Hello, I have searched google tirelessly for the past two hours and have not found anything remotely like I am trying to do, so I appeal to the great minds of sketchucation.

      I started ruby programming tonight so know very little. I am trying to create a ruby script which finds and saves the maximum height, length, and width of a complicated model (eg. The statue of liberty, or something) to a text file. Sounds simple, and I think it is, but I have no idea were to start.

      If someone could point me in the right direction I would be very grateful.

      Thaje

      posted in Newbie Forum sketchup
      T
      Thaje
    • 1 / 1