DXF Preview (from DXF)
DXF Preview
- dxf
- image
- mask
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) andline_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#F5F5F5default 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 themaskoutput 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.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| dxf | DXF | — | |
| size | INT | 512128–4096 | — |
| line_width | INT | 30–1000 | — |
| stroke_hex | STRING | #000000 | — |
| fill_enabled | BOOLEAN | false | — |
| fill_hex | STRING | #00A2FF | — |
| bg_enabled | BOOLEAN | true | — |
| bg_hex | STRING | #F5F5F5 | — |
| show_grid | BOOLEAN | true | — |
| transparent_bg | BOOLEAN | false | — |
| emit_mask | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |