Constraints to two different objects
You can use intermediate empties to do that. Here is a UI version (not Python).

For ID1:

Hook ID1 to an empty placed at its location. Then after that shrinkwrap the empty to the plane.

For ID0 and ID2:

Hook them the same way: place 1 empty at the location of the wanted vertex, hook the vertex. But here after that, add a "clamp to" constraint to the empties.



How to hook:



Note: for ID0 and 2, you can also use 1 empty for both if you want to keep a constant distance between them:


Select them both
Place the cursor at the middle
Move the empty to the cursor
Do the hook on both


The file here contains this last version:



Following the question in the comments: keeping the shape "rigid", here is another setting.


The prism is constrained by a bone
The bone follow an empty which is clamped to the curve
The bone also tracks to a second empty
This second empty: shrinks to the plane, is limited in distance from the first empty and shrinked again to the plane




The new file: