Nodes/Avatar Graph/Mesh Select Face By Sides
ComfyUI Node

Mesh Select Face By Sides

Grab every triangle, or every ngon, in one shot

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Mesh Select Face By Sides
  • BPY_OBJ
  • BPY_OBJ
number4
type
extendtrue

Cleaning up a mesh's topology usually starts with finding the offending faces, and doing that by eye on anything but a trivial mesh is a bad use of your time. This node does it by rule instead: select every face with a specific number of sides - every triangle, every quad, every stray n-gon - in a single pass. It's Blender's real bpy.ops.mesh.select_face_by_sides operator, exposed as a ComfyUI node inside Avatar Graph, the pack that runs actual Blender inside ComfyUI's process (via the bpy Python package) to build interactive 2D-to-3D avatars, auto-generating a node for every mesh operator Blender has.

How it works

It counts the sides on every face in the mesh and compares that count against the number you specify, using whichever comparison rule you pick - then selects (or adds to the selection) every face that matches. Feed it 3 with EQUAL and you've selected every triangle on the mesh; feed it 4 with GREATER and you've found every n-gon.

Inputs and outputs

  • BPY_OBJ - the mesh coming in from earlier in the graph.
  • number (default 4) - the side count to compare against.
  • type - the comparison: LESS, EQUAL, GREATER, or NOTEQUAL. Pair EQUAL with 3 to grab all triangles, or GREATER with 4 to grab all n-gons - the two most common cleanup targets.
  • extend (default true) - whether matching faces get added to whatever's already selected, or the selection is replaced entirely with the match. Turn it off if you want a clean, exact selection with nothing left over from an earlier step.

Output is a single BPY_OBJ - the same object, with the matching faces now selected.

Installing it

ComfyUI Manager: search "avatar-graph-comfyui", install, restart. Manually: cd ComfyUI/custom_nodes && git clone https://github.com/avatechai/avatar-graph-comfyui, then cd avatar-graph-comfyui && python -m pip install -r requirements.txt, then restart.

Python 3.10.x is the requirement to nail down before anything else - the bpy package this pack depends on needs that exact version, and the README pushes macOS/Linux users toward a dedicated conda environment (conda create --name comfyui python=3.10) instead of trusting an existing install. Windows users get a prebuilt ComfyUI + Python 3.10 zip linked in the README to unzip over their install before adding the pack via Manager. Restart with --enable-cors-header (macOS also wants --force-fp16) for the live 3D preview - without it, the graph still runs fine, you just save the model manually from the pack's Avatar Main Output node instead.

Common issues

If nodes from this pack aren't loading, check the Python version first - 3.10.x is required for bpy to have a working build at all. On this node specifically, the extend default catching people off guard is the most common gotcha: it's on by default, so if you're chaining several SelectFaceBySides calls expecting each one to replace the previous selection, you'll actually be accumulating matches across all of them unless you explicitly turn extend off. And it's worth remembering select_face_by_sides only counts sides - it has no concept of "good" or "bad" topology beyond that number, so a legitimate 5-sided face you intentionally modeled will get swept up in a GREATER-than-4 search along with the n-gons you actually meant to find. As with every mesh node in this pack, feeding it anything other than a real mesh BPY_OBJ from earlier in the same graph surfaces as a Blender-side error.

Categoryblender

Inputs (4)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
numberoptINT43–2147483647
typeoptCOMBO4 options: LESS, EQUAL, GREATER, NOTEQUAL
extendoptBOOLEANtrue

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ