Nodes/ComfyUI_DAO_master/DXF Preview (from DXF)
ComfyUI Node

DXF Preview (from DXF)

DXF Preview

By orion4d·Created about a year ago·Updated 12 months ago· 11
DXF Preview (from DXF)
  • dxf
  • image
  • mask
size512
line_width3
stroke_hex#000000
fill_enabledfalse
fill_hex#00A2FF
bg_enabledtrue
bg_hex#F5F5F5
show_gridtrue
transparent_bgfalse
emit_maskfalse

A DXF document is just numbers: coordinates, radii, line widths. You can't look at it, and ComfyUI definitely can't - ComfyUI speaks in image tensors. DXF Preview is the bridge. It renders your in-memory DXF into an actual IMAGE tensor so you can see what the geometry looks like, and it does it with a surprising amount of control: stroke width, fill color, background, grid lines, even a mask output. If you're building DXF shapes in this pack and never use this node, you're working blind.

How it works

Notably, this node doesn't use CairoSVG or any of the SVG tooling the pack ships - it has its own internal PIL-based renderer in dxf_utils.py. The process: it computes the drawing's bounding box, maps every entity's world coordinates into a square image (with a margin so shapes don't sit flush against the edge), and draws the geometry onto a PIL image. Fills are handled with an even-odd parity mask, which means overlapping closed shapes fill in that XOR-style "alternating regions" way rather than painting over each other. Then the result is converted to ComfyUI IMAGE and MASK tensors.

Inputs that matter

Most of these you'll leave alone, but a few earn their place:

  • dxf - the drawing to render. Wire this from any DXF-producing node.
  • size (default 512, up to 4096) - render resolution. 512 is fine for a quick look; bump it before you actually save or feed the result to a model.
  • stroke_hex (default #000000) and line_width (default 3) - the color and thickness of the outline.
  • fill_enabled + fill_hex - turn on a fill color (default off, which is what you want for cut paths).
  • bg_enabled + bg_hex - the light-gray #F5F5F5 default background.
  • show_grid (default on) - a reference grid. Nice while iterating, annoying in final output.
  • transparent_bg - returns an RGBA image with transparency instead of the flat background.
  • emit_mask - controls whether the mask output actually carries the shape silhouette or just a zero tensor.

Outputs

Two outputs: image (an IMAGE) and mask (a MASK). Wire image into a preview, a Save Image, or further image processing. The mask is only meaningful when emit_mask is on - it's the shape's silhouette, useful for compositing or as an inpaint mask. Wire image and mask together into an inpainting setup and you've got a raster pipeline around a vector source.

How to install

Part of the orion4d/ComfyUI_DAO_master pack - install the pack and this comes along:

cd ComfyUI/custom_nodes
git clone https://github.com/orion4d/ComfyUI_DAO_master.git
pip install -r requirements.txt   # ezdxf is the one this node needs

Restart ComfyUI afterwards. No models to download.

Common issues

The renderer needs a valid bounding box; if your drawing is a single point or an empty document, you'll get an empty canvas with the background color - that's expected, add some geometry first. If emit_mask is off, the mask output is a black zero tensor; that trips people up when they wire the mask into something and get nothing. And remember the fill is even-odd: overlapping filled shapes will punch holes in each other rather than stacking. If that's not what you want, restructure the geometry so shapes don't overlap.

CategoryDAO_master/DXF/Utils

Inputs (11)

NameTypeDefaultDescription
dxfDXF
sizeINT512128–4096
line_widthINT30–1000
stroke_hexSTRING#000000
fill_enabledBOOLEANfalse
fill_hexSTRING#00A2FF
bg_enabledBOOLEANtrue
bg_hexSTRING#F5F5F5
show_gridBOOLEANtrue
transparent_bgBOOLEANfalse
emit_maskBOOLEANfalse

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK