Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Revit Tpiece geometric analysis

Andrej.Licanin
Advocate

Revit Tpiece geometric analysis

Andrej.Licanin
Advocate
Advocate

Hello everybody,

 

Im trying to make a function that will take in a tpiece and return a coefficient base on a table from DIN 1988-300:

AndrejLicanin_0-1725006034457.png

I get T pieces by collecting family instances and checking the part type in the MEPModel field.

After that, I retrieved the connectors from the T piece and obtained the flow values, but I can't determine the coefficients based on just that. I would need some way to identify which connector is going straight and which one is branching off.

I thought the angle property could help me here, but no luck—in the families I'm looking at, they are all 0.  Any idea how to tackle this problem? How would i determine which connector is comming from the side at a t piece?

 

0 Likes
Reply
Accepted solutions (1)
398 Views
3 Replies
Replies (3)

jeremy_tammik
Autodesk
Autodesk
Accepted solution

Yes. You can look at the connector coordinate system:

  

  

Its Z axis point in the connector direction, so you can use that to determine the relative connector angles.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

Andrej.Licanin
Advocate
Advocate

Thanks Jeremy,it works
2024-09-02 15_50_36-Unity_calc_TpieceData.txt - Notepad.png

Here is the code for the function:

        public static Element AnalyzeTee2(Element element, Document doc)
        {
            Element elementAtAngle = null;

            // Check if the element is a FamilyInstance
            if (!PipeNetworkSplitter.isSplitter(element))
            {
                return null;
            }

            List<Connector> tpieceConnectors = getConnectors(element);


            Connector connector1 = tpieceConnectors[0];
            Connector connector2 = tpieceConnectors[1];
            Connector connector3 = tpieceConnectors[2];

            XYZ zVector1 = connector1.CoordinateSystem.BasisZ;
            XYZ zVector2 = connector2.CoordinateSystem.BasisZ;
            XYZ zVector3 = connector3.CoordinateSystem.BasisZ;

            if (AreVectorsParallel(zVector1,zVector2)) elementAtAngle = getConnectingConnector(connector3).Owner;
            if (AreVectorsParallel(zVector2,zVector3)) elementAtAngle = getConnectingConnector(connector1).Owner;
            if (AreVectorsParallel(zVector1,zVector3)) elementAtAngle = getConnectingConnector(connector2).Owner;

            return elementAtAngle;
        }
        public static bool AreVectorsParallel(XYZ vector1, XYZ vector2, double tolerance = 1e-6)
        {
            // Compute the cross product of the two vectors
            XYZ crossProduct = vector1.CrossProduct(vector2);

            // Check if the cross product is close to zero vector within the given tolerance
            return crossProduct.IsAlmostEqualTo(XYZ.Zero, tolerance);
        }

jeremy_tammik
Autodesk
Autodesk

Thank you for the confirmation! Shared on the blog for posterity:

  

  

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