ComfyUI Node

BBoxSnap

The invisible constraint that makes panel edges behave

By bmad4ever·Created 12 months ago·Updated 2 months ago· 41
BBoxSnap
  • canvas
  • BBOX_SNAP
snap_iffalse

Some nodes produce geometry; this one produces a rule. BBoxSnap takes a canvas polygon and returns a BBOX_SNAP object - a constraint that other nodes in the pack use when adjusting panels, telling them "here's where the page edges are and how to treat them." Its description is candid: it's an "optional constraint for the 'Adjust Panel' operation."

The workflow it exists for is page margin and spacing control. When you adjust a panel near the page boundary, you usually want one of two behaviors: either the panel edge stays glued to the page edge (so growing it leaves a margin between panels instead of pushing through), or the panel edge is moved freely and only its current position matters. That choice is exactly what the snap_if toggle encodes, and the tooltip spells out the two use cases directly.

How it works

The snap_if flag picks one of two snapping semantics:

  • snap_if on - polygon vertices that coincide with the canvas edges are not moved away from those edges. Their source points may move, but the vertices stay on the page boundary. The tooltip's use case: "add extra space between panels."
  • snap_if off - only vertices that are currently on the box get moved. Use case per the tooltip: "add the page's margins."

So you don't snap a polygon to a box; you snap a box to a mode of behavior that downstream adjustment nodes respect. The canvas is the rectangle (typically from Canvas Panel) that defines the page.

The inputs and output

  • canvas - a POLYGON rectangle defining the page.
  • snap_if - the boolean mode switch described above (the widget labels it "on a bbox's edge" / "not on a bbox's edge").

Output: one BBOX_SNAP.

Installing it

Part of comfyui-panels - Manager, search "comfyui-panels", or:

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_panels

Restart, install deps (shapely, matplotlib, opencv-python), no models.

Where people get burned

The node looks useless on its own because nothing visibly happens - the constraint only does work when consumed by an Adjust Panel operation, so if you're not feeding this into one, you'll see no effect and assume it's broken. And the snap_if polarity is easy to flip in your head: re-read the tooltip before wiring it, because "on" and "off" mean opposite things for margin-vs-spacing. It's a subtle utility for a specific workflow, not something you'll need on every page.

CategoryBmad/Panels

Inputs (2)

NameTypeDefaultDescription
canvasPOLYGON
snap_ifBOOLEANfalseIf True, polygons points coordinates coinciding withthe given canvas' edges are not changed; their source points may still be moved, but do so without leaving the canvas' edges. This can be used to add extra space between panels. If False, only point coordinates that are on the box are moved. This can be used to add the page's margins.

Outputs (1)

NameTypeDescription
BBOX_SNAPBBOX_SNAP