Get Space of Element

Hello Everyone,
I’m trying to get the name of the space, where my elements are located. For some reason, my python script throws me back IronPython.Runtime.Types.ReflectedIndexer.

What do I do wrong here?

I don’t think you are using the type() == FamilyInstance correctly. Try something like this:
if element.GetType() == typeof(FamilyInstance):

If I’m not mistaken, typeof() is used in C#, whereas the Python equivalent would be isinstance(). e.g.

if isinstance(element, FamilyInstance):
    # do stuff

The only explanation I have for OP’s issue is that the Python node is assuming that they are trying to access this specific property which requires a phase to be provided as an indexer.

For example, assuming phase is an actual Phase object:

room = element.Space[phase]

2 Likes

Thank you for your answer. Sadly python doesn’t seems to handle “typeof” method.

isinstance() has gave me the exact same results, than my previous solution, but passing the “phase” as an argument has solved it. Thank you!

1 Like

Hi @tamasorosz
Does the script works like Spaces which are made in the file. the elements within it would be detected?
If yes, how will it work for the elements which are passing from multiple spaces (say ducts )

@Nissal, My script detects the Room Calculation Point for each element, and then identifies that in which room the room calculation point is located in.
I’m not sure, what would happen if I use a line family, like duct, but it isn’t a problem in this case, since I’m getting my family list from electrical circuits.
Here is the final code for getting the space:
getSpace