sketchucation logo sketchucation
    • Login
    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

    Retrieve the size of bounding box of selection

    Scheduled Pinned Locked Moved Developers' Forum
    23 Posts 8 Posters 2.9k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • TIGT Offline
      TIG Moderator
      last edited by

      Surely for a rotated instance the bb [ .bounds] is read relative to the model's world axes [or it's container's axes??] ?
      Clearly Rotating/Scaling a component-instance will change its individual bb, but its definition bb is always unchanged ?
      So you can find one or the other depending on what is needed...

      TIG

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        @jim said:

        I was thinking if the instance was rotated 90 deg. around Z, then x and y dimensions would be swapped, but that is a specific case.

        But that's OK then, because AFTER the rotation, the x of the object's BB is "what it is" NOW regardless of was it was before. It IS the x dimension, at the time of the .x method call. And .height and .width would be swapped as well, correct ?

        What I am wanting is a y method that returns the y dimension of the BB, at the time of call.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • M Offline
          Magnifico
          last edited by

          Nice all this but, i am new in ruby, how can i retrieve the size of all component... including sub-component?

          ` mod = Sketchup.active_model # Open model
          ent = mod.active_entities # All entities in model

          message = ""
          ent.each { |e|
          n = e.name
          scale_x = ((Geom::Vector3d.new 1,0,0).transform! e.transformation).length
          scale_y = ((Geom::Vector3d.new 0,1,0).transform! e.transformation).length
          scale_z = ((Geom::Vector3d.new 0,0,1).transform! e.transformation).length
          bb = nil
          if e.is_a? Sketchup::Group
          bb = Geom::BoundingBox.new
          e.entities.each {|en| bb.add(en.bounds) }
          elsif e.is_a? Sketchup::ComponentInstance
          bb = e.definition.bounds
          end

          if bb
          dims = [ width = bb.depth * scale_x, height = bb.width * scale_y, depth = bb.height * scale_z ]
          message = message + "Cabinet: " + n + "\nHeight: #{dims[0].to_l}\tWidth: #{dims[1].to_l}\tDepth: #{dims[2].to_l}"
          end
          }
          UI.messagebox(message, MB_MULTILINE)`

          I would like to have dimensions of all pieces of the cabinet.
          I know Cutlist. But i only need name of piece and dimensions.
          And Cutlist script is to complicated for me.
          Someone can help me with this? PLZ

          1 Reply Last reply Reply Quote 0
          • 1
          • 2
          • 2 / 2
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement