Relations between elements

Relations between elements

Anonymous
Not applicable
673 Views
5 Replies
Message 1 of 6

Relations between elements

Anonymous
Not applicable
Hi.

Is it possible to know the relations between different elements?
I mean: how can I identify the wall to which a particular window belongs or the walls belonging to a room?
The only way I have found is to compare the coordinates of the various elements.

Thanks.
0 Likes
674 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
There are several different situations, based on the type of elements.

- For windows to walls, for example, I think you can look at the Host property of the FamilyInstance

- For Rooms, you can look at the BoundarySegments, then get the element associated with each BoundarySegment.

This is an area of the API that's pretty well developed - you can get most anywhere you need to go.

-Matt
0 Likes
Message 3 of 6

Anonymous
Not applicable
In addition to what Matt has said , you could also try using element IDs to route connections between elements... Message was edited by: ramaseshan
0 Likes
Message 4 of 6

Anonymous
Not applicable
Thank you very much.

Matt, what do you mean when you say "get the element associated with each BoundarySegment"?
Can you post me a very short piece of code as an example?
Thanks again.
0 Likes
Message 5 of 6

Anonymous
Not applicable
I don't have an existing code snippet to post... but if you've got the API guide it's pretty straightforward...

Here's some quick and dirty pseudocode. It appears from the API that Rooms could have multiple Segment arrays (such as for a large outer room, with a central room in the middle), so you have to iterate in two levels to find the boundaries.

For a given Room object, you would:

IEnumerator ie = MyRoomObject.Boundary.GetEnumerator

while (ie.MoveNext())
{
BoundarySegmentArray bsa = (BoundarySegmentArray)ie.Current;

IEnumerator ie2 = bsa.GetEnumerator();

while (ie2.MoveNext())
{
BoundarySegment bs = (BoundarySegment)ie2.Current;

if (bs.Element is Wall)
{
// do something with the wall
}
}

}
0 Likes
Message 6 of 6

Anonymous
Not applicable
Thank you very much!
0 Likes