Is there any way to show all reference planes in a model and what is hosted to them?
Yes - but you need to work the other way around. You need to get all the elements you are interested in and then find what their host (FamilyInstamnce,.Host) is and check if that is a reference plane and the - if you want - if that is the reference plane you are interested.
But there are the odd elements that don’t have a Host property, - like ModelText. ModelText’s host lane is referenced by it’s Work Plane Parameter - SKETCH_PLANE_PARAM. And that is a string value. So, you then have to take the string and see if that is a reference plane, And model text is only sort of hosted. You need a plane to create it. But if that plane is deleted - it will remain and just say not associated.
I’m sure there are other elements like that, but don’t have a list off the top of my head.
Then if you want elemets that are lockex to a referenec plane - well taht’s a whole different thing.
You can use the element pre-delete script which deletes the element (i.e. in your case the reference plane) in a transaction that is rolled back and saves a list of the elements that would have been deleted. This won’t catch those items that simply become not associated.
dynamoPython/revitAPI/elementPreDelete.py at master · Amoursol/dynamoPython