Moving Windows/Doors

A forum dedicated to the Draft, Arch and BIM workbenches development.
paullee
Veteran
Posts: 4437
Joined: Wed May 04, 2016 3:58 pm

Re: Moving Windows/Doors

Post by paullee »

That's inspiring :)

Have no idea about shape.transformShape(), but it looks 'similar'. Can you enlighten if this change fix the OP problem and what is the difference ?

Thanks.

Code: Select all

                        if inv_matrix:
                            add.transformShape(inv_matrix)
User avatar
Roy_043
Veteran
Posts: 5455
Joined: Thu Dec 27, 2018 12:28 pm

Re: Moving Windows/Doors

Post by Roy_043 »

paullee wrote: Sat Mar 12, 2022 3:48 pm Can you enlighten if this change fix the OP problem
As already mentioned: Yes.

paullee wrote: Sat Mar 12, 2022 3:48 pm Can you enlighten if this change fix the OP problem and what is the difference ?
In some cases a copied shape will have a Placement that is not the same as its original. Manipulations based on the Placement will then lead to faulty results. Using transformShape instead avoids this. But I have yet to check if this is the case here.
paullee
Veteran
Posts: 4437
Joined: Wed May 04, 2016 3:58 pm

Re: Moving Windows/Doors

Post by paullee »

Thanks for the explanation :)


This may be same / similar problem (2018) as previously reported ?

Arch Window create Wrong Opening Position Bug?
paullee
Veteran
Posts: 4437
Joined: Wed May 04, 2016 3:58 pm

Re: Moving Windows/Doors

Post by paullee »

It seems the order of inversing placement needs to take in account of the Window's placement, and below rectify the problem?

Code: Select all

                            #subvolume.Placement = subvolume.Placement.multiply(placement)
                            subPl = FreeCAD.Placement()

                            print (" subvolume placement is ", subPl)
                            subPl = subPl.multiply(placement)  # inverse placement of Wall object

                            print (" subvolume placement is ", subPl)
                            subPl = subPl.multiply(subvolume.Placement) # placementof Window (Opening) object

                            print (" subvolume placement is ", subPl)
                            subvolume.Placement = subPl
ArchComponent.py
(96.71 KiB) Downloaded 16 times
DoorInsertion002_ r2.FCStd
(36.22 KiB) Downloaded 9 times
Screenshot from 2022-03-13 02-19-50.png
Screenshot from 2022-03-13 02-19-50.png (198.17 KiB) Viewed 1003 times
paullee
Veteran
Posts: 4437
Joined: Wed May 04, 2016 3:58 pm

Re: Moving Windows/Doors

Post by paullee »

And seems it fix the problem 3 4 years ago (2018) ? :D

Before
Screenshot from 2022-03-13 02-23-47.png
Screenshot from 2022-03-13 02-23-47.png (186.29 KiB) Viewed 1002 times
After
Screenshot from 2022-03-13 02-24-00.png
Screenshot from 2022-03-13 02-24-00.png (187.57 KiB) Viewed 1002 times
paullee
Veteran
Posts: 4437
Joined: Wed May 04, 2016 3:58 pm

Re: Moving Windows/Doors

Post by paullee »

Just try to compare if there is any significant difference in time, seems both 5000 routine spend about somthing slightly more than 5s.

Code: Select all

w=Gui.Selection.getSelection()[0] # window
wl=Gui.Selection.getSelection()[0] # wall

for i in range(0,5000):
  ws=w.Proxy.getSubVolume(w)
  wlpi=FreeCAD.Placement().multiply(wl.Placement.inverse()).multiply(w.Placement)
  ws.Placement=wlpi

Code: Select all

for i in range(0,5000):
  ws=w.Proxy.getSubVolume(w)
  inv_matrix = wl.Placement.Matrix.inverse()
  ws.transformShape(inv_matrix)
paullee
Veteran
Posts: 4437
Joined: Wed May 04, 2016 3:58 pm

Re: Moving Windows/Doors

Post by paullee »

Hmmm, for some reason, the inverse_matrix method is not working ?

ArchComponent.py
(97.22 KiB) Downloaded 9 times
Test_ ArchSketch_ 49_ Window-Placement_r.FCStd
(35.63 KiB) Downloaded 9 times
Screenshot from 2022-03-14 01-56-59.png
Screenshot from 2022-03-14 01-56-59.png (231.03 KiB) Viewed 837 times
Screenshot from 2022-03-14 01-57-17.png
Screenshot from 2022-03-14 01-57-17.png (234.07 KiB) Viewed 837 times
Screenshot from 2022-03-14 02-18-48.png
Screenshot from 2022-03-14 02-18-48.png (183.63 KiB) Viewed 837 times
Screenshot from 2022-03-14 02-19-01.png
Screenshot from 2022-03-14 02-19-01.png (179.13 KiB) Viewed 837 times
User avatar
Roy_043
Veteran
Posts: 5455
Joined: Thu Dec 27, 2018 12:28 pm

Re: Moving Windows/Doors

Post by Roy_043 »

paullee wrote: Sun Mar 13, 2022 6:20 pm mmm, for some reason, the inverse_matrix method is not working ?
On line 721 you have:

Code: Select all

placement = placement.inverse()
On line 729 you have:

Code: Select all

inv_matrix = placement.Matrix.inverse()
In other words you are applying the inversion twice.
User avatar
Roy_043
Veteran
Posts: 5455
Joined: Thu Dec 27, 2018 12:28 pm

Re: Moving Windows/Doors

Post by Roy_043 »

paullee wrote: Sat Mar 12, 2022 6:21 pm It seems the order of inversing placement needs to take in account of the Window's placement, and below rectify the problem?

Code: Select all

                            #subvolume.Placement = subvolume.Placement.multiply(placement)
                            subPl = FreeCAD.Placement()

                            print (" subvolume placement is ", subPl)
                            subPl = subPl.multiply(placement)  # inverse placement of Wall object

                            print (" subvolume placement is ", subPl)
                            subPl = subPl.multiply(subvolume.Placement) # placementof Window (Opening) object

                            print (" subvolume placement is ", subPl)
                            subvolume.Placement = subPl
This code works.

It can be reduced to this line:

Code: Select all

                            subvolume.Placement = placement.multiply(subvolume.Placement)
If you compare it to the original code (line 786) there is only a subtle difference:

Code: Select all

                            subvolume.Placement = subvolume.Placement.multiply(placement)
I have to admit that I do not understand this difference.

Note that the .Placement.multiply(placement) structure occurs elsewhere in the file. I suppose it would have to be changed there as well?
paullee
Veteran
Posts: 4437
Joined: Wed May 04, 2016 3:58 pm

Re: Moving Windows/Doors

Post by paullee »

Roy_043 wrote: Sun Mar 13, 2022 7:21 pm It can be reduced to this line:

Code: Select all

                            subvolume.Placement = placement.multiply(subvolume.Placement)
If you compare it to the original code (line 786) there is only a subtle difference:

Code: Select all

                            subvolume.Placement = subvolume.Placement.multiply(placement)
I have to admit that I do not understand this difference.

Note that the .Placement.multiply(placement) structure occurs elsewhere in the file. I suppose it would have to be changed there as well?
Thanks. I understand the multiplication of placement is not 'commutative' in mathematics sense - so multiplication needs to be in the particular order of successive placement manipulation.


And further examining other Additions / Subtraction cases, and the bug seems exist. It can be shown that only Window object (getSubVolume) works correctly.

Test_ ArchSketch_ 49_ Window-Placement_r2.FCStd
(63.88 KiB) Downloaded 12 times
Screenshot from 2022-03-15 01-34-10.png
Screenshot from 2022-03-15 01-34-10.png (262.75 KiB) Viewed 721 times
Screenshot from 2022-03-15 01-34-18.png
Screenshot from 2022-03-15 01-34-18.png (272.86 KiB) Viewed 721 times
Screenshot from 2022-03-15 01-34-21.png
Screenshot from 2022-03-15 01-34-21.png (269.6 KiB) Viewed 721 times
Post Reply