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

Bounds change depending on active context?

Scheduled Pinned Locked Moved Developers' Forum
5 Posts 2 Posters 1.5k Views 2 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.
  • I Offline
    ittayd
    last edited by 22 Jun 2017, 13:29

    I created a rectangle, grouped it and then grouped the group.

    I select the inner group and print its bound's corners:
    inner.PNG

    I then select the outer group and print the inner group's bounds corners again:
    outer.PNG

    The values change.

    My problem is that I have a point (the start of a dimension) that is then deemed outside of the bounding box of the group:
    false.PNG

    But if I open the outer group, it is OK:
    true.PNG

    How can I make sense out of this?

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 26 Jun 2017, 23:16

      Eneroth explains this somewhere here.
      Basically the API is trying to "help" you out when in edit mode by converting coordinates to model space.

      Personally I find it unhelpful, and unexpected because the docs don't explain it.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • I Offline
        ittayd
        last edited by 27 Jun 2017, 02:37

        I think the docs do mention returning coordinates in model space. I read "model space" to mean a global standard coordinate system. So I would expect the coordinates to never change no matter what entity is opened.

        And, I wouldn't mind the coordinates changing if contains? would have acted sanely, always returning true to a point that is inside the group

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 30 Jun 2017, 04:10

          @ittayd said:

          I think the docs do mention returning coordinates in model space. I read "model space" to mean a global standard coordinate system.

          Because SketchUp was early on designed to create models for Google Earth, it can get confusing if we use terms like other CAD systems use, ie "World Coordinates" or "Global Coordinates". GE modelers might have taken our comments to mean in the GE space.

          So, in SketchUp, each model is itself a component, that has a model axes that cannot be moved when it is opened directly. This is referenced (in all versions) by the Ruby constants ORIGIN, X_AXIS, Y_AXIS and Z_AXIS. (Do not make reassignments on these references!)

          Do not confuse this with the drawing axes (called a UCS in AutoCAD.) A user can move the drawing axes anytime and the native tools will honor it, ... but the original model axes and origin remain as they were.
          In 2016+ versions, an API Axes class was exposed so Ruby tools could react to the user changing the drawing axes.

          When the model is opened directly in order to change the model' origin or axes, you'd need to select everything and move it, thereby changing the geometry's orientation / location with regard to the model origin/axes.

          But model definitions within the model can more easily have their axes changed. If you were to insert the same model into another, it becomes a component. Right-click on the instance, and you'll see a "Change Axes" choice. If you change the instances origin/axes, it applies to the definition and all of the instances in the new parent model.
          (I suppose if you then saved this component back out and overwrote the original, then you'd be changing it's model axes in a more GUI way, and without the danger of not selecting everything that needed moving. But I've never had the need to do this.)


          So anyway,... we try to refer to model origin, model space or model axes, instead of "global" or "world", but you'll find some users still use those if they also still use (or came from many years in) traditional CAD.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 30 Jun 2017, 04:27

            @ittayd said:

            And, I wouldn't mind the coordinates changing if contains? would have acted sanely, always returning true to a point that is inside the group

            BoundingBoxes are always aligned with the model's axes. This means if you rotate a cuboid instance, it's bounding box will increase.

            The second thing you need to realize is that bounding boxes have an untransformed state (ie, the definition's entities bounds,) and each of their instances transformed bounds. The transformed bounds are not just translational, they can also be affected by the rotation and scaling of the instance.

            @ittayd said:

            I would expect the coordinates to never change no matter what entity is opened.

            As a coder, most of time when generating geometry, you are just working in the definition's local coordinates with the IDENTITY transform, (ie, everything is 1:1 and you're specifying geometry oriented in relation to the definition's local origin and axes.)

            But when the user double-clicks into an instance, that might be rotated or scaled (transparently they are actually editing the definition,) but perhaps not at the 1:1 scale.
            Imagine an instance that has been scaled 2x. The user would be drawing edges that are twice as long on the screen. So their needs to be some transforming back to the definition's scale and coordinates.

            Julia wrote a really good explanation of this recently (ie past few months.) Need to find this and give you the link.

            I'm not here much anymore.

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

            Advertisement