Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit Tpiece geometric analysis

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Andrej.Licanin
269 Views, 3 Replies

Revit Tpiece geometric analysis

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?

 

Tags (4)
Labels (3)
3 REPLIES 3
Message 2 of 4

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
Message 3 of 4

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);
        }
Message 4 of 4

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report