Build a results scene
Demonstrates how a generic results field can be passed to the viewer wrapper.

The model before it is solved: its parts, supports (red) and loads (blue).
![The result: the deformed shape coloured by displacement (magnitude [mm])](/examples/core-concepts/viewers/results-scene-results.webp)
The deformed shape, coloured by displacement (magnitude [mm]), in xfea’s 3D viewer.
Open in 3D turn it, cut it, pick any field: in xfea's viewer, in your browser
The script
Section titled “The script”examples/scripts/02_core_concepts/viewers/results_scene.py. Run it from the repository with uv run python examples/scripts/02_core_concepts/viewers/results_scene.py, or, with xfea-examples installed, xfea-examples run 02_core_concepts/viewers/results_scene.py.
from xfea.problem import Problemfrom xfea.problem import StaticStepfrom xfea.results import DisplacementFieldResultsfrom xfea_examples import out_dirfrom xfea_examples import show_viewerfrom xfea_examples.models import cantilever_beam_model
tip_load = -1_000 # [N] downward tip force
model, _, tip_nodes, _, _, _ = cantilever_beam_model(name="results_scene")
problem = model.add_problem(Problem(name="viewer_results_problem"))step = problem.add_step(StaticStep(name="service"))step.add_uniform_forcefield(nodes=tip_nodes, z=tip_load, load_case="service")
disp = DisplacementFieldResults()step.add_field_outputs([disp])
problem.analyse_and_extract(path=out_dir(model.name), verbose=True)show_viewer(model, results={disp: "z"}, units="mm")© 2026 Francesco Ranaudo · Text and pictures CC BY 4.0 · Code Elastic License 2.0 · how to reuse them