Thanks for your suggestion George. But that would mean I need to find some kind of lifecycle hook that is triggered when the user imports a shared parameter via the Revit GUI. Inside the hook I would need to cancel the default import behavior and reimplement it in the way you propose.
But our plugin actually does not use shared parameter service. The problem is caused by the default behavior of Revit when importing a parameter from the service. Because of this I was hoping, there would be another solution.
Here are some steps to reproduce my problem:
1. Download https://apps.autodesk.com/RVT/en/Detail/Index?id=8706727659248635120&appLang=de&os=Win64
2. Open a new document. The code I sent you is executed.
3. Add an element to the document, e.g. a wall. You can verify that the parameter has been created by the code by selecting the element and finding "AUSSCHREIBEN.DE" in the parameter window in the group "ID-Daten" (probably "Id Data" in english).
4. Click on "Verwalten" (probably "Manage" in english)
5. Click on "Parameterdienst" (probably "Parameterservice" in english)
6. Click on the upload icon. Tooltip: "In Parameterdienst hochladen" (probably "Upload to parameter service" in english)
7. Select "Aktives Modell" (probably "active model") in radio button list, click on "Parameter hochladen" ("upload parameters"). All parameters from the current document are uploaded.
8. Close the document.
9. Open a new document. The code I sent you is executed again.
10. Add an element to the document, e.g. a wall. You can verify that the parameter has been created by the code by selecting the element and finding "AUSSCHREIBEN.DE" in the parameter window in the group "ID-Daten" (probably "Id Data" in english).
11. Click on "Verwalten" (probably "Manage" in english)
12. Click on "Projektparameter" (probably "Projectparameters" in english)
13. Click on the icon with the document and the cloud with Tooltip "Parameter aus Kategorie hinzufügen" (probably "Add parameter from category" in english)
14. In the list of parameters, "AUSSCHREIBEN.DE" is shown as "bereit" ("ready") and can be reimported into the project. If you reimport the parameter, it becomes user editable. We do not want that. Instead we expected the parameter to be shown as "Im Modell" ("in model") and to not be importable.
(Short sidenote: don't worry if you see the AUSSCHREIBEN.DE parameter twice in the shared paremter service window. This is intentional. One is an instance parameter, the other is a type parameter. Both have different guids.)
If you need more information to better understand my problem, I will be glad to provide more information.