¿How to get global coordinates of feature?

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
Simbioz
Posts: 67
Joined: Tue Mar 30, 2021 2:55 pm

¿How to get global coordinates of feature?

Post by Simbioz »

So, what I am trying to achieve is setting the Y position of Cylinder004(label: Soporte3) equal to the Y position of a vertex of Box005(PlacaSoporte). Therefore, I edit the Y coordinate of Cylinder004 putting

Code: Select all

Box005.Shape.Vertex3.Point.y
as an expression. This turns out to be 118mm, however the object is not in the position I expected. Hovering the mouse over the aforementioned vertex yields 340.5mm as the Y coordinate. I suspect 118mm is relative to the local coordinates and 340.5mm is relative to the global coordinates. What is the expression that gives the global coordinate of the Y component of the vertex?
Thanks.

OS: Arch Linux (sway/sway)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: makepkg
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.9.7
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: English/United States (en_US)
Attachments
sierra.FCStd
(236.48 KiB) Downloaded 41 times
Non native English speaker.
edwilliams16
Veteran
Posts: 3112
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: ¿How to get global coordinates of feature?

Post by edwilliams16 »

User avatar
Simbioz
Posts: 67
Joined: Tue Mar 30, 2021 2:55 pm

Re: ¿How to get global coordinates of feature?

Post by Simbioz »

Is there a simpler way of getting the global coordinates of the object without having to mess with the python console?(which I know nothing about)
Non native English speaker.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: ¿How to get global coordinates of feature?

Post by TheMarkster »

Simbioz wrote: Wed Dec 01, 2021 4:41 am Is there a simpler way of getting the global coordinates of the object without having to mess with the python console?(which I know nothing about)
None I am aware of. You can copy/paste this into the console after selecting your object and pressing Ctrl+Shift+P:

Code: Select all

obj.addProperty("App::PropertyPlacement","GlobalPlacement").GlobalPlacement = obj.getGlobalPlacement()
(Untested)

It should give you a new property with the current global placement, but it will not automatically refresh. You would need to refresh it manually with:

Code: Select all

obj.GlobalPlacement = obj.getGlobalPlacement()
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: ¿How to get global coordinates of feature?

Post by openBrain »

Simbioz wrote: Wed Dec 01, 2021 4:41 am Is there a simpler way of getting the global coordinates of the object without having to mess with the python console?(which I know nothing about)
Hover object with mouse pointer and read in the status bar.
chrisb
Veteran
Posts: 53939
Joined: Tue Mar 17, 2015 9:14 am

Re: ¿How to get global coordinates of feature?

Post by chrisb »

You may consider to model this differently, by attaching things properly.

Besides: If you model in Part workbench, you should not use the PartDesign clones, use Draft clone instead.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Simbioz
Posts: 67
Joined: Tue Mar 30, 2021 2:55 pm

Re: ¿How to get global coordinates of feature?

Post by Simbioz »

openBrain wrote: Wed Dec 01, 2021 5:58 am
Simbioz wrote: Wed Dec 01, 2021 4:41 am Is there a simpler way of getting the global coordinates of the object without having to mess with the python console?(which I know nothing about)
Hover object with mouse pointer and read in the status bar.
Yes, I tried this already, I memorize the string (because there seems no way to copy it) and write it in the expression box, getting;

Code: Select all

 Result: Property 'sierra' not found in 'sierra.Part.Part002.Box005.Vertex3'
Non native English speaker.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: ¿How to get global coordinates of feature?

Post by openBrain »

Simbioz wrote: Wed Dec 01, 2021 3:44 pm Yes, I tried this already, I memorize the string (because there seems no way to copy it) and write it in the expression box, getting;

Code: Select all

 Result: Property 'sierra' not found in 'sierra.Part.Part002.Box005.Vertex3'
AFAIK there is no way to use global coordinates in Expressions. You have to manually add all parents relative coordinates, but that will obviously break as soon as you move the object into other Part container.
User avatar
Simbioz
Posts: 67
Joined: Tue Mar 30, 2021 2:55 pm

Re: ¿How to get global coordinates of feature?

Post by Simbioz »

chrisb wrote: Wed Dec 01, 2021 7:08 am You may consider to model this differently, by attaching things properly.
I am still not familiar with the attachment process or why it would be necessary/convenient to use it in this situation. I am gonna have a look at the wiki.
chrisb wrote: Wed Dec 01, 2021 7:08 am Besides: If you model in Part workbench, you should not use the PartDesign clones, use Draft clone instead.
Interesting, I read the respective wikis and I found no fundamental reason to use one over the other for my model. Why are you suggesting this?

Thanks
Non native English speaker.
drmacro
Veteran
Posts: 8870
Joined: Sun Mar 02, 2014 4:35 pm

Re: ¿How to get global coordinates of feature?

Post by drmacro »

Simbioz wrote: Wed Dec 01, 2021 5:05 pm
chrisb wrote: Wed Dec 01, 2021 7:08 am You may consider to model this differently, by attaching things properly.
I am still not familiar with the attachment process or why it would be necessary/convenient to use it in this situation. I am gonna have a look at the wiki.
Your model seems to be developed in a rather haphazard way. This may be the reason you need global coordinates.
chrisb wrote: Wed Dec 01, 2021 7:08 am Besides: If you model in Part workbench, you should not use the PartDesign clones, use Draft clone instead.
Interesting, I read the respective wikis and I found no fundamental reason to use one over the other for my model. Why are you suggesting this?

Thanks
It is typical to recommend to new user to use either Part workbench or Part Design workbench exclusively.

Once the subtleties of each is experienced, then it is advisable to understand the rules required involved when mixing the two.

If you read this wiki page and have a look at the example of creating identical models with each workbench exclusively you may find some insight:
https://wiki.freecadweb.org/Part_and_PartDesign
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply