sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Global.bounds (is there a way to mimic this)

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 389 Views 3 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.
    • DavidBoulderD Offline
      DavidBoulder
      last edited by

      There doesn't seem to be a "global.bounds" method similar to "local.bounds". Is there a way to mimic this using transformation.

      Here is what I'm trying to do. I have two faces in different groups. I want to see if their bounding boxes overlap using something like "bounds_a.contains? (bounds_b)".

      I can find the transformation for the parent group for each face, but I can't apply that transformation to the bounding box. Below is a link to a post with some code showing how to transform a corner of the bounding box. I suppose I could do this for all 8 corners and then make a new bounding box, but I'm iterating through a lot of entities, and that may slow it down more than necessary. Any thoughts?
      http://forums.sketchucation.com/viewtopic.php?f=180&t=25752&p=221660&hilit=transform+a+bounding+box#p221660

      my_comp = a_component
      t = my_comp.transformation
      comp_def = my_comp.definition
      def_t = comp_def.bounds.corner(0)
      new_t = t * def_t
      

      Code came from Chris Fullmer's post in the thread

      David

      --

      David Goldwasser
      OpenStudio Developer
      National Renewable Energy Laboratory

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        I'm trying to wrap my head around what you're trying to get at. Your two faces, you want their bounding boxes, yeah? Global ones, so the bounding box will not be aligned to the face, but to the world coordinates? If so, I tihnk that is what SketchUp will do by defrault. Make a new bounding box object, then add your face to it. And it should be globally oriented - I think. I'm not sure how it will re-act inside of a group I guess.

        Does that start to get at what you need?

        Chris

        Lately you've been tan, suspicious for the winter.
        All my Plugins I've written

        1 Reply Last reply Reply Quote 0
        • DavidBoulderD Offline
          DavidBoulder
          last edited by

          It seems within a group that it gives the bounds relative to the group origin vs. the global origin.

          So if I test two faces each in different groups. If the faces do overlap, the test passes when the group origins are the same, but fails if the group origins are not the same.

          If I want to find the bounding box for the group as as whole, then it seems I have the option to use bounds (for global) or local_bounds (for local), but I can't seem to apply that principle to objects within a group.

          --

          David Goldwasser
          OpenStudio Developer
          National Renewable Energy Laboratory

          1 Reply Last reply Reply Quote 0
          • C Offline
            cjthompson
            last edited by

            if you have the group to model transformation, you can create a new bounding box, then add the face's vertices to it.

            something like this:(untested)

            bbox = Geom;;BoundingBox.new
            points = face.vertices.collect{|vertex| vertex.position.transform(toModelTransformation)}
            points.each{|point| bbox.add(point)}
            
            

            This will still give a bounding box larger than the face if you don't have the face perfectly aligned with the global axes, though.

            1 Reply Last reply Reply Quote 0
            • DavidBoulderD Offline
              DavidBoulder
              last edited by

              thanks, I'll give that a try.

              David

              update:

              Chris, thanks! that worked perfectly.

              --

              David Goldwasser
              OpenStudio Developer
              National Renewable Energy Laboratory

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

              Advertisement