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
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.
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...
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.
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.
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.
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.