Hello FreeCAD fourms! I came here from the irc channel on libre.
I just got this nifty SpacePilot pro and it has been working awesome! but there are a few things missing, i noticed that i cant use the translation lock, rotation lock and dominant mode buttons in freecad, freecad has checkboxes for these settings, but in the tools > customize > spaceball buttons you cant select checkboxes as a thing to tie a spaceball button to.
Anyway, you *can* select macros! so, my plan is to find a way to write a macro that can toggle that specific checkbox on and off! I looked through the example code posted on the fourm and on irc and i still feel lost, links to documentation would be awesome! Thank you so much!
Toggling a checkbox with a macro?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 1
- Joined: Sat Dec 04, 2021 5:50 pm
Re: Toggling a checkbox with a macro?
Not clear what you want.
Do You want to write a macro that select a checkbox, or to toggle some preferences?
They are different things, many settings could be simply toggled using proper commands in Python (that could be put in a Macro, that is simply a Python script, with a different extension).
Better to modify the title of this thread to something like that refer to the dialog you are trying to modify, toggling a checkbox is simply to refer to the checkbox and setting it to True or False.
The point is how to obtain a Qt reference for this checkbox, and sometimes it is not exposed as a child of the MainWindow, directly, so you have to mimick "Gui actions" that is not a "robust way" to do things.
Alternatively if they are exposed as a "parameter", you could set the proper parameter, using this syntax:
"User parameter:BaseApp/Preferences/.... will be the path to the parameter
while:
parameter_name are the name of the parameters (usually as written in the dialog)
Value is the desired value.
If you issue Saveparameters modifications are written in the preferences, and became persistent, if not they are used in this session only.
Hope it helps.
Regards
Carlo D.
Do You want to write a macro that select a checkbox, or to toggle some preferences?
They are different things, many settings could be simply toggled using proper commands in Python (that could be put in a Macro, that is simply a Python script, with a different extension).
Better to modify the title of this thread to something like that refer to the dialog you are trying to modify, toggling a checkbox is simply to refer to the checkbox and setting it to True or False.
The point is how to obtain a Qt reference for this checkbox, and sometimes it is not exposed as a child of the MainWindow, directly, so you have to mimick "Gui actions" that is not a "robust way" to do things.
Alternatively if they are exposed as a "parameter", you could set the proper parameter, using this syntax:
Code: Select all
param_grp=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/....")
param_grp.SetString("parameter_name", "Value")
FreeCAD.saveParameter
while:
parameter_name are the name of the parameters (usually as written in the dialog)
Value is the desired value.
If you issue Saveparameters modifications are written in the preferences, and became persistent, if not they are used in this session only.
Hope it helps.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Toggling a checkbox with a macro?
No answer to your question, but I think the far better way to solve this, is to fix the root of the problem, i.e. the mouse buttons. See here for a proposal: https://forum.freecadweb.org/viewtopic. ... 65#p517486
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.