Spreadsheets and Constraints

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!
Post Reply
coletreker
Posts: 2
Joined: Sat Apr 01, 2023 8:50 pm

Spreadsheets and Constraints

Post by coletreker »

Very new to FreeCAD, need help with simple issue: Basically, can I pull data into a spreadsheet from a sketch, do calculations on it, and feed those results back out to constrain other elements in the sketch. For example, I drew two lines at random acute angles attached to x-axis. Created a spreadsheet with two entries, angleleft and angleright, no aliases set yet. In the sketch, I put a constraint on the left angle to 30°and named it anglel. In the Spreadsheet, the cell next to angleleft (in this case B1) is set =Sketch.Constraints.anglel, this is fine and it pulls in the 30°. The cell next to angleright (B2) is then given the alias angler. The value of B2 is set to B1/2 which shows 15°, all is fine so far. Back in the sketch I attempt to set the right line angle using the angle constraint and formula editor, however, the Spreadsheet does not appear in the list, and I get errors for Spreadsheet.Constraints.angler. Tried using two different spreadsheets, no improvement. Any ideas would be appreciated.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Spreadsheets and Constraints

Post by chrisb »

You cannot use the same spreadsheet for input and output of the same sketch.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
coletreker
Posts: 2
Joined: Sat Apr 01, 2023 8:50 pm

Re: Spreadsheets and Constraints

Post by coletreker »

Thank you for the info. I did also read that in the Formula editor description which advised to used two different spreadsheets. I created a read and write spreadsheet to do the same task, this does not work either.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Spreadsheets and Constraints

Post by adrianinsaval »

you don't really need a spreadsheet to do calculations, you can do math directly on the constraints expressions and you can reference other constraints within the sketch.

Besides, that, Spreadsheet.Constraints doesn't make sense, that's the nomenclature for sketches, when referencing a spreadsheet cell use the cell directly or it's alias, for example Spreadsheet.B2 or Spreadsheet.angler but if this value is based on a constraint value from the same sketch this woul create a circular dependency which isn't allowed.
Post Reply