displaying a list of global dimensional variables ?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 13
- Joined: Sun Feb 23, 2020 1:10 am
displaying a list of global dimensional variables ?
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?
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?
Re: displaying a list of global dimensional variables ?
All objects in the current document are inLinear3000 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.
Code: Select all
FreeCAD.ActiveDocument.Objects
Code: Select all
for obj in FreeCAD.ActiveDocument.Objects:
for property in obj.PropertiesList:
print(property)
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.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
-
- Posts: 13
- Joined: Sun Feb 23, 2020 1:10 am
Re: displaying a list of global dimensional variables ?
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?
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?
Re: displaying a list of global dimensional variables ?
Obviously it's possible to add more graphical interfaces. This is exactly what many external workbenches do, they add new graphical panes and dialogs.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, ...
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.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
-
- Posts: 13
- Joined: Sun Feb 23, 2020 1:10 am
Re: displaying a list of global dimensional variables ?
Thank you again so much, I really appreciate it! Will see how things go. Cheers!
Re: displaying a list of global dimensional variables ?
hi
maybe this macro can help you momentarily Macro FCInfo on selected object
other Macro SimpleProperties
mario
maybe this macro can help you momentarily Macro FCInfo on selected object
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.
My macros on Gist.github here complete macros Wiki and forum.
- thomas-neemann
- Veteran
- Posts: 11944
- Joined: Wed Jan 22, 2020 6:03 pm
- Location: Osnabrück DE 🇩🇪
- Contact:
Re: displaying a list of global dimensional variables ?
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
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.
Re: displaying a list of global dimensional variables ?
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.
- thomas-neemann
- Veteran
- Posts: 11944
- Joined: Wed Jan 22, 2020 6:03 pm
- Location: Osnabrück DE 🇩🇪
- Contact:
Re: displaying a list of global dimensional variables ?
ok, I have completed it