Changing Object Bounds/Size upon a Button Press

Hi. Could anyone suggest me, is it possible to hide objects from the canvas? I wasn’t able to find such a method myself.

What I tried:

  1. Mass selecting relays, deleting them, and returning them with an undo button. But it’s going to work only for the last undo. I tried selecting and cutting them out, but pasting them back shifts their positions and causes them to lose their groups;
  2. Editing their bounds to minimise their footprint. I can read bounds from them, but I wasn’t able to set them no matter what I did. As I show with the panel called “b”, objects can exist with bounds below the minimal user-settable level.

What should I do? Is there a way to hide/delete relays from a canvas, while making this process easily reversible?

hide_relays_test.gh (10.6 KB)

I’d gotten a hint by calling obj.Attributes.Bounds()

It’s represented by RectangleF, which itself is present in System.Drawing, so…

Setting Height to 4 and Width to 10 makes them look like nice small dots while also displaying the group name, what I find ideal for my particular workflow:

Setting Height and Width to 0 displays their name should they have one, but the relays themselves get almost invisible:

Setting Width to -2 and Height to 0 displays a tiny red cross, but doesn’t print a canvas drawing error:

Upon reloading the file, the relays return to normal. Upon expiring the layout of their attributes, the relays return to normal.

I understand that it’s not how things are supposed to work and this approach is suboptimal. It, however, works for me. I’ll update the post should I find any instabilities.

hide_relays_test v2.gh (11.5 KB)

If relay’s position is critical for you, you can keep Height at 16 and Width at 10 or -2:

This will ensure that the straightened wires remain straight (like the one coming out of A*B).

Or you can play with Y offsets:

hide_relays_test v2.1 (position-preserving).gh (11.8 KB)