Again, I hugely appreciate the effort, but there are some significant issues:
#1) [Environment clarification] > each project parameter must have a unique (case-sensitive) name so it shouldn't matter.
That statement is not true, and not what I tried (perhaps unsuccessfully?) to note. More than 1 project parameter can have the exact same case-sensitive name, provided they are shared and have different GUIDs. (If they're not shared, then yes the names must be unique - go figure!!!)
So, for example, I could have a project parameter that is a shared parameter called "Voltage" with the GUID 8AB7097C-015A-4FEB-99A9-585882951695, and I could add another project parameter that is a shared parameter (from a different shared parameters file) called "Voltage" with the different GUID 3BDF50E5-AC43-43CA-897E-46118EDBD066 and both would show up on the list of project parameters as "Voltage"
Worse, if they're in the same category and in the same group, in the Properties panel for an element of that category, the Revit user would actually see this:
Voltage
Voltage
If they're not in the same group, one could (for example) be at the top of the list and one could be at the bottom of the list, and the Revit user would probably just fill in whichever one they happened to see first. YES, we have at least 1 (very big) customer with this messed-up situation in their projects.
(And which one do you pick if you're trying to build a schedule???)
If those hadn't been shared parameters, and were just regular, non-shared project parameters, then Revit would not allow me to create a second project parameter called "Voltage" (again, go figure!). But if they're shared, I can have 2 of them. Or any number of them, if they all have different GUIDs.
However, what I also noted was that in a single shared parameters file each parameter definition must have a unique (case-sensitive) name. So it's easy to see how that could get confusing. (This whole Revit "feature" is messed up and confusing)
#2) Perhaps the biggest issue with this example code is that the code for this approach presumes (and requires) that family instances have been created for at least 1 category attached to every project parameter, and by extension that families actually already exist in the project for at least 1 category attached to every project parameter. That simply may not be the case. Instance project parameters can be defined and associated to categories for which no instances have yet to be created. There may not even be any families yet loaded into the project of those categories as well. A use case for this tool may be, for example, to QA check a project file that is used as a template, or one that is early in the project lifecycle.
#3) The code in the example appears to assume that if it's a shared parameter, it's not a project parameter. It further appears to assume that if it's not a shared parameter, it must be a project parameter. Neither of these assumptions is likely to ever be correct, or would only be correct under extremely tightly controlled circumstances, which unfortunately we don't have. Our code needs to work generically, on any project.
#4) And not at all insignificantly, wouldn't iterating over every parameter on every element in a project be OMG unbelievably miserably sloooow, especially for large projects?
The idea is very creative to be sure, and again the effort is very much appreciated, but unfortunately it doesn't seem to be robust enough to handle any project accurately, which is what we need.
Surely there's a better, more reliable/accurate way to get project parameter definition information, including whether or not a project parameter definition is shared and what its GUID is...?
Again, many thanks for your efforts!