Python + Paraview.
I am facing an issue in conversion of a ascii geometrical data to Paraview VTK. Can you figure out and fix it?
Here is the code and error seen below. Ignore the cap_parser.py module.

#----------------- main.py -----------------#

import time

from cap_parser import parse_cap_file
from vtk_creator import create_diel_layers, create_diel_boxes, create_nets
from visualizer import group_and_color_objects, save_vtk, export_vtkjs

def main():
    cap_file_path = 'a.cap'
    output_vtk_path = 'a.png'
    output_vtkjs_path = 'a.vtkjs'
    color_by = 'layer'  # or 'net'
    
    print(f'{int(time.time())} Parsing cap file...')
    diel_layers, diel_boxes, nets = parse_cap_file(cap_file_path)
    print(f'{int(time.time())} Creating VTK objects - diel layers...')
    diel_layer_objects = create_diel_layers(diel_layers)
    print(f'{int(time.time())} Creating VTK objects - diel boxes...')
    diel_box_objects = create_diel_boxes(diel_boxes)
    print(f'{int(time.time())} Creating VTK objects - nets...')
    net_objects = create_nets(nets)

    print(f'{int(time.time())} Grouping and coloring objects...')
    plotter = group_and_color_objects(diel_layer_objects, diel_box_objects, net_objects, color_by)
    print(f'{int(time.time())} Saving VTK file...')
    save_vtk(plotter, output_vtk_path)

    # Collect all meshes for VTK.js export
    all_meshes = diel_layer_objects + diel_box_objects
    for net_boxes in net_objects.values():
        all_meshes.extend(net_boxes)
    
    export_vtkjs(all_meshes, output_vtkjs_path)

if __name__ == '__main__':
    main()

#----------------- vtk_creator.py -----------------#

import pyvista as pv

def create_diel_layers(diel_layers):
    diel_layer_objects = []
    for layer in diel_layers:
        eps, zl, zh = layer
        box = pv.Box(bounds=(0, 1, 0, 1, zl, zh))
        box.cell_data['eps'] = [eps] * box.n_cells
        diel_layer_objects.append(box)
    return diel_layer_objects

def create_diel_boxes(diel_boxes):
    diel_box_objects = []
    for box in diel_boxes:
        eps, xl, xh, yl, yh, zl, zh = box
        box = pv.Box(bounds=(xl, xh, yl, yh, zl, zh))
        box.cell_data['eps'] = [eps] * box.n_cells
        diel_box_objects.append(box)
    return diel_box_objects

def create_nets(nets):
    net_objects = {}
    for net_name, boxes in nets.items():
        net_objects[net_name] = []
        for box in boxes:
            if len(box) == 6:
                xl, xh, yl, yh, zl, zh = box
                box = pv.Box(bounds=(xl, xh, yl, yh, zl, zh))
                net_objects[net_name].append(box)
            else:
                print(f"    Skipping invalid box in net {net_name}: {box}")
    return net_objects



#----------------- visualizer.py -----------------#

import pyvista as pv

def group_and_color_objects(diel_layers, diel_boxes, nets, color_by='layer'):
    plotter = pv.Plotter()
    colors = ['red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'orange', 'purple', 'brown', 'pink']

    if color_by == 'layer':
        for i, layer in enumerate(diel_layers):
            color = colors[i % len(colors)]
            plotter.add_mesh(layer, color=color, opacity=0.5)
        for i, box in enumerate(diel_boxes):
            color = colors[i % len(colors)]
            plotter.add_mesh(box, color=color, opacity=0.5)
    elif color_by == 'net':
        for i, (net_name, boxes) in enumerate(nets.items()):
            color = colors[i % len(colors)]
            for box in boxes:
                plotter.add_mesh(box, color=color, opacity=0.5)

    return plotter

def save_vtk(plotter, file_path):
    plotter.show(screenshot=file_path)

def export_vtkjs(meshes, file_path):
    pv.export_vtkjs(file_path, meshes)


This the error I see:

lib/python3.9/site-packages/pyvista/plotting/plotter.py:159: UserWarning: 
This system does not appear to be running an xserver.
PyVista will likely segfault when rendering.

Try starting a virtual frame buffer with xvfb, or using
  ``pyvista.start_xvfb()``

  warnings.warn(
1731896610 Saving VTK file...
Segmentation fault