[ArchWall] Multi-Material width return to Width Property (#27972)
* [ArchWall] Multi-Material width return to Width Property Fix #27804 - BIM: Wall with MultiMaterial assigned reports wrong Width * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [ArchWall] Multi-Material width return to Width Property (rev.) Fix #27804 - BIM: Wall with MultiMaterial assigned reports wrong Width (rev. Better algorithm - https://github.com/FreeCAD/FreeCAD/issues/27804#issuecomment-3986056788) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
+24
-21
@@ -870,7 +870,10 @@ class _Wall(ArchComponent.Component):
|
||||
obj.setEditorMode("ArchSketchPropertySet", 0)
|
||||
else:
|
||||
if hasattr(obj, "Width"):
|
||||
obj.setEditorMode("Width", 0)
|
||||
if hasattr(self, "multimaterialsWidth") and self.multimaterialsWidth:
|
||||
obj.setEditorMode("Width", ["ReadOnly"])
|
||||
else:
|
||||
obj.setEditorMode("Width", 0)
|
||||
if hasattr(obj, "Align"):
|
||||
obj.setEditorMode("Align", 0)
|
||||
if hasattr(obj, "Offset"):
|
||||
@@ -1053,7 +1056,7 @@ class _Wall(ArchComponent.Component):
|
||||
else:
|
||||
aligns = [obj.Align]
|
||||
|
||||
# set 'default' align - for filling in any item in the list == 0 or None
|
||||
# Set 'default' align - for filling in any item in the list == 0 or None
|
||||
align = obj.Align # or aligns[0]
|
||||
|
||||
# Get offset of each edge segment from Base Objects if they store it
|
||||
@@ -1106,25 +1109,25 @@ class _Wall(ArchComponent.Component):
|
||||
placement = None
|
||||
self.basewires = None
|
||||
|
||||
# build wall layers
|
||||
layers = []
|
||||
if hasattr(obj, "Material"):
|
||||
if obj.Material:
|
||||
if hasattr(obj.Material, "Materials"):
|
||||
thicknesses = [abs(t) for t in obj.Material.Thicknesses]
|
||||
# multimaterials
|
||||
varwidth = 0
|
||||
restwidth = width - sum(thicknesses)
|
||||
if restwidth > 0:
|
||||
varwidth = [t for t in thicknesses if t == 0]
|
||||
if varwidth:
|
||||
varwidth = restwidth / len(varwidth)
|
||||
for t in obj.Material.Thicknesses:
|
||||
if t:
|
||||
layers.append(t)
|
||||
elif varwidth:
|
||||
layers.append(varwidth)
|
||||
|
||||
# Check and build wall layers
|
||||
self.multimaterialsWidth = False
|
||||
layers = self.get_layers(obj)
|
||||
# check total width and update Wall's Width
|
||||
if layers:
|
||||
total = sum(layers)
|
||||
if obj.Width.Value != total:
|
||||
obj.Width = total
|
||||
# If there is no 0 (zero) in any of the layers, the total thickness
|
||||
# is driven by the multi-materials itself. Otherwise, user should
|
||||
# be able in any time change the Width and drive the total thickness
|
||||
# - in the latter case, Width property should not be changed to
|
||||
# ready-only.
|
||||
if not (0 in obj.Material.Thicknesses):
|
||||
self.multimaterialsWidth = True
|
||||
if self.multimaterialsWidth:
|
||||
obj.setEditorMode("Width", ["ReadOnly"])
|
||||
else:
|
||||
obj.setEditorMode("Width", 0)
|
||||
# Check if there is obj.Base and its validity to proceed
|
||||
if self.ensureBase(obj):
|
||||
if hasattr(obj.Base, "Shape"):
|
||||
|
||||
Reference in New Issue
Block a user