Find Which Elements are Attached to an Element

Find Which Elements are Attached to an Element

JC_BL
Advocate Advocate
473 Views
6 Replies
Message 1 of 7

Find Which Elements are Attached to an Element

JC_BL
Advocate
Advocate

I would like to know if there is a way to find out the elements that are attached to an element.

 

I use MEP Fabrication Ductwork in Revit.  One thing that I want to know is "exactly" which end-cap is attached to which duct body.  I also want to know if an access door is attached to which side of the duct body.  Then our system can communicate with our worker about which duct needs which end-cap (or access door).

 

One thing that I may try is to find out the 3D-coordinates of the duct body and the end-cap (or access door) and see if they are close enough.  That's how I find if an end-cap or access door is attached to a duct body in CADmep.  But that is complicated.  Now that I am in Revit, I would like to see if there is a better and easier way to do this.

 

Please help.  Thanks.

 

JC_BL

0 Likes
Accepted solutions (1)
474 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni

There are many ways in Revit to determine which element is connected with another. Some elements can join at their endpoints, or by joining their geometry. If your question is purely related to MEP elements that can be officially connected with each other, that relationship can be queried through the MEP connection manager. Please refer to the Revit SDK sample TraverseSystem. It shows how to traverse a well-connected mechanical or piping system in the direction of flow and dump the traversal into an XML file.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 7

JC_BL
Advocate
Advocate

Thanks for showing me one possible way to find the link between elements.

 

Unfortunately this tip doesn't seem to work for elements that are FabricationPart.  The tip needs to work with MEPSystem.  I thought FabricationPart should be considered as MEP element because it is also referred to as MEP Fabrication Ductwork.  I am surprised that it is not. 

 

When I use the following code to retrieve elements from a Revit file that has many FabricationPart's, I get nothing:

FilteredElementCollector systems =
   new FilteredElementCollector( doc ).OfClass( typeof( MEPSystem ) );

 

When I check the Connector.MEPSystem of a connector in a Fabrication Part, it is null.

 

Moreover, seem like in order for the tip to work, I need to be able to get access to the Elements property of an element (that is an ElementSet).  Unfortunately FabricationPart doesn't have that property.

 

Seem like that tip only works with elements that are MEPSystem, and unfortunately FabricationPart is not a MEPSystem.  Very disappointed.

 

Still, I appreciate for the fact that you try to help.

 

JC_BL

0 Likes
Message 4 of 7

JC_BL
Advocate
Advocate

So far, I can use the "Origin" of the connectors (in ConnectorManager) of a duct-body and an end-cap to link them together.  They turns out to be the same if the end-cap is attached to the duct.  I can also use the same way to link a volume damper to a duct body.  This is the good news.

 

The bad news is that I cannot use this method to link an Access Panel to a duct body that it is attached to.  I also cannot use this method to link a duct (such as Boot Tap) to a duct body that it is attached to.  The common characteristic of these 2 cases is that the Access Panel and the Boot Tap are attached to the "side" of a duct body instead of attaching to the end of the duct body.  The Origin of the connector in ConnectorManager of the duct body is actually pointing at somewhere along the center line of the duct body.  On the other hand, the Origin of the connector in ConnectorManager of the Access Panel is pointing at the attachment point on the side of the duct body.  The difference is shown in the picture below:

JC_BL_0-1707753822918.png

I need a way to determine if the Origin of the Access Panel is along the center line of the duct body with a distance of half of the duct body width.   Or put this in another way: How to project outward a point that is along the center line of a duct body to the side of the duct body?  Please note that an Access Panel tends to be placed in the middle of the duct body (in term of depth).  Therefore, I don't worry about if the Access Panel is placed 3 inches above the center line or below the center line.  This is all just an approximation.

 

I used to use functions Item.GetConnectorWidthVector() or Item.GetConnectorDepthVector() in Fabrication API to solve this problem.  Is something like these available in Revit-API?

 

Please let me know if such a function available.  Thanks in advance.

 

JC_BL

0 Likes
Message 5 of 7

JC_BL
Advocate
Advocate

I believe I can project the point in the center line of the duct body to the side of the duct body.  This is based on the nature of ductwork.  Ductwork is always laying flat.  It can go up or down.  But it won't rotate along its center line axis.  This means I can use the center line to create a vertical "surface", and then use Surface.Project() function to see if the Origin of an Access Panel is close to one of the connector of the duct body.

 

I believe this should work, and I will find out if this really works.

 

JC_BL

0 Likes
Message 6 of 7

jeremy_tammik
Alumni
Alumni
Accepted solution

You can query a fabrication part for its connector manager and retrieve the connector objects from that. Each connector has a location. The location can be used to determine other neighbouring parts. The neighbourship relationships can be used to determine the graph of connected parts. A similar approach is used by the TraverseSystem SDK ample that I pointed out. Here is a code snippet accessing a fabrication part's primary connector and using that to determine its local coordinate system:

    

    /// <summary>
    /// Return LCS of a duct, its local coordinate
    /// system, defined by the primary connector.
    /// </summary>
    static Transform GetDuctLcs(FabricationPart part)
    {
      ConnectorManager conmgr = part.ConnectorManager;
      ConnectorSet conset = conmgr.Connectors;
      Connector start = GetPrimaryConnector(conset);
      // Transform from local duct to world coordinate system
      Transform twcs = start.CoordinateSystem;
      Debug.Assert(Util.IsEqual(1, twcs.Determinant), "expected 1 twcs determinant");
      // Flip so that Z axis points into duct, not out of it
      twcs.BasisY = -(twcs.BasisY);
      twcs.BasisZ = -(twcs.BasisZ);
      Debug.Assert(Util.IsEqual(1, twcs.Determinant), "expected 1 flipped twcs determinant");
      return twcs;
    }

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 7 of 7

JC_BL
Advocate
Advocate

Thanks for pointing out that we can use ConnectorManager to link one duct to another duct.  And this works.

 

JC_BL

0 Likes