I've made some changes to this macro. The idea here is to streamline and simplify this macro, both for the user and your humble developer. I removed the SSHelper object. I also removed the feature to add expressions from objects, such as Cube's, etc. to the spreadsheet. The macro will now focus on one thing (and hopefully do that one thing well) -- take named constraints from the document's sketches and convert them to aliases in a spreadsheet. I've left the old version, renamed as ConstraintsToSpreadsheetOld.FCMacro.py
on the github site. Here is a new animated .gif demonstrating its usage:
INFORMATION BELOW AND IN REMAINING POSTS RELATE TO OLD VERSION, SOME OF WHICH MIGHT BE NO LONGER APPLICABLE.
Latest bug fix: (2018.07.05b) --SSHelper object wasn't getting re-initialized upon re-creation, so it wasn't updating the Spreadsheet values. It had *one* job. Lol.
To get the macro to ignore a constraint name you should append an underscore (_) to the end of the constraint name, not at the beginning, as before. Underscores are okay for use in constraint names, but evidently not at the beginning. This was the source of some invalid constraint errors I was getting.
Old way to get macro to ignore constraint names: _prependToTheName;
new way: appendToTheName_
Spreadsheets are useful at times, but it can be very tedious to set them up. As an example, suppose you wish to create cells in the spreadsheet and link the values in those cells to your constraints in multiple sketches. You have to create the spreadsheet. You have to assign a label to the cell next to the cell you want to use for the value. You have to assign an alias to the value cell. You have to enter a valid value in the value cell. You have to set the constraint in the sketch to use the value cell in the spreadsheet. There are a lot of steps, a lot of left-clicking and right-clicking. That's where this macro comes in.
This macro automates the process of entering named constraints into a spreadsheet. All you have to do is give the constraint a name, the macro will do the rest.
To use it, select the sketches containing named constraints (and the spreadsheet if you already have made one) and run the macro. If a spreadsheet is part of the selection it will be used. If no spreadsheet is in the selection you will be prompted whether you want the macro to make one for you.
The macro then goes through all of the constraints in all of the selected sketches. Unnamed constraints are ignored. Elements without constraints are ignored. Named constraints get added to the spreadsheet and the constraint gets referenced to that cell in the spreadsheet, which said cell now has alias = constraint name.
Only columns A, B, C, and D are used. Anything in E, F, or beyond will not be modified. Each time the macro is run, columns A through D get reset and repopulated. The upshot of this is if you have multiple sketches linked to the same spreadsheet you will need to be sure to select all the sketches, along with the spreadsheet, each time you run the macro to update the named constraints. You only need to run the macro again when you've added more constraints to your sketch(es).
You should not have spaces or any non-ASCII characters in the constraint names.
There is an animated gif at the github site.