Referencing X,Y, Z coordinate of another object in formula editor.
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!
- joeldebruijn
- Posts: 3
- Joined: Thu Apr 01, 2021 5:26 am
- Contact:
Referencing X,Y, Z coordinate of another object in formula editor.
Context:
- I'm designing a cabinet with different 'heights' for each shelf.
- Because I'm using certain storage boxes the heigth is calculated in a spreadsheet, so eacht shelf fits them nicely.
- Each shelf is supported by 4 beams.
- First design, so maybe n00b question.
What I try to accomplish:
- After I copy/paste a shelf and its beams I change the z coordinate of the first horizontal beam.
- I want the other beams to change their z coordinate as well automaticcaly.
What I expected:
To be able to enter the following in the formula editor at the Z property of Beam II "<<Beam I>>.Placement.Base.Z"
So I'm having trouble using a property/value of one object in another by using the formula editor.
I studied the Placement page in the wiki and the aeroplane example, but I still dont get it.
I'm on FreeCad 0.19
- I'm designing a cabinet with different 'heights' for each shelf.
- Because I'm using certain storage boxes the heigth is calculated in a spreadsheet, so eacht shelf fits them nicely.
- Each shelf is supported by 4 beams.
- First design, so maybe n00b question.
What I try to accomplish:
- After I copy/paste a shelf and its beams I change the z coordinate of the first horizontal beam.
- I want the other beams to change their z coordinate as well automaticcaly.
What I expected:
To be able to enter the following in the formula editor at the Z property of Beam II "<<Beam I>>.Placement.Base.Z"
So I'm having trouble using a property/value of one object in another by using the formula editor.
I studied the Placement page in the wiki and the aeroplane example, but I still dont get it.
I'm on FreeCad 0.19
Last edited by joeldebruijn on Wed May 05, 2021 6:14 pm, edited 1 time in total.
Re: Referencing X,Y, Z coordinate of another object in formula editor.
Hard to say anything without the file.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
- joeldebruijn
- Posts: 3
- Joined: Thu Apr 01, 2021 5:26 am
- Contact:
Re: Referencing X,Y, Z coordinate of another object in formula editor.
Thanks in advance, see attachement.
Made a screenshot also:
I'm trying to make the Z for beam II, III and IV depending on Z of beam I.
Made a screenshot also:
I'm trying to make the Z for beam II, III and IV depending on Z of beam I.
Re: Referencing X,Y, Z coordinate of another object in formula editor.
Hi Joel
I'm into woodworking and I came accross your problem, although I haven't managed to find the solution, but I do understand what you mean. The problem, as I understand is that the Placement attribute of the referenced object is actually a vector and I haven't the foggiest idea, if the formula editor has any functions to manipulate vectors, like to access the Y coordinate of a vector. But I keep digging, and hoping that somebody will be able to give us an answer.
I'm into woodworking and I came accross your problem, although I haven't managed to find the solution, but I do understand what you mean. The problem, as I understand is that the Placement attribute of the referenced object is actually a vector and I haven't the foggiest idea, if the formula editor has any functions to manipulate vectors, like to access the Y coordinate of a vector. But I keep digging, and hoping that somebody will be able to give us an answer.
-
- Veteran
- Posts: 3117
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Referencing X,Y, Z coordinate of another object in formula editor.
Code: Select all
<<BladBRaamwerkLigger I>>.Placement.Base.z
Code: Select all
Box010.Placement.Base.z
Note it is lower-case z.
Re: Referencing X,Y, Z coordinate of another object in formula editor.
Well done, thanks! There's no code completion for .Placement.Base.x|y|zedwilliams16 wrote: ↑Wed May 05, 2021 7:49 pmandCode: Select all
<<BladBRaamwerkLigger I>>.Placement.Base.z
both work for me in the formula editorCode: Select all
Box010.Placement.Base.z
Note it is lower-case z.
BTW, is there an object reference library, or a wiki on the properties somewhere here? Would be great to have especially because without the completion I'm clueless sometimes.
- joeldebruijn
- Posts: 3
- Joined: Thu Apr 01, 2021 5:26 am
- Contact:
Re: Referencing X,Y, Z coordinate of another object in formula editor.
Ahhhhhh! Thanks, so often the smallest things take the longest time ...
At first I thought "Base" wasnt possible because it isnt in the listed suggestions:
But typing it anyway works.
Then (I dont know why) I used uppercase the whole time.
Anyway, thanks for helping me out!
At first I thought "Base" wasnt possible because it isnt in the listed suggestions:
But typing it anyway works.
Then (I dont know why) I used uppercase the whole time.
Anyway, thanks for helping me out!
-
- Veteran
- Posts: 3117
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Referencing X,Y, Z coordinate of another object in formula editor.
Code completion is partly broken in the formula editor. It does work in the Python console, so
you can look for completions of App.ActiveDocument.Box010.Placement there. The property naming hierarchy, I think always follows how it shows in the property editor, so, for instance
is just what you might expect.
you can look for completions of App.ActiveDocument.Box010.Placement there. The property naming hierarchy, I think always follows how it shows in the property editor, so, for instance
Code: Select all
Placement.Axis.z
Re: Referencing X,Y, Z coordinate of another object in formula editor.
Ed, you're a true gem, thanks! I don't know Python, but I know other languages, so I guess, I can take it from here.edwilliams16 wrote: ↑Wed May 05, 2021 9:33 pm Code completion is partly broken in the formula editor. It does work in the Python console, so
you can look for completions of App.ActiveDocument.Box010.Placement there.
Screen Shot 2021-05-05 at 11.41.27 AM.png
The property naming hierarchy, I think always follows how it shows in the property editor, so, for instanceis just what you might expect.Code: Select all
Placement.Axis.z
One more silly question. I have named bodies in the tree, say there's a body named, say 'fence'. It would be obvious to me to refer to it as App.ActiveDocument.fence.Placement yadayadayada… But for me it does not work in the console, it refers to PartXXX, BodyYYY, PadZZZ. I did change the name, the ID, the label. Drives me nuts. Can you give me a last hint?
-
- Veteran
- Posts: 3117
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Referencing X,Y, Z coordinate of another object in formula editor.
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.
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.
will allow you to refer to it as DOC
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
Typing App.ActiveDocument all the time is also tedious.
Code: Select all
DOC = App.ActiveDocument