Exception when rendering blocks in wall based on sketch

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
dasmodel
Posts: 9
Joined: Mon Aug 02, 2021 10:25 am

Exception when rendering blocks in wall based on sketch

Post by dasmodel »

Hi all,

Version 0.19.
First post here, still learning FreeCAD through (mostly) YT videos and trial & error. Steep learning curve until you know what to expect and change the way you think about modeling (no experience whatsoever).

I'm modeling my house in BIM and ran into an issue. Please let me know if I've posted this in the wrong subsection.
I've drawn walls with a polyline sketch but when I try to create blocks, I get the following error:

Code: Select all

12:24:36  Traceback (most recent call last):
  File "/snap/freecad/22/opt/local/FreeCAD-0.19/Mod/Arch/ArchWall.py", line 850, in execute
    for edge in self.basewires[0].Edges:
<class 'AttributeError'>: 'list' object has no attribute 'Edges'
Tried to reproduce with a simple wall, when I create a wall without a sketch (base is WallTrace) it works without a problem and renders the blocks.
Creating a simple rectangle sketch, making it into a wall and adding blocks (height 50, length 210, joint 10mm) again results in the error.

1) Am I doing/using it wrong?
2) I had a look at the code, apparently there is a basewire in the object (which is the wall?), which is a list, but has no edges. The object probably isn't of a type that has edges (?).
3) Is there any way to inspect these objects (i.e. by using a breakpoint in a python script?)

I don't want to suggest this is a bug, however as a novice user I don't have the idea I'm doing something wrong or misusing concepts of the software.
Thanks! Hopefully in the future I'm able to figure out bugs, fix them and even do a pull request

Edit: Another (more pressing) issue is that my custom windows are not placed well in these walls (no hole cut etc..). It might be related since it works well when using it on a WallTrace based wall as described above. If potentially related, I won't make another thread for this.
Edit2: I solved the problem with the windows, I think the working plane was the issue.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Exception when rendering blocks in wall based on sketch

Post by paullee »

dasmodel wrote: Mon Aug 02, 2021 10:41 am First post here, still learning FreeCAD through (mostly) YT videos and trial & error. Steep learning curve until you know what to expect and change the way you think about modeling (no experience whatsoever).

I'm modeling my house in BIM and ran into an issue. Please let me know if I've posted this in the wrong subsection.
I've drawn walls with a polyline sketch but when I try to create blocks, I get the following error:

...

2) I had a look at the code, apparently there is a basewire in the object (which is the wall?), which is a list, but has no edges. The object probably isn't of a type that has edges (?).
3) Is there any way to inspect these objects (i.e. by using a breakpoint in a python script?)

I don't want to suggest this is a bug, however as a novice user I don't have the idea I'm doing something wrong or misusing concepts of the software.
Thanks! Hopefully in the future I'm able to figure out bugs, fix them and even do a pull request
Welcome !

There are a series of Youtube by @yorik, @regis etc. very good for Arch/BIM. And @yorik has also a series of written tutorial you could find :)

About the make Block feature, I remember but can't find out after a while of searching there is some discussion about some bug.

One thing I remember and happen just recently test is when the Block Length is not 0, makeBlock on a close loop Sketch return error.

Not sure if there has been a bug report in FreeCAD Mantis bugtracker, can you help find out ? Hope someone has a gap to have a look, until you want to fix something by yourself :D


In the meantime, you can use Draft Wire if you want to use makeBlock feature of ArchWall, which is more reliable in the meantime.

Good luck !
Screenshot from 2021-08-03 00-24-35.png
Screenshot from 2021-08-03 00-24-35.png (313.6 KiB) Viewed 2499 times
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

[PR] Re: Exception when rendering blocks in wall based on sketch

Post by paullee »

dasmodel wrote: Mon Aug 02, 2021 10:41 am 2) I had a look at the code, apparently there is a basewire in the object (which is the wall?), which is a list, but has no edges. The object probably isn't of a type that has edges (?).
OK, making a PR #4955 to fix this, anyone would like to test ? :)

Noted there are some cases as mentioned in original wiki that with some particular geometry, makeBlock may fail.

Code: Select all

                                    # only 1 wire (first) is supported
                                    if obj.Base.isDerivedFrom("Sketcher::SketchObject"):
                                        # if obj.Base is Sketch, self.baseWires[0] returned is already a list of edge
                                        baseEdges = self.basewires[0]
                                    else:
                                        # otherwise, it is wire
                                        baseEdges = self.basewires[0].Edges
                                    for edge in baseEdges:

ArchWall.py
(78.84 KiB) Downloaded 41 times
Screenshot from 2021-08-06 01-16-24.png
Screenshot from 2021-08-06 01-16-24.png (285.76 KiB) Viewed 2419 times
dasmodel
Posts: 9
Joined: Mon Aug 02, 2021 10:25 am

Re: Exception when rendering blocks in wall based on sketch

Post by dasmodel »

I had a quick look at the issues and couldn't find any, but now I see you've created one. Thanks for that very quick action!

What's the best way for me to test such pull requests? Checkout your repository and run it? Or is the PR also on the FreeCad repo as a branch?Currently I'm working from the default install (Ubuntu). If I'm a bit more familiar with the workflow it'll be easier to make my own changes and contribute if necessary.

Edit: the other issues I had were kinda related to the topological naming problem, so I've been introduced to that too now.
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

[PR] Re: Exception when rendering blocks in wall based on sketch

Post by paullee »

dasmodel wrote: Fri Aug 06, 2021 11:04 am What's the best way for me to test such pull requests? Checkout your repository and run it? Or is the PR also on the FreeCad repo as a branch?
That's easy :)

Find the directory of your installation, find ...usr/Mod/Arch/ArchWall.py (hopefully same path in your installation).

Back it up / rename it, copy the one in above post in this directory, restart FC (or importlib.reload( ArchWall.py) in the python console).

Good luck.

dasmodel wrote: Fri Aug 06, 2021 11:04 am Edit: the other issues I had were kinda related to the topological naming problem, so I've been introduced to that too now.
I have another experiment to 'temporarily' tackle that, if you are bold enough for adventure :)
dasmodel
Posts: 9
Joined: Mon Aug 02, 2021 10:25 am

Re: [PR] Re: Exception when rendering blocks in wall based on sketch

Post by dasmodel »

paullee wrote: Fri Aug 06, 2021 11:40 am
dasmodel wrote: Fri Aug 06, 2021 11:04 am What's the best way for me to test such pull requests? Checkout your repository and run it? Or is the PR also on the FreeCad repo as a branch?
That's easy :)

Find the directory of your installation, find ...usr/Mod/Arch/ArchWall.py (hopefully same path in your installation).

Back it up / rename it, copy the one in above post in this directory, restart FC (or importlib.reload( ArchWall.py) in the python console).

Good luck.

dasmodel wrote: Fri Aug 06, 2021 11:04 am Edit: the other issues I had were kinda related to the topological naming problem, so I've been introduced to that too now.
I have another experiment to 'temporarily' tackle that, if you are bold enough for adventure :)
Will try it that way soon. Does it matter which version I'm using (0.19)? I read on mantis that new issues should only be for 0.20. Perhaps I should be working with .20 anyway.

Regarding the topological naming problem; I think I read somewhere that this problem is addressed in 0.20 there, or am I mistaken. In that case, a temporary fix seems less effective. However, I do encounter the problem and have not solved it in my models so I'm not biased ;)
I'm using BIM (arch) to place windows and when I do, the faces change, screwing up references to completely other "rooms", I'm really doubting between learning 'workarounds' in my workflow or relying on a fix.
Let me know, I'm happy to try out your fix if I can find the time :)

Edit:
The files were in the path you supplied, however, those aren't used when I start FreeCad (same error), the stacktrace however provided the correct path of the exception of course... that's in a snap directory and I cannot modify that since

Code: Select all

mv: cannot move 'ArchWall.py' to 'ArchWall.py.bak': Read-only file system
. Cannot temper with the snap ;)

If I install freecad with apt I'm getting the 0.18 version iirc (at least, there's a 0.18 present somewhere...)
Will give it another go.
Ideally I'd load Freecad into pycharm or another IDE and put in some breakpoints, but I'm not sure if that's possible (and if Freecad is 100% python... part is c++ right?)
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [PR] Re: Exception when rendering blocks in wall based on sketch

Post by paullee »

dasmodel wrote: Fri Aug 06, 2021 12:36 pm
Will try it that way soon. Does it matter which version I'm using (0.19)? I read on mantis that new issues should only be for 0.20. Perhaps I should be working with .20 anyway.
...

Edit:
The files were in the path you supplied, however, those aren't used when I start FreeCad (same error), the stacktrace however provided the correct path of the exception of course... that's in a snap directory and I cannot modify that since ...
Do you want to try the AppImage? It runs on my Fedora w/o installation.

To unzip the single file into directory.

Code: Select all

FreeCADxxxxxAppImage  --appimage--extract
Find squashfs-root/AppRun to run FC. And you can find the same /usr/Mod... directory there.

Good luck :)
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [PR] Re: Exception when rendering blocks in wall based on sketch

Post by paullee »

dasmodel wrote: Fri Aug 06, 2021 12:36 pm Regarding the topological naming problem; I think I read somewhere that this problem is addressed in 0.20 there, or am I mistaken. In that case, a temporary fix seems less effective. However, I do encounter the problem and have not solved it in my models so I'm not biased ;)
I'm using BIM (arch) to place windows and when I do, the faces change, screwing up references to completely other "rooms", I'm really doubting between learning 'workarounds' in my workflow or relying on a fix.
0.20 is in development stage, that particular feature is not merged yet. So you download the latest 0.20_pre, you do not have that feature yet.

You may try @realthunder's branch, that has that feature.


Show your model, I guess you map the Window's underlying sketch to a face so you suffer the problem...
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [PR] Re: Exception when rendering blocks in wall based on sketch

Post by paullee »

paullee wrote: Thu Aug 05, 2021 5:24 pm OK, making a PR #4955 to fix this, anyone would like to test ? :)

Made a further PR PR #4958 to fix Sketch Base on single edge.

ArchWall.py
(79.08 KiB) Downloaded 43 times
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: [PR Merged] Re: Exception when rendering blocks in wall based on sketch

Post by paullee »

paullee wrote: Mon Aug 09, 2021 1:15 am Made a further PR PR #4958 to fix Sketch Base on single edge.

PR Merged :D

https://github.com/FreeCAD/FreeCAD/pull/4958
Post Reply