Proposed algorithm for window added in wall, movement

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Evaggelos
Posts: 14
Joined: Mon Dec 28, 2020 4:55 pm
Location: Thessaloniki, Greece

Proposed algorithm for window added in wall, movement

Post by Evaggelos »

Greetings everybody! This the first time I am posting in this forum!
First of all I want to congratulate everybody who is contributing, one way or another, in the development of this software.
It has being a short time since I begun experimenting with FreeCad, and especially with the BIM and TechDraw workbenches. There are some thoughts I am having on various matters, and I will begin with door/window moving along with their host wall. Searching the forum I found that I am not the only one who is troubled by this.
My thoughts are the following:
When an object is added to an other selected one, along with the Host field that is created in the Property View, a Guest field must by created too, so that for every object we can check its Host and Guest ones.
For example, we create the Wall1. Then we create Wall2 and add this to Wall1. Then we create Window1 and add this to Wall2. Finally we create Window2 and add this to Wall2. The Host – Guest structure directly expressed for the four objects is the following:

Wall1.Hosts = []
Wall1.Guests = [Wall2]

Wall2.Hosts = [Wall1]
Wall2.Guests = [Window1, Window2]

Window1.Hosts = [Wall2]
Window1.Guests = []

Window2.Hosts = [Wall2]
Window2.Guests = []


By implicit, Window1 and Windows2 are also guests to Wall1. So the Host – Guest structure directly and indirectly expressed for the four objects is the following:

Wall1.Hosts = []
Wall1.Guests = [Wall2, Window1, Window2]

Wall2.Hosts = [Wall1]
Wall2.Guests = [Window1, Window2]

Window1.Hosts = [Wall2]
Window1.Guests = []

Window2.Hosts = [Wall2]
Window2.Guests = []


When an object is moved, then its direct and indirect Guest objects must by moved along with it, but not the host objects. In the above example:
  • if we move Wall1, then Wall2, Window1 and Window2 must also move along.
    If we move Wall2, then Window1 and Window2 must also move along, but Window1 must be unmoved.
    If we move Window2, then all other objects must remain unmoved.
To demonstrate the above I wrote a small python program, witch I am attaching to this post as Wall_Window_Move.txt.
I am waiting for your thoughts.
Attachments
Wall_Window_Move.txt
(3.04 KiB) Downloaded 46 times
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Proposed algorithm for window added in wall, movement

Post by carlopav »

Welcome to the forum!
As many others i've been spending quite a lot of time on the subject :) So I appreciate every effort in this direction.
You can checkout my topic on BIM experimental tools to see the direction i've been experimenting.
Just a note on things that you should consider IMO:
- the position of an object is affected by its Placement property;
- the position of a wall is dependent on the object the wall is based upon: a movement of that object moves the wall too;
- a multi-segment wall can be based on a wire or a complex sketch: a modification of the base object that does not change the base object's Placement is not easy to be detected in the wall object (follow here Paullee's experiments on sketchArch module and windows/doors attachments);
- in FreeCAD there is a special object that visually moves its grouped children, it's called GeoFeatureGroup (that's what I was experimenting with);
- in IFC a window is not necessairly contained in a wall, but more often associated with a room (not sure about that);
- freeCAD objects do not contain move functions: it is the move function that changes the object Placement "from outside", then the object realizes that using its onChanged method;
- in your example it seems that you are considering walls nested one into another, but if I recall correctly, also yorik was not happy about that and encouraged disabling the option to merge walls automatically: to me it's quite annoying because it's complicated to select them and edit them further.

just some random thoughts that are not meant to discourage you, but to get you onboard more quickly!
have fun and feel free to ask what you need :)
see ya!
follow my experiments on BIM modelling for architecture design
Evaggelos
Posts: 14
Joined: Mon Dec 28, 2020 4:55 pm
Location: Thessaloniki, Greece

Re: Proposed algorithm for window added in wall, movement

Post by Evaggelos »

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23323 (Git)
Build type: Release
Branch: master
Hash: 512d5c6141aec52b6eecc67370336a28fde862a6
Python version: 3.8.6
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: Greek/Greece (el_GR)

I really appreciate the time you took to provide such a detailed reply on a sort notice!
The truth is that I haven’t looked at the experimental tools yet, but I will devote the proper time to test them. Thank you for pointing me at this direction.
Now as for the scope of my posting, as the title suggests, is this:
We create a wall, draw a window in it, then we move the wall and we want the window to move with the wall no matter what. This simple, yet so fundamental, task is not working correctly in the latest 0,19 version.
My intention is not to provide a new paradigm for wall design and I am glad to hear the developers do not like the concept of nested walls, I don’t like it either :D . What I am suggesting, in my example, is that a window must move along with it’s host wall, even if this wall is nested in an other one.
I know that a wall can be created and placed with various methods, but to my understanding a window insertion point is it’s bottom – left corner. This thing can simplify the coordination of the window movement, regardless of the way its host wall moved (draw move or placement).
The concept of host – guests lists for windows can be further expanded. For example a window can have guest objects (i.e. a window cornice) and when this window moves this objects follow that movement.
Evaggelos
Posts: 14
Joined: Mon Dec 28, 2020 4:55 pm
Location: Thessaloniki, Greece

Re: Proposed algorithm for window added in wall, movement

Post by Evaggelos »

The python program I attached in my first posting is a simple, and I admit a rather crude, way to investigate the success of the host – guest list concept to allow for successful coordination of a window movement along with its host wall.
In my program code I don’t take account of the various ways a wall is created. I just assume that is placed via its insertion point.
The same thing goes for the windows. But in case its is more close to reality, because a window has its bottom left corner as insertion point.
Readers are encouraged to modify and “play” with the program, and even test what I suggested in my previous post, that is to create a window cornice choose a window as its host and track the movement of objects.
paullee
Veteran
Posts: 5120
Joined: Wed May 04, 2016 3:58 pm

Re: Proposed algorithm for window added in wall, movement

Post by paullee »

I haven't looked at the script but the concept make sense i think :) Difficulty is the relative Placement of both objects.

Some experiment ongoing to make objects like Arch Windows, Arch Equipment 'attach' to another object like ArchWall, so when an ArchWall move, rotate etc., the Arch Window / Equipment stick to the 'position' user suppose it to be relative to the Wall - [ Comments Request ] Intuitive Automatic Windows/Doors + Equipment Placement
Evaggelos
Posts: 14
Joined: Mon Dec 28, 2020 4:55 pm
Location: Thessaloniki, Greece

Re: Proposed algorithm for window added in wall, movement

Post by Evaggelos »

Let me be more precise on how I envision the implementation of the host – guest idea in Freecad:
1)The user creates a wall. That creation may come from a line, a wire or completely free. By convention Freecad assigns the first point of the line, the wire or the wall as the reference point. The coordinates of this point are recorded and stored.
2)The user creates a window. By convention Freecad assigns the bottom - left point as the reference point. The coordinates of this point are recorded and stored.
3)The user assigns the wall to be the host of the window.
4)For both the wall and the window Freecad updates the host and guest lists.
5)The user moves the wall. To my understanding, in BIM workbench this can be accomplished via the draw move or the placement property. Either way, inside both the draw move or placement functions, FreeCad can record the new reference point of the wall. Now Freecad calculates the relative movement (i.e. RX = X’start – Xstart).
6)Freecad goes through the wall guest list and enforces the same realative movement on the guest objects.
That is what the script I wrote does (more or less).

The advantages of this approach:
1)Simple and transparent concept.
2)Can easily integrate to the existing source code.
3)Not computer intensive procedure. The extra data stored are minimal. The procedure targets only the needed objects and doesn't expand in the whole model.

There is the pending thing of rotational movement. I am already working on this.
I think that once the rotational movement is dealt, and it will be dealt, this solution will be airtight.
User avatar
johnwang
Veteran
Posts: 1382
Joined: Sun Jan 27, 2019 12:41 am

Re: Proposed algorithm for window added in wall, movement

Post by johnwang »

I like the idea that a window is part of the wall, not a separate object. The window is alway located with an offset to the wall origin (lower left corner) . Door is the same. It is more important when you only make wall frame. Door and window are just an opening in the frame.

Link is too general, it covers a wide range of object than window. It is hard to ask a general tool to meet special need of window. Use wall as a host, could provide more function for window.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
Evaggelos
Posts: 14
Joined: Mon Dec 28, 2020 4:55 pm
Location: Thessaloniki, Greece

Re: Proposed algorithm for window added in wall, movement

Post by Evaggelos »

Yes it is very helpful to consider the window as a part of a wall, and the nice think is that you can stop considering it part of the wall anytime you like. You can go to the window properties and uncheck the wall as its host.
The solution I provide can also expand to every BIM / Arch object, as long as they have host and guest fields in their properties.
The code will be incorporated in the move, position and rotate functions. Now these functions will not only move or rotate the object, but will go thru the list of guest objects and enforce the same movement or rotation on them.
Evaggelos
Posts: 14
Joined: Mon Dec 28, 2020 4:55 pm
Location: Thessaloniki, Greece

Re: Proposed algorithm for window added in wall, movement

Post by Evaggelos »

You asked and I delivered :D
Lets see how to rotate a window along with its host wall:
1)The user creates a wall. That creation may come from a line, a wire or completely free. By convention Freecad assigns the first point of the line, the wire or the wall as the reference point. The coordinates of this point are recorded and stored.
2)The user creates a window. By convention Freecad assigns the bottom - left point as the reference point. The coordinates of this point are recorded and stored.
3)The user assigns the wall to be the host of the window.
4)For both the wall and the window Freecad updates the host and guest lists.
5)The user rotates the wall about the z axis by an angle of θ.
6)Freecad calculates the new position of the reference point of the wall:
- if the rotation point coincides with the wall reference point, this will remain unchanged.
- if the rotation point don’t coincide with the wall reference point then the new position of the wall
reference point can be calculated:
x’ = x cosθ – y sinθ
y’ = x sinθ + y cosθ
z’ = z
7)Freecad calculates the new position of the reference point of the window:
- if the rotation point coincides with the window reference point, this will remain unchanged.
- if the rotation point don’t coincides with the window reference point then the new position of the
wall reference point can be calculated:
x’ = x cosθ – y sinθ
y’ = x sinθ + y cosθ
z’ = z
8)Freecad calls the move function and moves the window from the old reference point to the new one.
9)Freecad calls the rotation function and rotates the window at the angle of θ, using as rotation point the point that was calculated in step 7.
paullee
Veteran
Posts: 5120
Joined: Wed May 04, 2016 3:58 pm

Re: Proposed algorithm for window added in wall, movement

Post by paullee »

Looks promising :D

Do you think it would works with an ArchWall with multiple edges in Sketch like the demonstration model file I am using in the SketchArch experiment ?

The ArchWindow has a Hosts property which link to the ArchWall. Likewise, the ArchEquipment has a Host (no 's') property which currently also link to the Arch Wall.

Thanks for looking into this matter.
Test_ Link_ ArchWindow_ 04j.FCStd
(325.87 KiB) Downloaded 34 times
Screenshot from 2020-12-28 00-33-18.png
Screenshot from 2020-12-28 00-33-18.png (278.86 KiB) Viewed 1151 times
Post Reply