How to get the parent of an attached Wall sub-element

0001des
Enthusiast

How to get the parent of an attached Wall sub-element

0001des
Enthusiast
Enthusiast

I'm still working on this weird wall issue.  I think people would understand my issue better if I did it in the UI, then showed you the pictures.  Then we can figure out how to do this in the API's.

 

Main objective: How can I access (via API's) all the associated geometry of a wall with many components inside it?  More importantly, how can I get the parents of an object, if I have the ElementID number of a sub-element?

 

I have a client with several walls containing odd geometry.  I need a way to get the script to identify these oddballs.  I've been using Try-catch for now, but it's slow.  

 

I want to hide the geometry that isn't the oddball low-wall.  I've tried to do this in the UI and API's, but it appears I cannot.  The main wall appears to be the "parent" and if the main wall hides, then all the sub-elements are hidden.  See images:

 

Here's the wall.  It has a top and bottom element.  When I select it, it selects the whole wall.Here's the wall. It has a top and bottom element. When I select it, it selects the whole wall.If I want to select the low wall, I have to use the "select by ID" feature.If I want to select the low wall, I have to use the "select by ID" feature.I can hide this part of the wall using the UI.I can hide this part of the wall using the UI.The main wall stays shown (or in the Revit vernacular, "Unhidden").The main wall stays shown (or in the Revit vernacular, "Unhidden").Here's the sub-wall in the hidden space.Here's the sub-wall in the hidden space.I can unhide this sub-wall in the hide space.I can unhide this sub-wall in the hide space.I can select the main wall....I can select the main wall....I can hide the main wall, and it hides everything in the wall.I can hide the main wall, and it hides everything in the wall.Hidden.Hidden.Here's the entire wall in Hidden Space.Here's the entire wall in Hidden Space.I use the "select by ID" feature to select the sub-wall in Hidden Space....I use the "select by ID" feature to select the sub-wall in Hidden Space....And when I "unhide"  (show) the object, it stays hidden.And when I "unhide" (show) the object, it stays hidden.

So, my problem is, I can write a script that hides all the walls.  And when I use "UnhideElements" method, the sub-walls do not unhide, because they are in the sub-group of the main wall that is hidden.  

 

How can I use the API's to retrieve all the sub-walls in my wall?  Then I can make a subroutine that will show the parent wall, and hide all the sub-walls except the one I want to see.

 

How can I use my sub-wall's ID number to find the parent wall?  I have the sub-wall element ID.  How can I use that to find the parents of an object?  

 

thanks, 

0 Likes
Reply
Accepted solutions (1)
985 Views
6 Replies
Replies (6)

jeremytammik
Autodesk
Autodesk

I can imagine several different approaches.

 

Have you tried retrieving all wall elements intersecting one of the walls'  bounding box?

 

Have you compared the different walls' location lines? Are they possibly identical? Or, identical except for the Z component? Or just parallel and pretty close to each other?

 

Your question is ambiguous; at the beginning, you say you want to retrieve the parent wall; at the end, you say you want to retrieve all the sub-walls.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

FAIR59
Advisor
Advisor
Accepted solution

your "odd-ball"wall is a stacked wall.

for the parent wall:

			//check if wall is a stackedwall
			wall.IsStackedWall;
			// get all the member walls
			wall.GetStackedWallMemberIds();

for a memberwall:

			// check if wall is member of a stackedwall
			wall.IsStackedWallMember;
			// get "parent" wall
			wall.StackedWallOwnerId;

0001des
Enthusiast
Enthusiast

Brilliant answer.  Thank you.

0 Likes

0001des
Enthusiast
Enthusiast

Thanks again for your post.  It solved my problem and I am able to get the parents without any issues.

 

I have a secondary question.  This works when I recast the element into a type "wall."  I sometimes have elements that are parts of a greater assembly, but are not just a wall.  Is there a method for getting any parent object generically?  I'm used to coding in CATIA, and you can get parents basically regardless of the type declaration.

0 Likes

0001des
Enthusiast
Enthusiast

Bump.

 

Anyone know if Is there a method for getting any parent object generically?

0 Likes

jeremytammik
Autodesk
Autodesk

The most generic thing I can think of in that direction is the family instance `Host` property:

 

https://apidocs.co/apps/revit/2019/69f30141-bd3b-8bdd-7a63-6353d4d495f9.htm

 

Much more limited than what you describe, though.

 

Something generic such as you describe can be implemented in various ways, e.g., using a filtered element collector using the element geometry or bound box intersection, or by ray tracing analysis to discover adjacency and containment.

 

Details depend on your exact requirements, though.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes