how to add expression feature to a QuantitySpinBox

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
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

how to add expression feature to a QuantitySpinBox

Post by uwestoehr »

I work frequently with Part/PartDesign primitives and it annoys me that I can define the offset using expressions but not the angle:
Screenshot of TaskAttacher dialog
Screenshot of TaskAttacher dialog
FreeCAD_oKAWuIXQWJ.png (10.97 KiB) Viewed 874 times

Therefore I wanted to add the missing expression feature but cannot figure out how. Has anybody a pointer for me please to learn how this is done?
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: how to add expression feature to a QuantitySpinBox

Post by openBrain »

As this angles are basically yaw/pitch/roll, I advise that you have a look at notes of issue #4106 and related links before getting started. ;)
chrisb
Veteran
Posts: 54302
Joined: Tue Mar 17, 2015 9:14 am

Re: how to add expression feature to a QuantitySpinBox

Post by chrisb »

It seems that these are not enabled for expressions for the same reason as the Placement dialog is not expression aware: They are already calculated values.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: how to add expression feature to a QuantitySpinBox

Post by uwestoehr »

openBrain wrote: Thu Mar 19, 2020 10:30 pm As this angles are basically yaw/pitch/roll, I advise that you have a look at notes of issue #4106 and related links before getting started. ;)
My question is not bound to these specific SpinBoxes, but in general: How do I add the expression feature to a SpinBox?
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: how to add expression feature to a QuantitySpinBox

Post by wmayer »

uwestoehr wrote: Fri Mar 20, 2020 3:29 am My question is not bound to these specific SpinBoxes, but in general: How do I add the expression feature to a SpinBox?
https://github.com/FreeCAD/FreeCAD/blob ... rs.cpp#L97

All what's needed is to use the bind for the property you want to control. The ability to set expressions is done automatically.
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: how to add expression feature to a QuantitySpinBox

Post by uwestoehr »

wmayer wrote: Fri Mar 20, 2020 7:41 am All what's needed is to use the bind for the property you want to control. The ability to set expressions is done automatically.
Many thank!
Post Reply