Page 2 of 6
Re: Moving Windows/Doors
Posted: Sat Mar 12, 2022 3:48 pm
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)
Re: Moving Windows/Doors
Posted: Sat Mar 12, 2022 4:05 pm
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.
Re: Moving Windows/Doors
Posted: Sat Mar 12, 2022 5:00 pm
by paullee
Thanks for the explanation
This may be same / similar problem (2018) as previously reported ?
Arch Window create Wrong Opening Position Bug?
Re: Moving Windows/Doors
Posted: Sat Mar 12, 2022 6:21 pm
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
- Screenshot from 2022-03-13 02-19-50.png (198.17 KiB) Viewed 2024 times
Re: Moving Windows/Doors
Posted: Sat Mar 12, 2022 6:25 pm
by paullee
And seems it fix the problem
3 4 years ago (2018) ?
Before
- Screenshot from 2022-03-13 02-23-47.png (186.29 KiB) Viewed 2023 times
After
- Screenshot from 2022-03-13 02-24-00.png (187.57 KiB) Viewed 2023 times
Re: Moving Windows/Doors
Posted: Sun Mar 13, 2022 5:08 am
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)
Re: Moving Windows/Doors
Posted: Sun Mar 13, 2022 6:20 pm
by paullee
Re: Moving Windows/Doors
Posted: Sun Mar 13, 2022 7:06 pm
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:
On line 729 you have:
Code: Select all
inv_matrix = placement.Matrix.inverse()
In other words you are applying the inversion twice.
Re: Moving Windows/Doors
Posted: Sun Mar 13, 2022 7:21 pm
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?
Re: Moving Windows/Doors
Posted: Mon Mar 14, 2022 5:38 pm
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.
- Screenshot from 2022-03-15 01-34-10.png (262.75 KiB) Viewed 1742 times
- Screenshot from 2022-03-15 01-34-18.png (272.86 KiB) Viewed 1742 times
- Screenshot from 2022-03-15 01-34-21.png (269.6 KiB) Viewed 1742 times