displaying a list of global dimensional variables ?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
Linear3000
Posts: 13
Joined: Sun Feb 23, 2020 1:10 am

displaying a list of global dimensional variables ?

Post by Linear3000 »

Hi there, I'm fairly new to FreeCAD and doing quite well with it, but a thought occurred to me ---

in a typical IDE software package, you'll have a variables list feature which will show you what variables you currently have data assigned to, what that data is, and how it changes as you step through a program.

In using FreeCAD software (not editing code in an IDE, but simply while working in the FreeCAD program creating CAD parts) Is there any existing way to similarly view such a list of specifically positional/dimensional variables of the freecad document you're currently working in? i.e. those items that show up in the property view panel (not necessarily to edit them, but could be)

An example of what I'm talking about -- if I type the following in the python console
FreeCAD.getDocument("toy").getObject("Sketch").AttachmentOffset
I get:
Placement [Pos=(0,0,0), Yaw-Pitch-Roll=(0,0,0)]

As a first step, I'm thinking that I could write a simple macro to basically loop through all the instantiated objects / variables , and then simply display those variables in the console, as above.

Maybe later I could develop it into some kind of graphical thing.

However, If there's already an easy way to do these things, maybe I should know about that first, before I reinvent the wheel.

I do understand that expressions, dynamic data variables, and assembly workbench variables, spreadsheets, etc already exist as ways to assign values to variables.

All that stuff is a bit cumbersome, and sometimes you just want to see all the relevant variables, all in one place, not having to endlessly click through so many different things in the tree to get there.

Thoughts?
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: displaying a list of global dimensional variables ?

Post by vocx »

Linear3000 wrote: Fri Mar 20, 2020 11:43 pm ...
All that stuff is a bit cumbersome, and sometimes you just want to see all the relevant variables, all in one place, not having to endlessly click through so many different things in the tree to get there.
All objects in the current document are in

Code: Select all

FreeCAD.ActiveDocument.Objects
Then each object has its own set of properties in the attribute PropertiesList.

Code: Select all

for obj in FreeCAD.ActiveDocument.Objects:
    for property in obj.PropertiesList:
        print(property)
Having a single place for all relevant properties doesn't exist, because what is a "relevant property" to you? That's what the property editor is for, it shows you all properties of the active object. If you would like to show all properties of all objects at the same time, then you'd need to loop through all objects in the document, extract the property, and show it somewhere.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Linear3000
Posts: 13
Joined: Sun Feb 23, 2020 1:10 am

Re: displaying a list of global dimensional variables ?

Post by Linear3000 »

Thank you! Much appreciated!

One other thing I haven't been able to locate in the documentation is how one might go about creating
graphical elements that are not part of the existing freecad gui, or, for example, to create an alternate panel view like i.e. the property view... something that can be attached to a fixed location inside the freecad window or possibly float outside.

Is that something that could be done at the python level? or would one have to delve into the nitty gritty lower level operations of the program to produce novel graphical features?

as a simple test for handling 'extra' graphical elements, I fired up matplotlib in the python console and much to my surprise,
(note: I do not believe I have "plot" workbench installed in freecad, but this stuff worked nonetheless. )
I succeeded in creating a graphical interactive plot. Now I don't know if matplotlib is doing this independently in some graphical backend that is seperate from freeCAD but when I run this command
>>> plt.get_backend()
I get:
'Qt5Agg'

So should I assume it is using FreeCAD's 'Qt5Agg' backend?

Is there any particular reference or documentation you could refer me to regarding developing novel graphical elements in freecad?
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: displaying a list of global dimensional variables ?

Post by vocx »

Linear3000 wrote: Sat Mar 21, 2020 4:19 pm ...
One other thing I haven't been able to locate in the documentation is how one might go about creating graphical elements that are not part of the existing freecad gui, ...
Obviously it's possible to add more graphical interfaces. This is exactly what many external workbenches do, they add new graphical panes and dialogs.

What you want is located somewhere in the Power users hub or Developer hub. Unfortunately, many pages are very old, created around 2014 and earlier so they haven't been updated significantly in years. They are also hard to find, because there is no clear progression on what you should read first, and what second, or how to return to the beginning, etc.

But if you are willing to dig in, you can find what you need. And you should also check the official Qt docs to see what else is available.

FreeCAD uses Qt5. It accesses it through the PySide wrapper in Python. See the examples there.

If you find references to PyQt in the documentation these are outdated as PyQt hasn't been used since 2013 or so. In many cases you can just substitute PyQt with PySide and the examples should work.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Linear3000
Posts: 13
Joined: Sun Feb 23, 2020 1:10 am

Re: displaying a list of global dimensional variables ?

Post by Linear3000 »

Thank you again so much, I really appreciate it! Will see how things go. Cheers!
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: displaying a list of global dimensional variables ?

Post by mario52 »

hi

maybe this macro can help you momentarily Macro FCInfo on selected object

Image

other Macro SimpleProperties

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
thomas-neemann
Veteran
Posts: 11915
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: displaying a list of global dimensional variables ?

Post by thomas-neemann »

Linear3000 wrote: Fri Mar 20, 2020 11:43 pm ...
it is not via gui and also only in linux (but should also work under mac-os and Windows subsystem for Linux). you can use it e.g. in a foreign documnet to display names and locations of the used contrains

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

phpBB [video]


edit

this properties can also be searched for

PropertyBool
PropertyFloat
PropertyAngle
PropertyDistance
PropertyInteger
PropertyString
PropertyMatrix
PropertyVector
PropertyPlacement

and other properties
Last edited by thomas-neemann on Tue Aug 22, 2023 7:22 am, edited 3 times in total.
Gruß Dipl.-Ing. (FH) Thomas Neemann

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

Re: displaying a list of global dimensional variables ?

Post by chrisb »

Please read the posts carefully you are posting to. This is a three years old topic, OP hasn't logged in since, and he asked for all properties, and not only expressions.
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: 11915
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: displaying a list of global dimensional variables ?

Post by thomas-neemann »

chrisb wrote: Tue Aug 22, 2023 5:22 am Please read the posts carefully you are posting to. This is a three years old topic, OP hasn't logged in since, and he asked for all properties, and not only expressions.
ok, I have completed it
Gruß Dipl.-Ing. (FH) Thomas Neemann

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