Spreadsheet: set true/false property in model data
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Spreadsheet: set true/false property in model data
In the properties data tab the little blue fx icon allows you to get the value from the spreadsheet.
But, some properties are true/false and give a control that allows the user to select true or false.
Is there a way to set this property from a spread sheet?
But, some properties are true/false and give a control that allows the user to select true or false.
Is there a way to set this property from a spread sheet?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Spreadsheet: set true/false property in model data
AFAIK boolean properties aren't expression aware, thus can't be directly bound to a spreadsheet value.
You can do that with a macro, but it will be neither saved in the document nor working on another installation.
You can do that with a macro, but it will be neither saved in the document nor working on another installation.
Re: Spreadsheet: set true/false property in model data
I suspected as much.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Spreadsheet: set true/false property in model data
Something like this works:
Code: Select all
App.ActiveDocument.Box.setExpression('MapReversed', u'Spreadsheet.MyBool')
Re: Spreadsheet: set true/false property in model data
Just to be sure I understand...which can always be questionable.Roy_043 wrote: ↑Fri Aug 07, 2020 7:01 pm Something like this works:Code: Select all
App.ActiveDocument.Box.setExpression('MapReversed', u'Spreadsheet.MyBool')
That code would need to be run each time the spreadsheet cell was changed, correct?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Spreadsheet: set true/false property in model data
Nope. 'setExpression' sets an expression binding inside the expression engine, which will be updated on recompute automatically.
I hadn't expected this to be possible. Thx Roy, will try it also.
Re: Spreadsheet: set true/false property in model data
Finally getting back around to this...
I tried it and it works great.
The 'u' in
Code: Select all
...u'Spreadsheet.MyBool'...
How does one do that for, say, Pad > Type which is probably an enumerated value?
I tried:
Code: Select all
App.ActiveDocument.Pad.setExpression('Type', u'Spreadsheet.PadType')
I also tried other than 'u' to no avail.
(I couldn't really find a good reference for the construct in Python docs (probably don't know what to search for...) and I still get cross eyed when I attempt to read the API docs for FreeCAD. )
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Re: Spreadsheet: set true/false property in model data
I think so too. But I am not sure.
Pad Type is a string value. You can easily check this:
Code: Select all
App.ActiveDocument.Pad.Type
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Spreadsheet: set true/false property in model data
BTW, it doesn't have to be done with a macro/py console. In 0.19, realthunder has added a gui method, too.
1. Right-click in property editor, "Show all"
2. Right-click on the property you want to drive with an expression, click "Expression", type the expression, done!
With this method, it is also possible to assign vectors and placements in one go.
1. Right-click in property editor, "Show all"
2. Right-click on the property you want to drive with an expression, click "Expression", type the expression, done!
With this method, it is also possible to assign vectors and placements in one go.