(SOLVED) Sketcher: system-generated constraint name only usable after renaming? e.g. in the 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!
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

(SOLVED) Sketcher: system-generated constraint name only usable after renaming? e.g. in the formula editor

Post by thomas-neemann »

I only manage to use the system generated contraint name if I rename it to itself. am I doing something wrong?

1.png
1.png (13.04 KiB) Viewed 860 times

2.png
2.png (32.43 KiB) Viewed 860 times
3.png
3.png (10.35 KiB) Viewed 860 times
OS: Ubuntu 20.04.1 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.28918 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 69a4963)
Hash: 69a4963ebfdbdda0d069347d013f28f2d6ba687a
Python 3.9.12, Qt 5.12.9, Coin 4.0.0, OCC 7.5.3
Locale: German/Germany (de_DE)
Last edited by thomas-neemann on Wed May 25, 2022 7:12 am, edited 2 times in total.
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Sketcher: system-generated contraint name only usable after renaming? e.g. in the formula editor

Post by thomas-neemann »

openBrain wrote: Wed May 25, 2022 5:56 am

Code: Select all

Sketch.Constraints[0]
Thank you for your prompt reply. it works, but how do you get Constraints[0]
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Sketcher: system-generated contraint name only usable after renaming? e.g. in the formula editor

Post by openBrain »

thomas-neemann wrote: Wed May 25, 2022 6:10 am Thank you for your prompt reply. it works, but how do you get Constraints[0]
This is as any numbered element in FreeCAD (Face, Edge, Vertex, ...) ;)
'.ElementN' = '.Elements[N-1]'
Workshop_Notes
Posts: 590
Joined: Wed Sep 29, 2021 8:35 am

Re: Sketcher: system-generated contraint name only usable after renaming? e.g. in the formula editor

Post by Workshop_Notes »

The issue you have run into is, I suspect, common to many people.

The answer is given above.

It is also given in slightly longer form in the 'Referencing Objects' part of the Expressions wiki page (https://wiki.freecadweb.org/Expressions).

If the answer satisfies your need, great, but please do a follow up post if you want to know why the answer is correct.

---
Now a plea to the wiki writers:

In common with so much of the documentation, that page prioritises brevity over clarity and pedagogy. It is written from a programmer's point of view, not as a way to assist a non-technical new user. It would surely be much better to use a few more words to explain how stuff is stored internally (single variables vs. arrays) and the different ways you access them.

It is a very similar story with the 'Reference to CAD data' part of the page: 'If the property is a compound of fields, the individual fields can be accessed as object.property.field'. To a non-technical user, that is incomprehensible because they do not know the specialised meaning of each individual word. Even a 'data storage and retrieval 101' page that could be linked to would allow people to do a little background reading.
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Sketcher: system-generated contraint name only usable after renaming? e.g. in the formula editor

Post by thomas-neemann »

openBrain wrote: Wed May 25, 2022 6:22 am ...
thank you for your explanation. Isn't it wise to display it here from the system as well?
Bildschirmfoto_2022-05-25_08-39-05.png
Bildschirmfoto_2022-05-25_08-39-05.png (3.83 KiB) Viewed 798 times
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Sketcher: system-generated contraint name only usable after renaming? e.g. in the formula editor

Post by openBrain »

thomas-neemann wrote: Wed May 25, 2022 6:40 am thank you for your explanation. Isn't it wise to display it here from the system as well?
No opinion from my side on this. ;)
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Sketcher: system-generated contraint name only usable after renaming? e.g. in the formula editor

Post by thomas-neemann »

openBrain wrote: Wed May 25, 2022 6:50 am ...
is there a way to display all the names created by the system?
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Sketcher: system-generated contraint name only usable after renaming? e.g. in the formula editor

Post by openBrain »

thomas-neemann wrote: Wed May 25, 2022 6:55 am is there a way to display all the names created by the system?
Not sure to get your point completely. Do you mean on a single sketch, or across a complete document ?
In the form 'ContraintN' or 'Constraints[N]' ?
User avatar
thomas-neemann
Veteran
Posts: 11801
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Sketcher: system-generated contraint name only usable after renaming? e.g. in the formula editor

Post by thomas-neemann »

openBrain wrote: Wed May 25, 2022 7:00 am ...
I mean e.g. a macro which shows all variables of a document or a sketch. or a python line from which i can create a macro
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
Post Reply