Arch Window from Python - hinge problems and edge IDs

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
olof
Posts: 11
Joined: Thu Sep 04, 2014 7:40 am

Arch Window from Python - hinge problems and edge IDs

Post by olof »

Hi,

I have to deal with leaded windows in old houses like this quite a bit:
fc_window.jpg
fc_window.jpg (174.26 KiB) Viewed 621 times
So I've written a script to generate sketches which are then fed into ArchWindow.makeWindow.

It all works fine until I try to add a hinge to to the top right casement (I know there isn't one in the photo above but added one for testing). The bottom left casement hinge works fine. The casements are added in the order bottom left, bottom right, top left, top right so the top right casement has the wires and edges with the highest ID numbers.

Code: Select all

Traceback (most recent call last):
  File "/Users/rwoodhouse/Desktop/FreeCAD.app/Contents/Resources/Mod/Arch/ArchWindow.py", line 1223, in execute
    shapes = self.buildShapes(obj)
  File "/Users/rwoodhouse/Desktop/FreeCAD.app/Contents/Resources/Mod/Arch/ArchWindow.py", line 1050, in buildShapes
    e = obj.Base.Shape.Edges[hinge]
<class 'IndexError'>: list index out of range
When I open the sketch I see 268 lines but when I use the python console to look at the object it tells me there are 168 edges in the sketch:

Code: Select all

>>> len(App.ActiveDocument.getObject("Sketch001").Shape.Edges)
168
I've attached an example model with both a working window (with just the lower left casement having a hinge) and a broken window where I tried to create a hinge for the top right casement.

Any thoughts?

Thanks.

OS: macOS 10.13
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16110 (Git)
Build type: Release
Branch: (HEAD detached at 0.18.1)
Hash: f7dccfaa909e5b9da26bf50c4a22ccca9bb10c40
Python version: 3.6.7
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
Attachments
fc_window_hinge_error.FCStd
(104.15 KiB) Downloaded 25 times
chrisb
Veteran
Posts: 53933
Joined: Tue Mar 17, 2015 9:14 am

Re: Arch Window from Python - hinge problems and edge IDs

Post by chrisb »

This is just a shot in the dark.

The first two messages when opening the file are:

Code: Select all

Upgrading Window IfcRole property to IfcType
Upgrading Window001 IfcRole property to IfcType
So perhaps it's the MacOS version, see https://forum.freecadweb.org/viewtopic.php?f=39&t=36072.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
olof
Posts: 11
Joined: Thu Sep 04, 2014 7:40 am

Re: Arch Window from Python - hinge problems and edge IDs

Post by olof »

Thanks chrisb for your thought but I don't think it is that but I do think I've found out what the problem is.

I'm using construction lines to keep things in the right place. This works fine until we come hinges. When creating a sketch the construction lines add to the edge count. However when complete the construction lines are ignored and do not add to the count of edges.

I think I'll tackle this by adding a function to proxy for the Sketch addGeometry method that keeps a track of the "visible only" and "all" line counts.
chrisb
Veteran
Posts: 53933
Joined: Tue Mar 17, 2015 9:14 am

Re: Arch Window from Python - hinge problems and edge IDs

Post by chrisb »

I don't think that any tool outside of Sketcher knows the construction geometry, but I am not at all familiar with Arch.

If you need the construction lines only for the proper alignment, there are other possibilities like making straight lines tangent, although they don't even touch, or aligning points vertically or horizontally, or setting a point-on-line constraint with an endpoint on another line. Again, the point doesn't have to lie on that line segment, it is positioned on the infinite prolongation of the line.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
olof
Posts: 11
Joined: Thu Sep 04, 2014 7:40 am

Re: Arch Window from Python - hinge problems and edge IDs

Post by olof »

I'm using construction lines so that I can use equality constraints to keep things like width of the lead came between the glass panes the same width, with the aim of making it easy to tweek a window's geometry by just modifying a few named constraints.

In heindsight it is rather obvious that the end Shape wouldn't know about the construction geometry...
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Arch Window from Python - hinge problems and edge IDs

Post by yorik »

Indeed the end shape doesn't know about construction geometry...
Not sure why your hinge fails though, I'll have a look at your file
Post Reply