recompute() is slow, how do I do it less?

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
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: recompute() is slow, how do I do it less?

Post by Roy_043 »

louisgag wrote: Tue Jul 28, 2020 11:33 am do you mean through the App:Link feature of 0.19?
This can actually also be used in this context. But after changes to the 'spreadsheet' file, only the spreadsheet 'Link' in the 'model' file is marked to be recomputed. So the user would have to remember to additionally recompute the whole 'model' file.
louisgag
Posts: 75
Joined: Fri Jan 17, 2020 9:59 am

Re: recompute() is slow, how do I do it less?

Post by louisgag »

Roy_043 wrote: Tue Jul 28, 2020 1:19 pm You can use the following syntax to reference values from an external file.

Code: Select all

NameOfOtherFile#NameOfSpreadsheet.Alias
Thank you very much, that's the best solution so far!

I made a script to quickly update all references to a local spreadsheet to point to the same cells from the spreadsheet of another file.
Replace "data" by the name of your spreadsheet file and both "Spreadsheet" by the name of your original and new spreadsheets:

Code: Select all

for obj in FreeCAD.ActiveDocument.Objects:
 for expTuple in obj.ExpressionEngine:
  newEE = re.sub(r'(^|[^#])Spreadsheet',r'\1data#Spreadsheet',expTuple[1])
  print ('Setting ' + expTuple[0] + ' of object ' + obj.Label + ' to ' + newEE)
  obj.setExpression(expTuple[0], newEE)
Post Reply