If I understand correctly, your question is whether we could introduce a feature in Control plus Studio, allowing add-on object definitions to specify a specific parent type required by the add-on.
At the moment, the hierarchy rules consider the node type, nothing else. Add-ons are allowed on every handler, that's it. Sure, it would be possible to introduce another field in the OOD file specifying the required parent type. But this would be quite a big effort, because it affects drag/drop and copy/paster operations as well. And I don't know how frequent this use-case would be.
Actually I find your solution perfectly OK. Generating an error pragma in the PLC code is not super-nice, but it works. (I don't see how this should perceptibly increase export time.)
My other question would be: Why does the programmer expect this add-on to work on a handler where it should not be placed? If the add-on really doesn't make sense on a specific handler type, he shouldn't have a motivation to put it there. Or at least the mistake shouldn't happen very often.
I don't say your feature suggestion doesn't make any sense. It's just my feeling that it's not very urgently needed.
... View more