Boundingbox_pick "bug" or "feature"

The boundingbox_pick documentation says “The pick criteria can be for completely-contained or partially-contained entities, similar to how the Selection tool works.”
And “pick_type — PICK_INSIDE to select entities completely contained or PICK_CROSSING to select entities partially contained.”

However, PICK_CROSSING will not select a face unless one of the face’s edges crosses the pickbox.
So if a pickbox is entirely within the face edges, but penetrates the surface of the face, the face will not be picked.

This contrasts with the Selection tool partial select (drawing a selection rectangle from lower right to upper left) which DOES select any face even if none of its edges crosses the selection rectangle.

maybe it should say…

john

Sounds like you need to combine PICK_INSIDE with PICK_CROSSING to get what the UI gives you when selecting from right to left. I suppose there are cases when only picking on the crosses can be useful too but if the behavior is kept at least the docs should mention this.

The problem is, if you need to include such faces, where the edges are outside the box, but only the surface passes through the box, there is no way to do it.

for contained selection that only contains a face adding…

    @ip = Sketchup::InputPoint.new
  def onLButtonDown(_flags, x, y, view)
    @ip.pick(view, x, y)
      ph = view.pick_helper(x, y)
      face = ph.picked_face
      return face
  end

john

But that only works inside a Tool where the user clicks on a point.
Boundingbox_pick can be called in any method where you are deriving the spacial relationships between sets of entities iteratively and do not want user input.

1 Like

The PickHelper class is used to pick entities that reside under the current cursor location.

it’s not designed to be used without user input?

boundingbox1.intersect(boundingbox2)

is available for use outside a tool…

john

boundingbox_pick was added in a much later SU version and does (what I know of) not in any way take input from mouse coordinates. I don’t think there’s anything saying it needs to be used with a Tool or with user interaction other than the outdated docs.

I have only ever tried to use it in tools…

i.e. construct a bb.new from the diagonal defined by ip1 and ip2…

even then bb1.insect(bb2) was more robust for my purposes…

I would agree it’s bad documentation that neither of our expectations are met…

john

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.