[ArchWall] Fix: Better Info 0 Width Or 0 Height (#25878)

* [ArchWall] Fix: Better Info 0 Width Or 0 Height

Fix #25338

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [ArchWall] (Update) Fix: Better Info 0 Width Or 0 Height

Update - Following discussion at https://github.com/FreeCAD/FreeCAD/pull/25878

Fix #25338

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [ArchWall] (Update 2) Fix: Better Info 0 Width Or 0 Height

Update - Following discussion at #25878
Update 2 - Add translation

Fix #25338

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [ArchWall] (Update 3) Fix: Better Info 0 Width Or 0 Height
Update - Following discussion at #25878
Update 2 - Add translation
Update 3 - Follow comment on https://github.com/FreeCAD/FreeCAD/pull/25878#issuecomment-3724698834
         - Test of shape further relocated to after self.applyShape()

Fix #25338

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Improve warning message for ArchWall object

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
This commit is contained in:
paul
2026-01-15 02:22:47 +08:00
committed by GitHub
parent e4eebe50d0
commit d002e0cf46

View File

@@ -722,11 +722,20 @@ class _Wall(ArchComponent.Component):
# return
# walls can be made of only a series of additions and have no base shape
base = Part.Shape()
base = self.processSubShapes(obj, base, pl)
self.applyShape(obj, base, pl)
# Check if there is base, and if width and height is provided or not
# Provide users message below to check the setting of the Wall object
if base.isNull() and (self.noWidths or self.noHeight):
FreeCAD.Console.PrintWarning(
translate(
"Arch",
f"Cannot create or update {obj.Label} as its length, height or width is zero, and there are no solids in its additions",
)
+ "\n"
)
# count blocks
if hasattr(obj, "MakeBlocks"):
if obj.MakeBlocks:
@@ -932,6 +941,9 @@ class _Wall(ArchComponent.Component):
return data
length = obj.Length.Value
# TODO currently layers were not supported when len(basewires) > 0 ##( or 1 ? )
self.noWidths = False
self.noHeight = False
width = 0
# Get width of each edge segment from Base Objects if they store it
# (Adding support in SketchFeaturePython, DWire...)
@@ -971,10 +983,19 @@ class _Wall(ArchComponent.Component):
elif obj.Width:
widths = [obj.Width.Value]
else:
# having no width is valid for walls so the user doesn't need to be warned
# it just disables extrusions and return none
# print ("Width & OverrideWidth & base.getWidths() should not be all 0 or None or [] empty list ")
return None
## having no width is valid for walls so the user doesn't need to be warned
## it just disables extrusions and return none
## print ("Width & OverrideWidth & base.getWidths() should not be all 0 or None or [] empty list ")
#
# Having no width is valid for walls for a few cases, e.g.-
# - it has Base with solid
# - it has Additions
# A message could be provided in the Report panel for users
# to note if this is intended, then ignore extrusion afterwards,
# i.e. return None.
# Also should check Height.
self.noWidths = True
# return None
# Set 'default' width - for filling in any item in the list == 0 or None
if obj.Width.Value:
@@ -982,6 +1003,17 @@ class _Wall(ArchComponent.Component):
else:
width = 200 # 'Default' width value
# Check height
height = obj.Height.Value
if not height:
height = self.getParentHeight(obj)
if not height:
self.noHeight = True
# Check width and height is provided or not
if self.noWidths or self.noHeight:
return None
# Get align of each edge segment from Base Objects if they store it.
# (Adding support in SketchFeaturePython, DWire...)
aligns = []
@@ -1062,11 +1094,6 @@ class _Wall(ArchComponent.Component):
# Set 'default' offset - for filling in any item in the list == 0 or None
offset = obj.Offset.Value # could be 0
height = obj.Height.Value
if not height:
height = self.getParentHeight(obj)
if not height:
return None
if obj.Normal == Vector(0, 0, 0):
if obj.Base and hasattr(obj.Base, "Shape"):
normal = DraftGeomUtils.get_shape_normal(obj.Base.Shape)
@@ -1176,7 +1203,6 @@ class _Wall(ArchComponent.Component):
(Part.LineSegment, Part.Circle, Part.ArcOfCircle, Part.Ellipse),
):
skGeomEdgesI = geom.Geometry.toShape()
skGeomEdges.append(skGeomEdgesI)
for cluster in Part.getSortedClusters(skGeomEdges):
clusterTransformed = []
@@ -1186,7 +1212,6 @@ class _Wall(ArchComponent.Component):
edge.Placement = edge.Placement.multiply(
skPlacement
) ## TODO add attribute to skip Transform...
clusterTransformed.append(edge)
# Only use cluster of edges rather than turning into wire
self.basewires.append(clusterTransformed)