Desperately need to check if wall-based FamInstance is placed on the particular material layer

Hi all! I desperately need to check if my wall-based electrical socket outlets is placed on the side of the wall that has particular material. My goal is to stick with the python only as I will share this script via pyRevit later.
Walls is compound-structured, with thick core and thin finishing layers. I need to change checkbox values in socket instances IF they are based on the side of the walls that has particular material. Quick lookup shows that wall-based families has no HostFace parameter, and I found HostParameter useless while it gives me same value for all sockets.
I was trying to get bounding box both from sockets and from wall finishing layers, but it turns out that you can’t just get BB from compound layer. Checking for collision of socket and whole wall is useless.
So far i ran out of ideas, and hope that someone will advise me to look into another method.
Thanks in advance for any thoughts!

Some hoops to jump though, but a combination of the below should get you started:

MaterialElementId Property will give you the material applied to a given face.

HostFace Property will give you the reference face from a given family instance.

From there you may have to compare the reference face of the instance to the references of the overall host by something like EqualTo Method to confirm you’re working with he correct mapping.

It’s not simple, but certainly achievable. Give it a shot and let us know where you get!

2 Likes

Thanks for reply!
But as I mentioned earlier - my socket families is wall-based, so HostFace returns null.
Or am I missing something?

UPD: although if I make this family face-based it gives me REFERENCE_TYPE_SURFACE in HostFace. Maybe I just need to remake this sockets to be face-based

Ah! In which case you could query the wall’s faces and fixture’s location point, and find the face which intersects your point, and use that to pull the material from.