Shape binder not at expected place

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
User avatar
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

Post by DeepSOIC »

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.
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Shape binder not at expected place

Post by wmayer »

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

Code: Select all

getattr(App.ActiveDocument.Pad.Shape,"Face1").Placement
then for face 1,...,5 the output is:
Placement [Pos=(0,0,0), Yaw-Pitch-Roll=(0,0,0)]
However, for face 6 the placement is (see the z value of pos):
Placement [Pos=(0,0,10), Yaw-Pitch-Roll=(0,0,0)]
So, obviously shape binder doesn't handle the placement 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.
No idea what the shape binder does here but when assigning the face 6 to a part feature everything is handled correctly:

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)]
And also graphically the shape is at the correct location in the 3d view.
User avatar
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

Post by DeepSOIC »

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:

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)]
And also graphically the shape is at the correct location in the 3d view.
That's only up to the moment you click Recompute.

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
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Shape binder not at expected place

Post by wmayer »

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.
User avatar
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

Post by DeepSOIC »

wmayer wrote: Sun Aug 20, 2017 6:55 pm When I touch the part feature and perform a recompute the face doesn't move.
Indeed, I didn't notice that face's Placement is copied to documentobject's placement, as your example clearly displays. My bad.
Dekonstruierer
Posts: 45
Joined: Sat Jun 24, 2017 8:12 am

Re: Shape binder not at expected place

Post by Dekonstruierer »

PeterII
Posts: 21
Joined: Sat Aug 14, 2021 8:53 am

Re: Shape binder not at expected place

Post by PeterII »

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).
Hole_external geometry.png
Hole_external geometry.png (21.67 KiB) Viewed 620 times
I tried to bind shape of plate (Hole002) to Steber1 part, however when I use ShapeBinder, shape is thrown on completely different location.
Shape binder.png
Shape binder.png (33.67 KiB) Viewed 620 times
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
chrisb
Veteran
Posts: 54273
Joined: Tue Mar 17, 2015 9:14 am

Re: Shape binder not at expected place

Post by chrisb »

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.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
PeterII
Posts: 21
Joined: Sat Aug 14, 2021 8:53 am

Re: Shape binder not at expected place

Post by PeterII »

Thank you it works.

And sorry for model size.

Good night,
Peter
Kind regards,
Peter
Post Reply