From 7adc157bdfa6a7d617cc1497810c1837bffded74 Mon Sep 17 00:00:00 2001 From: Gregor Riepl Date: Sat, 21 Feb 2026 13:03:59 +0100 Subject: [PATCH] Replace incompatible np.fromstring with np.frombuffer --- plugins/3MFReader/ThreeMFReader.py | 4 ++-- plugins/CuraEngineBackend/ProcessSlicedLayersJob.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/3MFReader/ThreeMFReader.py b/plugins/3MFReader/ThreeMFReader.py index 09143dde643..bec6c5f28ff 100755 --- a/plugins/3MFReader/ThreeMFReader.py +++ b/plugins/3MFReader/ThreeMFReader.py @@ -137,11 +137,11 @@ def _convertSavitarNodeToUMNode(savitar_node: Savitar.SceneNode, file_name: str mesh_data = savitar_node.getMeshData() - vertices_data = numpy.fromstring(mesh_data.getFlatVerticesAsBytes(), dtype=numpy.float32) + vertices_data = numpy.frombuffer(mesh_data.getFlatVerticesAsBytes(), dtype=numpy.float32) vertices = numpy.resize(vertices_data, (int(vertices_data.size / 3), 3)) texture_path = mesh_data.getTexturePath(scene) - uv_data = numpy.fromstring(mesh_data.getUVCoordinatesPerVertexAsBytes(scene), dtype=numpy.float32) + uv_data = numpy.frombuffer(mesh_data.getUVCoordinatesPerVertexAsBytes(scene), dtype=numpy.float32) uv_coordinates = numpy.resize(uv_data, (int(uv_data.size / 2), 2)) mesh_builder.setVertices(vertices) diff --git a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py index 02583a6e404..91bee3a9d3b 100644 --- a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py +++ b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py @@ -140,23 +140,23 @@ def run(self): extruder = polygon.extruder - line_types = numpy.fromstring(polygon.line_type, dtype = "u1") # Convert bytearray to numpy array + line_types = numpy.frombuffer(polygon.line_type, dtype = "u1") # Convert bytearray to numpy array line_types = line_types.reshape((-1,1)) - points = numpy.fromstring(polygon.points, dtype = "f4") # Convert bytearray to numpy array + points = numpy.frombuffer(polygon.points, dtype = "f4") # Convert bytearray to numpy array if polygon.point_type == 0: # Point2D points = points.reshape((-1,2)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly. else: # Point3D points = points.reshape((-1,3)) - line_widths = numpy.fromstring(polygon.line_width, dtype = "f4") # Convert bytearray to numpy array + line_widths = numpy.frombuffer(polygon.line_width, dtype = "f4") # Convert bytearray to numpy array line_widths = line_widths.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly. - line_thicknesses = numpy.fromstring(polygon.line_thickness, dtype = "f4") # Convert bytearray to numpy array + line_thicknesses = numpy.frombuffer(polygon.line_thickness, dtype = "f4") # Convert bytearray to numpy array line_thicknesses = line_thicknesses.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly. - line_feedrates = numpy.fromstring(polygon.line_feedrate, dtype = "f4") # Convert bytearray to numpy array + line_feedrates = numpy.frombuffer(polygon.line_feedrate, dtype = "f4") # Convert bytearray to numpy array line_feedrates = line_feedrates.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly. # Create a new 3D-array, copy the 2D points over and insert the right height.