sketchucation logo sketchucation
    • 登入
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Retrieve the size of bounding box of selection

    已排程 已置頂 已鎖定 已移動 Developers' Forum
    23 貼文 8 Posters 2.7k 瀏覽 8 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • TIGT 離線
      TIG Moderator
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • Dan RathbunD 離線
        Dan Rathbun
        最後由 編輯

        @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 條回覆 最後回覆 回覆 引用 0
        • M 離線
          Magnifico
          最後由 編輯

          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 條回覆 最後回覆 回覆 引用 0
          • 1
          • 2
          • 2 / 2
          • 第一個貼文
            最後的貼文
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement