From aa1913b1b1884395cbede53ad69baa262af87045 Mon Sep 17 00:00:00 2001 From: Dusten Hubbard Date: Wed, 14 Oct 2026 21:59:18 -0500 Subject: [PATCH 1/2] fix(ztrace): give each from-object ztrace its own point list createZtrace defaulted z_points to a list and appended to it. A default argument is created once, so after the first ztrace made from an object, the default held that object's points. The next call in the same session saw a non-empty list: it named the ztrace after the object with no "_zlen", generated no points, and replaced any ztrace of that name with the first object's points. The default is now None, and each call starts from an empty list. --- PyReconstruct/modules/datatypes/series.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PyReconstruct/modules/datatypes/series.py b/PyReconstruct/modules/datatypes/series.py index 8cecde704..82994ae32 100644 --- a/PyReconstruct/modules/datatypes/series.py +++ b/PyReconstruct/modules/datatypes/series.py @@ -925,7 +925,7 @@ def createZtrace( self, obj_name : str, cross_sectioned : bool = True, - z_points : list = [], + z_points : list = None, ztrace_color : tuple = (0, 0, 0), log_event=True ): @@ -938,6 +938,11 @@ def createZtrace( ztrace_color (tuple): color of ztrace to display in field log_event (bool): True if event should be logged """ + # A fresh list per call: a shared mutable default would let the points + # generated for one object leak into the next from-object ztrace. + if z_points is None: + z_points = [] + if not z_points: # append name with "_zlen" if creating from obj ztrace_name = f"{obj_name}_zlen" else: # use tracing_trace name From 1fe73022d482f702114c4dadcab22163dae7531d Mon Sep 17 00:00:00 2001 From: Dusten Hubbard Date: Wed, 14 Oct 2026 22:03:49 -0500 Subject: [PATCH 2/2] fix(ztrace): use the object's alignment for a from-object ztrace createZtrace chose the alignment with "if not z_points", but by then the from-object branch had already filled z_points, so the test was always false and every ztrace took the current alignment. It now records whether the call is from an object once, before any points are added, and uses that for the name, the point generation, and the alignment. --- PyReconstruct/modules/datatypes/series.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PyReconstruct/modules/datatypes/series.py b/PyReconstruct/modules/datatypes/series.py index 82994ae32..f5a3881f7 100644 --- a/PyReconstruct/modules/datatypes/series.py +++ b/PyReconstruct/modules/datatypes/series.py @@ -943,7 +943,11 @@ def createZtrace( if z_points is None: z_points = [] - if not z_points: # append name with "_zlen" if creating from obj + # Decide this once, before the from-object branch below fills z_points: + # the alignment choice at the end must not see the filled list. + from_object = not z_points + + if from_object: # append name with "_zlen" if creating from obj ztrace_name = f"{obj_name}_zlen" else: # use tracing_trace name ztrace_name = obj_name @@ -954,7 +958,7 @@ def createZtrace( del(self.ztraces[ztrace_name]) if log_event: self.addLog(ztrace_name, None, "Updated ztrace") - if not z_points: # generate points from already traced object if non provided + if from_object: # generate points from already traced object if non provided ## If create on midpoints, make one point per section @@ -996,7 +1000,7 @@ def createZtrace( ) ## Assign alignement to ztrace - if not z_points: # use obj alignment + if from_object: # use obj alignment alignment = self.getAttr(obj_name, "alignment") else: # use current alignment alignment = self.alignment