what is the difference between placement and attachment?

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!
geos
Posts: 21
Joined: Sun Nov 03, 2019 11:10 am

what is the difference between placement and attachment?

Post by geos »

what is the difference between placement and attachment?

could anyone explain this from the ground up for the beginner so that the explanation is build upon basic principles of freecad internal design or the way freecad "sees" modeled things in space?

I just don't understand it as I would like to, I feel like I'm missing something in order to grasp this fully.

for example, when I create a cube in PART workbench it shows the placement position of (0,0,0). let's assume that this makes sense to me and I can relate this (0,0,0) to the origin of blue coordinate system that is also visible, and I understand placement like this "left bottom corner of cube is placed at (0,0,0) in this blue coordinate system". it defines how the cube is placed in this system assuming that left bottom corner of a cube is used to describe placement:
1.png
1.png (46.29 KiB) Viewed 2479 times
but when I make a cube in PART DESIGN workbench as PAD operation on a sketch of square in XY plane then this sketch has both placement and attachment and they both show (0,0,0) no matter when on the plane the square is sketched:
2.png
2.png (10.12 KiB) Viewed 2479 times
3.png
3.png (48.7 KiB) Viewed 2479 times
also it looks like there are many coordinate systems for each part, body etc. that probably relate to one another but I don't know how.
4.png
4.png (96.63 KiB) Viewed 2479 times
I use freecad to design hobbyist stuff for myself just by sketching, padding, plcketing, intersecting etc. really simple things. they work but when I try to read wiki for freecad it is overwhelming and daunting to me: "The placement is stored internally as a position and a rotation (rotation axis and angle transformed into quaternion). While there are several forms to specify a rotation, for instance with a rotation center, this is only used to affect the rotation computation and is not stored for later operations. Similarly, if a rotation axis of (1,1,1) is specified, it may be normalized when stored in the quaternion and appear as (0.58, 0.58, 0.58) when browsing the object later."

I realize that making such advanced software is heavily based on mathematics but is there any way to clearly and simply explain what placement and attachment are, how they relate to one another and to many origins visible in freecad?
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: what is the difference between placement and attachment?

Post by chrisb »

First thong to note is that Attachment is different from AttachmentOffset.

You can attach an object to another object, which moves the origin of the attached object to some other point in 3D space. AttachmentOffset then starts there as an offset in the local coordinate system of the attached object.

Have a look at the Basic Attachment Tutorial.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
drmacro
Veteran
Posts: 8863
Joined: Sun Mar 02, 2014 4:35 pm

Re: what is the difference between placement and attachment?

Post by drmacro »

Hmm...explain in laymen's terms. ;)

Every object, Part workbench Cube, Torus, etc., Part Design Body, etc. has a Placement object. You can think of it as establishing the geometry's position on it's local coordinate system (LCS) and establishes the relationship between the LCS and the global coordinate system (GCS).

When an Attachment object is added, it essentially establishes a relationship between the LCS and some geometry of another item. The Placement about the LCS now stays the same, and the position of the item is relative to the geometry selected in the other item.

I'm sure others will correct me if I'm wrong. :mrgreen:
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: what is the difference between placement and attachment?

Post by adrianinsaval »

ok this might get long... I assume you know what coordinate system is, origin, xyz axis...

So the model has an implicit global coordinate system (GCS) that is not shown in the tree but can be seen in the 3d view if you toggle the axis cross on.

Part and Body containers define their own coordinate system (CS) that is listed in the tree and can be showed in 3d view (if you ever studied physics you've probably heard of reference frames, the concept is very similar), it also has some handy planes associated to this system.

Every object that has a shape has a placement property (including Part and Body containers) that defines it's position in the coordinate system were this object is located, so the placement of objects in the root level of the tree is relative to the GCS, the placement of object inside a Part container is relative to Part's own CS (and these can be nested, you can have an object inside a part inside a part, the placement of each will be relative to it's parent). The placement consist of a coordinate point and a rotation defined by an axis (relative to the coordinate point) and an angle.

The placement point of a Part/Body container defines were the origin of that Part/Body's CS will be and the rotation defines the orientation of the axis.
Sketches also have their own CS that can be seen when you edit the sketch, there's a origin point, a vertical axis and a horizontal axis. The placement of the sketch defines were the origin point will be located and the rotation defines the orientation of the axis (and therefore the sketch plane). The geometries inside the sketcher are defined in relation to this origin point, moving those geometries around has no effect on the sketch placement, it's the other way around.
In general every object with a shape has it's own implicit CS that is defined by the placement property, the coordinate of the points that define that shape are relative to this CS.
In the simple case of your cube there's one corner that was defined as (0,0,0) and thus it is coincident with the placement of that cube but as you can probably guess not every shape has a point coincident with it's placement.

Now attachments and attachment offset. This can easily confuse you as in some case you may see that the attachment offset and the placement are the same, this happens when an object is attached to something with placed at the origin and with no rotation.
In general you can attach an object to another and this binds the object's placement to whatever it is attached to, for example you can attach a sketch to the top face of a cube, then you can see that it's placement z value is the same as the cube height (for example 10mm), your attachment offset is still 0.
The attachment offset let's you move the object relative to the attachment point, try editing the attachment offset of that sketch to z=10mm you will then see that the placement of the sketch now has z=20mm. So attaching the sketch to the face move it 10mm up, then with the offset you moved it 10mm more.

Hope this helps and isn't just confusing you more.
User avatar
thomas-neemann
Veteran
Posts: 11800
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: what is the difference between placement and attachment?

Post by thomas-neemann »

geos wrote: Thu Mar 10, 2022 1:27 pm ...is there any way to clearly ...
I felt the same way as you at the beginning. I ignored those things and used a different wrkflow. here is an example:

https://www.youtube.com/watch?v=xNcJcsifcpU

phpBB [video]



edit

https://www.youtube.com/watch?v=s_K9Yt9HuCs

phpBB [video]
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: what is the difference between placement and attachment?

Post by chrisb »

thomas-neemann wrote: Wed Mar 16, 2022 8:41 am I ignored those things and used a different wrkflow.
Ignoring is not the best of all explanations I have seen so far :roll: .
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
thomas-neemann
Veteran
Posts: 11800
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: what is the difference between placement and attachment?

Post by thomas-neemann »

chrisb wrote: Wed Mar 16, 2022 10:17 am
Ignoring is not the best of all explanations I have seen so far :roll: .
would be interesting to know what proposal geos will use?
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Re: what is the difference between placement and attachment?

Post by manos »

chrisb wrote: Thu Mar 10, 2022 1:56 pm First thong to note is that Attachment is different from AttachmentOffset.

You can attach an object to another object, which moves the origin of the attached object to some other point in 3D space. AttachmentOffset then starts there as an offset in the local coordinate system of the attached object.
May I rephrase: "Attachment offset is a part of Attachment Data of an object, if the object is attached" ?
manos
Posts: 432
Joined: Thu Nov 12, 2020 10:48 am
Location: Greece

Re: what is the difference between placement and attachment?

Post by manos »

drmacro wrote: Thu Mar 10, 2022 1:57 pm Hmm...explain in laymen's terms. ;)

When an Attachment object is added, it essentially establishes a relationship between the LCS and some geometry of another item.
I have a sketch inside a Body: When I create an Attachment of the Sketch (to some geometry of another item) the LCS you mention is the Body's LCS or the Sketche's LCS ? Or it is up to me to choose from both?

And by the way : Since attachment is object can we see it at the Tree ?
drmacro
Veteran
Posts: 8863
Joined: Sun Mar 02, 2014 4:35 pm

Re: what is the difference between placement and attachment?

Post by drmacro »

manos wrote: Sat Jul 02, 2022 11:00 am ...I have a sketch inside a Body: When I create an Attachment of the Sketch (to some geometry of another item) the LCS you mention is the Body's LCS or the Sketche's LCS ? Or it is up to me to choose from both?
A sketch in a Body always references the Origin object of the Body. The LCS of the sketch is confusing to many. When a sketch is created the origin of the sketch is somewhere in the Body LCS (the Body LCS, is represented by the Origin object). When you open the sketch it has, let's call it a temporary LCS, where +Z is from the Root point out of the screen, +X is from the Root point to the right, and +Y is from the Root point up.

The confusing part is that the LCS of the sketch can be Attached anywhere in the space of the LCS of the Body. So, X of the Body does not, necessarily map to X of the sketch.

And by the way : Since attachment is object can we see it at the Tree ?
Hmm...the word "object" has different meanings in different contexts. Let's first clarify this a bit.

In the world of Object Oriented Programming (OOP) an object is an encapsulation of things that define and/or implement the behavior of something.

But, in general conversation the word "object" is more thought of as a physical thing. (I'll call this a and RWO (Real World Object), as opposed to the OOP object described above.

An OOP circle, for example, would encapsulate the Properties and Methods than define the behavior of a circle. A Property, for example, would be Radius. A Method would be the program code to implement formula for the the circumference (2*Radius*pi).

In OOP, an object can be made up of other objects. They "inherit" behavior for other OOP objects. So, for example, a sphere might inherit from the circle since the sphere has a Radius.

Much of what is shown in the FreeCAD Tree view are more like RWO's for representation to the user. Generally speaking, the "features" shown in the Tree view have some 3D representation that can be shown in the 3D view.

In fact, under the hood, almost everything in FreeCAD is an OOP object with Properties and Methods.

When a feature, like a sketch, "inherits" and Attachment object, Properties of that the parent object (the sketch) inherits from the Attachment object can be seen in the Properties view. (Most of the time Methods aren't shown directly.)

In the case of the Attachment, there is, no physical presentation of the Attachment that can be shown in the 3D view. (That doesn't mean there can't be, there just isn't at this point.)

The Part Design Body inherits, by default, an Origin object. This particular object does provide visual representation of itself, so can be seen in the 3D view. It also has Properties that can be seen in the Properties view.

So, the short answer to your question: the Attachment Properties are available in the Properties view. You can see more details of the Attachment (and modify it) by looking to the right of the Attachment Offset and clicking the ellipsis (the 3 dot icon '...' on the right of the line).
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply