Referencing X,Y, Z coordinate of another object in formula editor.

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!
tigrincs
Posts: 8
Joined: Wed May 05, 2021 6:45 pm

Re: Referencing X,Y, Z coordinate of another object in formula editor.

Post by tigrincs »

edwilliams16 wrote: Thu May 06, 2021 1:39 am The internal name is unique. The label you assign need not be - though it would be a good idea if you are going to script with it.

If you hover over an object in the 3D or tree view, you'll see its internal name at the left bottom edge of the screen.

Or you might find selection view useful: https://wiki.freecadweb.org/Selection_view

Using the python console with the label is a bit more cumbersome.

Code: Select all

obj = App.ActiveDocument.getObjectsByLabel("myLabel")[0]
obj.   # will give possible completions - properties and methods
The getObjectsByLabel() method returns a list (not necessarily unique, remember) - the [0] picks off the first item

Typing App.ActiveDocument all the time is also tedious.

Code: Select all

DOC = App.ActiveDocument
will allow you to refer to it as DOC
Awesome, thank you very much!
chrisb
Veteran
Posts: 54313
Joined: Tue Mar 17, 2015 9:14 am

Re: Referencing X,Y, Z coordinate of another object in formula editor.

Post by chrisb »

If you want to investigate something iin the Python console, you can select it in the tree and use Edit->Send to Python console. Some objects even have it in their context menu.

Off topic:
tigrincs wrote: Thu May 06, 2021 1:56 am Awesome, thank you very much!
The helpers are rewarded by a nice thank you :D , and quoting notifies the quotee. But in general don't quote whole messages, just the relevant part of it. It keeps topics smaller and easier to follow.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
tigrincs
Posts: 8
Joined: Wed May 05, 2021 6:45 pm

Re: Referencing X,Y, Z coordinate of another object in formula editor.

Post by tigrincs »

Sure, thanks Chris! :)
Post Reply