[ PR #3856 ] [ Bug ] Multi-material cannot be applied to a sketch-based wall

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

[ PR #3856 ] [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by Roy_043 »

In the version listed below applying a multi-material to a sketch-based wall no longer works. Only walls based on a Dwire correctly display multi-materials.

Test:
Open the attached file (created in V0.18) and recompute the document.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18738 (Git)
Build type: Release
Branch: master
Hash: f65a72deb71e8b2a18c849adc9a900c3d113d51b
Python version: 3.6.7
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Attachments
wall-multimat.FCStd
(31.19 KiB) Downloaded 56 times
Last edited by Roy_043 on Thu Sep 10, 2020 1:26 pm, edited 1 time in total.
paullee
Veteran
Posts: 5097
Joined: Wed May 04, 2016 3:58 pm

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by paullee »

Roy_043 wrote: Fri Nov 22, 2019 7:54 pm In the version listed below applying a multi-material to a sketch-based wall no longer works. Only walls based on a Dwire correctly display multi-materials.

Test:
Open the attached file (created in V0.18) and recompute the document.
Hmmm, I thought nobody using Sketch as Wall Base. Yes you do in previous posts.

Two things in my minds:-
  1. I thought I reported that Multi-Material do not support Sketch with > 1 base Wires , can't find it (a test file back in Sep 2017 ! See screenshot below )

    Code: Select all

                            if (len(self.basewires) == 1) and layers:
                                self.basewires = [self.basewires[0] for l in layers]
    
  2. I am adding support / fix to Sketch based Wall, e.g. correct export to IFC, 'multi-width', 'multi-align' - I thought Multi-Material for Sketch with 1 base Wires still works but it seems it break ( Support on 'complex sketch' > 1 base Wires was not added still. Limited time to consider yet ). See what can be done.

    In the meantime, a clumsy workaround is to do a numbers of wall based on sample Sketch / Wire manually and apply different materials and offset ...

    A remark, I had thought of Multi-materials support to > 1 baseWires, but how to set 'layer direction' for each wires is problematic ...
Screenshot from 2019-11-23 07-23-03.png
Screenshot from 2019-11-23 07-23-03.png (213.94 KiB) Viewed 2039 times
Screenshot from 2019-11-23 07-09-29.png
Screenshot from 2019-11-23 07-09-29.png (166.51 KiB) Viewed 2039 times
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by Roy_043 »

paullee wrote: Fri Nov 22, 2019 11:55 pm Hmmm, I thought nobody using Sketch as Wall Base.
This is actually more or less the standard. If the Wall command is used without a pre-selected base a sketch based wall is created.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by carlopav »

Yes, walls based on single segment sketch are also to me perceived as the default wall.
follow my experiments on BIM modelling for architecture design
paullee
Veteran
Posts: 5097
Joined: Wed May 04, 2016 3:58 pm

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by paullee »

Yes you both are correct, not aware of that single

I am always thinking about more complex use of sketch for Arch Wall :)
e.g.
https://forum.freecadweb.org/viewtopic.php?f=23&t=38703
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by Roy_043 »

While checking this issue I find that some work, perhaps related to this topic, has been done on ArchWall.py. But also that a new bug has been introduced:
A multi-material cannot be applied to a multi-segment wall if the alignment is left or right. The cause is rather obvious: the DraftGeomUtils.offsetWire function requires a widthList with the same length as the wire list, and the supplied widthList only contains a single item.

Maybe DraftGeomUtils.offsetWire was modified and this issue was never tested?

https://github.com/FreeCAD/FreeCAD/blob ... 1342-L1366

The code is a bit convoluted and hard to follow. Proposed fix:
Old (line 1344 and 1388):

Code: Select all

                                if layers:
                                    curWidth = [abs(layers[i])]
New (works for wire and sketch based walls):

Code: Select all

                                if layers:
                                    curWidth = []
                                    for n in range(edgeNum):
                                        curWidth.append(abs(layers[i]))
EDIT: the fix that was proposed before didn't work properly. Have added a new fix. It is confusing that the wire variable can be a list or a Part.Wire.
Last edited by Roy_043 on Wed Sep 09, 2020 9:31 am, edited 3 times in total.
paullee
Veteran
Posts: 5097
Joined: Wed May 04, 2016 3:58 pm

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by paullee »

Interested to have a look when there is a gap :D

There have been a numbers of PR merged that added difficulty to trace.

But maybe what do you expect with a Wall on Sketch + Multi-Material ?
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by Roy_043 »

paullee wrote: Tue Sep 08, 2020 5:00 pmwhat do you expect
This is not about new functionality, although I do have a wish list.
I expect a multi segment wall to support left/right alignment as well as a multi-material. IOW what worked in V0.18 should still work in V0.19. Try changing the alignment of Wall003 or Wall004 in the attached file to Left and then recompute. Result:
19:29:30 Traceback (most recent call last):
File "D:\BKG_Tmp\FreeCAD_0.19_Last\Mod\Arch\ArchWall.py", line 785, in execute
extdata = self.getExtrusionData(obj)
File "D:\BKG_Tmp\FreeCAD_0.19_Last\Mod\Arch\ArchWall.py", line 1370, in getExtrusionData
basewireOffset=off)
File "D:\BKG_Tmp\FreeCAD_0.19_Last\Mod\Draft\draftgeoutils\offsets.py", line 331, in offsetWire
if widthList > 0:
<class 'IndexError'>: list index out of range
Attachments
wall-multimat-revisited.FCStd
(37.98 KiB) Downloaded 35 times
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by Roy_043 »

I'll try to write a unit test for this.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: [ Bug ] Multi-material cannot be applied to a sketch-based wall

Post by vocx »

Roy_043 wrote: Tue Sep 08, 2020 6:01 pm I'll try to write a unit test for this.
Please, do. The entire Arch Workbench needs better unit tests, otherwise the code cannot be checked if core functions are modified.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Post Reply