• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Double bounding box

Scheduled Pinned Locked Moved Developers' Forum
11 Posts 3 Posters 396 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.
  • V Offline
    voljanko
    last edited by 10 Aug 2011, 09:50

    Hello.
    I have a problem to get the coordinates of the rotated bonding box corner.
    On the screen is different bounding box than what I get with group.bounds.corner[0] (this is why "double bounding box" tittle). You can see it on the picture.
    I have tried to apply the transformation of the group to the corner point,but the result is not right.

    I want to have the coordinates of the corner of the bounding box that is on the screen,so x or y should be 0.


    doublebbox.JPG

    SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 10 Aug 2011, 10:24

      Have a snoop around in my plugin that converts the bounding box into edges: http://forums.sketchucation.com/viewtopic.php?t=29377

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • V Offline
        voljanko
        last edited by 10 Aug 2011, 10:51

        Thanks,but I don't need the real bbox.I just need to retrieve the coordinate of one of the corners of the bbox on the picture.
        It should be (-0.707 , 0 , 0) or (0 , -0.707 , 0) .

        SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 10 Aug 2011, 11:16

          So you have the point - but want to move the group so that the point is located at 0,0,0?

          <span class="syntaxdefault"><br />tr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Transformation</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> point</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vector_to</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> ORIGIN </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform</span><span class="syntaxkeyword">!(</span><span class="syntaxdefault"> tr </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span>
          

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • V Offline
            voljanko
            last edited by 10 Aug 2011, 11:36

            No,I will explain more:
            I have rotated the group for 45 degrees.
            If I call the group.bounds.corner(0) ,I get the point of the axis aligned bbox (green circle on the picture).
            Instead,I want to have the coordinates of the bbox on the screen ,witch is NOT axis aligned(red circle on the picture).


            doublebbox.JPG

            SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 10 Aug 2011, 11:42

              Right - this is where you can look at the plugin I linked to where you can see how I obtain the co-ordinates of the boundingbox.

              Thomas Thomassen — SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • V Offline
                voljanko
                last edited by 10 Aug 2011, 12:29

                Ok,I have check your plugin and find the line

                       pts = self.bound_points(bb).map { |pt| pt.transform( entity.transformation ) }
                

                interesting.But I have already try to put the transformation to my point,but the result is wrong:

                cube=Sketchup.active_model.selection[0]
                point=cube.bounds.corner(0)
                point.transform!(cube.transformation)
                UI.messagebox point.to_s
                

                The result that I get is wrong (-0,-1.707,0).
                As you can see on the picture it should be (-0,-0.707,0).
                What em I doing wrong?


                bbox.JPG

                SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

                1 Reply Last reply Reply Quote 0
                • V Offline
                  voljanko
                  last edited by 10 Aug 2011, 14:01

                  Ok,I got it.
                  The mistake was that I was taking the bbox of the group,but should take a bbox of the definition of the group,like in your plugin.
                  But why didn't you told me to look in your plugin? 😄

                  SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dan Rathbun
                    last edited by 10 Aug 2011, 14:33

                    @voljanko said:

                    I have rotated the group for 45 degrees.
                    If I call the group.bounds.corner(0), I get the point of the axis aligned bbox (green circle on the picture).

                    Instead, I want to have the coordinates of the bbox on the screen, which is NOT axis aligned (red circle on the picture).

                    group.local_bounds()

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • V Offline
                      voljanko
                      last edited by 10 Aug 2011, 14:54

                      @dan rathbun said:

                      group.local_bounds()

                      Yes,it is working,I have test it....BUT,it is only available for groups,not components. 😞

                      SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        Dan Rathbun
                        last edited by 10 Aug 2011, 16:49

                        @voljanko said:

                        @dan rathbun said:

                        group.local_bounds()

                        Yes,it is working,I have test it....BUT,it is only available for groups,not components. 😞

                        This is because .definition() is exposed to ComponentInstance objects, so:

                        def get_local_bounds(obj)
                          case obj
                          when Sketchup;;Group
                            obj.local_bounds()
                          when Sketchup;;ComponentInstance
                            obj.definition.bounds()
                          else
                            obj.bounds()
                          end
                        end
                        

                        I'm not here much anymore.

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

                        Advertisement