For a while now I've been using App::FeaturePython objects filled with values to parametrise sketches, pads, etc. conveniently from the outliner.
I want to share the corresponding GUI macro as I find it quite useful and it has reached some stage of maturity.
Comments welcome.
Usage: run the macro, set a parameter holder (e.g. the shown default name), create entries and use them in any formula editor.
Illustrations:
edit: current version 2019.08.20
Param object editor macro
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Param object editor macro
- Attachments
-
- paramgui.FCMacro
- (10.2 KiB) Downloaded 40 times
Last edited by donjan on Tue Aug 20, 2019 12:17 am, edited 3 times in total.
Re: Param object editor macro
Added a tooltip (also text when deleting) showing labels of where the property is used:
-
- Veteran
- Posts: 5505
- Joined: Thu Apr 05, 2018 1:53 am
Re: Param object editor macro
This is similar to DynamicData workbench, but done as a macro.
Re: Param object editor macro
Had I been aware of the DynamicData workbench a few months ago, I probably would not have written this macro.
Didn't find it because I never expected anyone to want to put this kind of functionality in a workbench.
It's definitely a useful plugin, but I find its UX is rather convoluted due to the multiple dialog click-throughs, name prefix cluttering and having to switch workbenches and hunt for buttons.
In my taste it's too "involved" for what is conceptually a simple task: stashing and fiddling with values. So I'll continue using and developing my macro.
Ideally, the ability to add/remove properties in App::FeaturePython (or even general) objects via right-click context menu should go into FreeCAD proper. This would obliviate the need for 90% of both plugins. I might attempt a hack to smarten up instances of App::FeaturePython, if I get more acquainted with manipulating the main window Qt elements (and have the time to spare). I guess this would require more FreeCAD plugin writing experience (or storing code in the save file *shudder*).
Didn't find it because I never expected anyone to want to put this kind of functionality in a workbench.
It's definitely a useful plugin, but I find its UX is rather convoluted due to the multiple dialog click-throughs, name prefix cluttering and having to switch workbenches and hunt for buttons.
In my taste it's too "involved" for what is conceptually a simple task: stashing and fiddling with values. So I'll continue using and developing my macro.
Ideally, the ability to add/remove properties in App::FeaturePython (or even general) objects via right-click context menu should go into FreeCAD proper. This would obliviate the need for 90% of both plugins. I might attempt a hack to smarten up instances of App::FeaturePython, if I get more acquainted with manipulating the main window Qt elements (and have the time to spare). I guess this would require more FreeCAD plugin writing experience (or storing code in the save file *shudder*).
Re: Param object editor macro
A few updates:
- hidden variable differentiating it from other App::FeaturePython objects. This enables a nicer user interface via dropdown selection.
- "used in" lookup now properly respects word boundaries in expressions.
The current script creates slightly different objects and won't recognise the previous parameter holders. Those few who downloaded the previous versions can update by pasting this into the FreeCAD console with the correct param name inserted:
I'm also playing around with live updates of the window, whenever parameter variables are changed in the outliner. It works by using code roughly equivalent to:
Then I can use the onChanged() method of my ParamWindow class to update the display. The problem is that this can't be serialised into the save file any more, because the macro code is session-only (as it should be). Moreover, if I try to save (or let autosave trigger), the save file becomes corrupt and can't be opened any more.
Current implementation is in the macro, but commented out.
Any ideas on how to get nice window-updates going?
- hidden variable differentiating it from other App::FeaturePython objects. This enables a nicer user interface via dropdown selection.
- "used in" lookup now properly respects word boundaries in expressions.
The current script creates slightly different objects and won't recognise the previous parameter holders. Those few who downloaded the previous versions can update by pasting this into the FreeCAD console with the correct param name inserted:
Code: Select all
App.ActiveDocument.PARAMNAME.addProperty('App::PropertyBool', 'param_holder_marker', '', '', 4)
I'm also playing around with live updates of the window, whenever parameter variables are changed in the outliner. It works by using code roughly equivalent to:
Code: Select all
pwin = ParamWindow()
param = App::FeaturePython()
param.Proxy = pwin
Current implementation is in the macro, but commented out.
Any ideas on how to get nice window-updates going?
Last edited by donjan on Tue Aug 20, 2019 12:19 am, edited 1 time in total.
Re: Param object editor macro
Added live updating with a global addDocumentObserver(), then filtering for my object. Seems a bit overkill, but does the job.