import json import matplotlib.pyplot as plt # Load JSON data with open('GeometryAndSurfaceLinePlot.json', 'r') as file: data = json.load(file) # Extract points DEFAULT_VALUE = 91919191919.987654321 geometry = data.get('Geometry') if geometry: surfaces = geometry.get('Surfaces', []) else: surfaces = data.get('Surfaces', []) for surface in surfaces: curves = surface.get('OuterLoop', {}).get('Curves', []) points = [] previous_head_point = (DEFAULT_VALUE, DEFAULT_VALUE) previous_end_point = (DEFAULT_VALUE, DEFAULT_VALUE) for curve in curves: head_point_element = curve.get('HeadPoint', {}) end_point_element = curve.get('EndPoint', {}) head_point = (head_point_element['X'], head_point_element['Z']) end_point = (end_point_element['X'], end_point_element['Z']) if end_point == previous_head_point or end_point == previous_end_point: head_point, end_point = end_point, head_point points.append(head_point) points.append(end_point) previous_head_point = head_point previous_end_point = end_point # Plot points and lines if points: x_vals, z_vals = zip(*points) plt.plot(x_vals, z_vals, marker='o') # Extract surfaceline surface_Line = data.get('SurfaceLine') if surface_Line: surfaceLine = surface_Line.get('Points', []) surfpoints = [] for surfpoint in surfaceLine: surf_point = (surfpoint['X'], surfpoint['Z']) surfpoints.append(surf_point) # Plot surfaceline if surfpoints: x_vals, z_vals = zip(*surfpoints) plt.plot(x_vals, z_vals, marker='X', linestyle='dotted', linewidth='3') # Add labels and grid plt.xlabel('X') plt.ylabel('Z') plt.grid(True) plt.show()