From df97a3ad215519ad8ec5d2f0ef2e16d1575d3f9a Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 25 Nov 2024 12:24:39 +0100 Subject: [PATCH] BIM: Fix calculation of fence sections (#18042) * BIM: Fix calculation of fence sections The length and placement of fence sections was only correct if they were cut to size. * Fix required another change. --- src/Mod/BIM/ArchFence.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mod/BIM/ArchFence.py b/src/Mod/BIM/ArchFence.py index 4427046841..49901eeddb 100644 --- a/src/Mod/BIM/ArchFence.py +++ b/src/Mod/BIM/ArchFence.py @@ -147,10 +147,9 @@ class _Fence(ArchComponent.Component): obj.Shape = compound def calculateNumberOfSections(self, pathLength, sectionLength, postLength): - withoutLastPost = pathLength - postLength realSectionLength = sectionLength + postLength - return math.ceil(withoutLastPost / realSectionLength) + return math.ceil(pathLength / realSectionLength) def calculatePostPlacements(self, obj, pathwire, rotation): postWidth = obj.Post.Shape.BoundBox.YMax @@ -159,7 +158,7 @@ class _Fence(ArchComponent.Component): transformationVector = FreeCAD.Vector(0, - postWidth / 2, 0) return patharray.placements_on_path(rotation, pathwire, - obj.NumberOfSections + 1, + obj.NumberOfPosts, transformationVector, True) def calculatePosts(self, obj, postPlacements): @@ -204,11 +203,12 @@ class _Fence(ArchComponent.Component): sectionCopy = obj.Section.Shape.copy() - if sectionLength > sectionLine.length(): + if sectionLength > sectionLine.length() - postLength: # Part.show(Part.Shape([sectionLine]), 'line') sectionCopy = self.clipSection( sectionCopy, sectionLength, sectionLine.length() - postLength) + sectionCopy = Part.Compound([sectionCopy]) # nest in compound to ensure correct Placement sectionCopy.Placement = placement shapes.append(sectionCopy)