Spreadsheet: set true/false property in model data

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
User avatar
Roy_043
Posts: 1773
Joined: Thu Dec 27, 2018 12:28 pm

Re: Spreadsheet: set true/false property in model data

Postby Roy_043 » Wed Aug 12, 2020 11:13 am

DeepSOIC wrote:
Tue Aug 11, 2020 11:53 pm
BTW, it doesn't have to be done with a macro/py console
Ah yes. Thanks for pointing that out. Note that the field should not have the focus when you right-click (I found this a bit confusing).
drmacro
Posts: 1341
Joined: Sun Mar 02, 2014 4:35 pm

Re: Spreadsheet: set true/false property in model data

Postby drmacro » Wed Aug 12, 2020 12:02 pm

DeepSOIC wrote:
Tue Aug 11, 2020 11:53 pm
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.
Nice!

And things like Pad>Type are apparently text. (Though I still suspect somewhere under the hood they are enumerated... :?: )
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."

My beginners, written treatise: Learning FreeCAD
jmaustpc
Posts: 9991
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Spreadsheet: set true/false property in model data

Postby jmaustpc » Wed Aug 12, 2020 2:29 pm

These file I am referring to in this post will only work in FreeCAD 0.19 (or newer).
drmacro wrote:
Wed Aug 12, 2020 12:02 pm
DeepSOIC wrote:
Tue Aug 11, 2020 11:53 pm
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.
Nice!

And things like Pad>Type are apparently text. (Though I still suspect somewhere under the hood they are enumerated... :?: )

This is a little demo set of files (made in FreeCAD 0.19 from the Daily PPA on Ubuntu Linux) that you may find interesting...
testexpression.FCStd
(23.59 KiB) Downloaded 4 times
The file "testexpression" contains a simple PartDesign Body object created by a Pad and then a Pocket, both the sketches for these are attached to the xy plane hence not directly to a solid. There are also two spreadsheets, "spreadsheet and spreadsheet001".

Pad (and pocket) has a property "Midplane" (True or False), pocket has a property "Reversed" (True or False).

I have used the spreadsheets and expressions such that if you toggle the Pad's "Midplane" property, the subsequent Pocket's "Midplane" property will change as well. Also I have used an Expression in on of the spreadsheets to see if Midplane for the Pad is False and if so to make the "Reversed" for Pocket toggle to True so that the pocket still goes through the Pad rather than trying to pocket in the wrong direction hence doing nothing.

note: -
FreeCAD will not allow a cyclic dependency and it checks for this currently at the "spreadsheet" object level, which means you need to use one spreadsheet to read values from an object and a second spreadsheet to provide a value for an object to read into a property with an expression.


So if you go to Pad in combo view and toggle Midplane between true and false, you will see Pocket's Midplane and Reversed also toggle.

"Spreadsheet001" is just reading the Midplane property value of Pad whereas "Spreadsheet" is reading the Pad Midplane property value but not directly its doing so by reading from Spreadsheet001, doing a test and then telling Pocket how to set both its Midplane and Reversed properties.
testexpression2.FCStd
(25.02 KiB) Downloaded 4 times
The second file "testexpression2", demonstrates the same thing except it is all done in one spreadsheet which can be done in this case because the property being read is from a different object to the properties being driven. The red is the reading from "Pad" cells and the green is the driving "Pocket" cells.
testexpression3.FCStd
(20.41 KiB) Downloaded 4 times
The third is similar but tries to read the Midplane property from the "Pocket" and drive the Reversed property of the same object "Pocket". Which creates a cyclic dependency so FreeCAD will show an error about it not being a DAG. :)

Jim
drmacro
Posts: 1341
Joined: Sun Mar 02, 2014 4:35 pm

Re: Spreadsheet: set true/false property in model data

Postby drmacro » Wed Aug 12, 2020 2:55 pm

jmaustpc wrote:
Wed Aug 12, 2020 2:29 pm
This is a little demo set of files (made in FreeCAD 0.19 from the Daily PPA on Ubuntu Linux) that you may find interesting...
Just spent 2 hours making a similar video... 8-)

Sooooo, never mind. :lol:
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."

My beginners, written treatise: Learning FreeCAD