Shape binder not at expected place
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Shape binder not at expected place
The exact same problem was once in Draft Facebinder.
When coding Lattice, I found out a lot of things about how placement works in freecad and occ. This is what I think is happening.
Top face of Pad is a partner of the bottom face of Pad. Being "partner" means it is the same underlying face, just with different (nonzero) placement.
Now, Shapebinder is likely taking the face off the Pad, like face = App.ActiveDocument.Pad.Shape.Face2, and assigning it to its own shape, like selfobj.Shape = face. Now what happens is that FreeCAD will always force Placement of selfobj.Shape be equal to selfobj.Placement. As a result, the original nonzero placement is wiped off (ignored). It is done in Part::Feature code.
There are two workarounds I know of. One is to pack the face into a compound. Second is to use transformShape() Py method to sort-of "imprint the placement of the face into the face itself".
Of course I described it in python terminology, in C++ things are similar, just named differently.
When coding Lattice, I found out a lot of things about how placement works in freecad and occ. This is what I think is happening.
Top face of Pad is a partner of the bottom face of Pad. Being "partner" means it is the same underlying face, just with different (nonzero) placement.
Now, Shapebinder is likely taking the face off the Pad, like face = App.ActiveDocument.Pad.Shape.Face2, and assigning it to its own shape, like selfobj.Shape = face. Now what happens is that FreeCAD will always force Placement of selfobj.Shape be equal to selfobj.Placement. As a result, the original nonzero placement is wiped off (ignored). It is done in Part::Feature code.
There are two workarounds I know of. One is to pack the face into a compound. Second is to use transformShape() Py method to sort-of "imprint the placement of the face into the face itself".
Of course I described it in python terminology, in C++ things are similar, just named differently.
Re: Shape binder not at expected place
If you have a shape then in most cases its sub-shapes has an empty placement and transformations are directly incorporated into the geometry. But it's possible that also a sub-shape has set a placement which happens in this case.
If you look at the placement information of all faces of the pad
then for face 1,...,5 the output is:
And also graphically the shape is at the correct location in the 3d view.
If you look at the placement information of all faces of the pad
Code: Select all
getattr(App.ActiveDocument.Pad.Shape,"Face1").Placement
However, for face 6 the placement is (see the z value of pos):Placement [Pos=(0,0,0), Yaw-Pitch-Roll=(0,0,0)]
So, obviously shape binder doesn't handle the placement correctly.Placement [Pos=(0,0,10), Yaw-Pitch-Roll=(0,0,0)]
No idea what the shape binder does here but when assigning the face 6 to a part feature everything is handled correctly:DeepSOIC wrote:Now what happens is that FreeCAD will always force Placement of selfobj.Shape be equal to selfobj.Placement. As a result, the original nonzero placement is wiped off (ignored). It is done in Part::Feature code.
Code: Select all
shape=App.ActiveDocument.addObject("Part::Feature")
shape.Shape=App.ActiveDocument.Pad.Shape.Face6
shape.Placement # shows: Placement [Pos=(0,0,10), Yaw-Pitch-Roll=(0,0,0)]
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Shape binder not at expected place
That's only up to the moment you click Recompute.wmayer wrote: ↑Sun Aug 20, 2017 5:27 pm No idea what the shape binder does here but when assigning the face 6 to a part feature everything is handled correctly:And also graphically the shape is at the correct location in the 3d view.Code: Select all
shape=App.ActiveDocument.addObject("Part::Feature") shape.Shape=App.ActiveDocument.Pad.Shape.Face6 shape.Placement # shows: Placement [Pos=(0,0,10), Yaw-Pitch-Roll=(0,0,0)]
Also, doing this from within execute is different to doing it directly in py console, because this:
https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L134
Last edited by DeepSOIC on Sun Aug 20, 2017 6:19 pm, edited 1 time in total.
Reason: replaced the link to be for specific version of the file
Reason: replaced the link to be for specific version of the file
Re: Shape binder not at expected place
When I touch the part feature and perform a recompute the face doesn't move. This is because the execute() method of Part::Feature actually doesn't do anything but touching its shape which causes the onChanged() method to set again (the already set) placement to the shape.
-
- Posts: 45
- Joined: Sat Jun 24, 2017 8:12 am
Re: Shape binder not at expected place
Hi,
I think I am experiencing similar issue.
I am trying to make a hole in Steber1 so it would aline with hole in the plate above (Part of Body 12). I tried to bind shape of plate (Hole002) to Steber1 part, however when I use ShapeBinder, shape is thrown on completely different location. Is there any solution to that jet?
Kind Regards,
Peter
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.27422 (Git)
Build type: Release
Branch: master
Hash: d938733eaf2c2ce7cb18d1cbb56147185c473530
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: Slovenian/Slovenia (sl_SI)
I think I am experiencing similar issue.
I am trying to make a hole in Steber1 so it would aline with hole in the plate above (Part of Body 12). I tried to bind shape of plate (Hole002) to Steber1 part, however when I use ShapeBinder, shape is thrown on completely different location. Is there any solution to that jet?
Kind Regards,
Peter
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.27422 (Git)
Build type: Release
Branch: master
Hash: d938733eaf2c2ce7cb18d1cbb56147185c473530
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: Slovenian/Slovenia (sl_SI)
- Attachments
-
- Staja.FCStd
- (216.25 KiB) Downloaded 14 times
Kind regards,
Peter
Peter
Re: Shape binder not at expected place
Set the ShapeBinders TraceSupport=true.
And please minimize for your next question the model as far as possible, so that it still shows the issue, but as little other stuff as necessary.
And please minimize for your next question the model as far as possible, so that it still shows the issue, but as little other stuff as necessary.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Shape binder not at expected place
Thank you it works.
And sorry for model size.
Good night,
Peter
And sorry for model size.
Good night,
Peter
Kind regards,
Peter
Peter