NXKnowledge

Community Knowledge > Headless and Batch Automation

Headless Image Rendering in NX Batch: BatchShade Works (All 7 Methods) — but Run It in a Disposable Process

Regular view/image export (UF_DISP_create_image, Studio capture, the export-image dialogs) requires an interactive graphics session — in batch there is nothing to grab. The one API that renders without any display is UF_DISP_batch_shade, exposed in Python as:

ufs = NXOpen.UF.UFSession.GetUFSession()
ufs.Disp.BatchShade(filename, xSize, ySize, method)

Verified facts (NX 2606)

  • Deprecated but functional. The docstring says .. deprecated:: NX2406, yet it renders correctly in NX 2606 batch sessions.

  • Output format follows the file extension — TIFF, GIF, or JPEG per the UF docs. JPEG is the proven safe choice. (A .png extension produced TIFFWriteScanline errors in testing — don't assume PNG works.)

  • All 7 shade methods render: FLAT, GOURAUD, PHONG, PREVIEW, HIGH_QUALITY, PHOTO_REAL, RAYTRACE (members of NXOpen.UF.Disp.ShadeMethod). An 800x600 render of a simple solid is ~15-17 KB of JPEG and takes a few seconds.

    CORRECTION, added 2026-09-06: "renders" means "produces a file", NOT "produces that look." PHOTO_REAL and RAYTRACE come out essentially identical to PHONG: flat white background, no shadows, no environment reflection, no applied material. The seven outputs differ byte for byte (distinct MD5s) but not meaningfully in appearance.

    The sentence above is true as written and is the one a reader turns into "so PHOTO_REAL gives me a photoreal image", which is false. Stated at the scope actually tested: BatchShade is a headless viewport capture. It is the right tool for a thumbnail and the wrong one for a hero image.

    For genuine photorealism use Ray Traced Studio (Iray+), which needs an interactive session: headless it returns None builders and CreateHighEndRenderImage reports success while writing an empty directory. See the nx-photorealistic-rendering skill and nx-mcp/render/CAPABILITY-MATRIX.md.

  • It renders the displayed part — open the .prt you want rendered in the rendering process (Parts.OpenActiveDisplay). Unsaved state from some other session obviously isn't visible: save first, then render the file.

The crash warning

In testing, calling BatchShade inside a long-lived, reused batch session (one that had already opened/closed parts and run exports) killed the entire NX process instantly — a hard native crash, observed by attached sockets as WinError 10054, with no Python exception and no syslog goodbye. The exact same call in a fresh one-shot process ran flawlessly, seven methods in a row.

Given the API is deprecated and the failure mode is process death, the robust pattern is: never call BatchShade in a session you care about. Spawn a disposable run_journal.exe per render:

run_journal.exe render_image.py -args part.prt out.jpg 1024 768 HIGH_QUALITY

where render_image.py opens the part, calls BatchShade, prints a JSON result line, and exits. A crash then costs one render attempt, not your session. (Licensing note: with DUP_GROUP=UHD the extra one-shot session does not consume an additional seat — see the run_journal licensing article.)

Alternatives not yet evaluated

NXBIN ships purpose-built image extractors that may cover specific cases without a session: export_ugdwgimages.exe, partimageextractor.exe, PartModelViewImagePreviewGenerator.exe; and the Iray+ bulk-rendering sample (UGOPEN\SampleNXOpenApplications\Python\HighEndRendering) is a documented rendering pipeline. None were needed once BatchShade-in-isolation proved reliable.

Source: first-party finding, verified against NX 2606 on Windows 11, 2026-07-12; corroborates https://www.nxjournaling.com/content/exporting-jpeg-without-interactive-session; reference implementation https://github.com/chrisdamonmartini/nx-mcp (worker/render_image.py) · retrieved 2026-07-12