How to create duct with fittings .

How to create duct with fittings .

MohammedHussam
Explorer Explorer
193 Views
2 Replies
Message 1 of 3

How to create duct with fittings .

MohammedHussam
Explorer
Explorer
public static Duct Create(
	Document document,
	ElementId ductTypeId,
	ElementId levelId,
	Connector startConnector,
	Connector endConnector
)

How to get the connectors , i am trying to create the duct from cad lines i am unable to get the connectors ,looking for someone who would help me to solve my issue .

0 Likes
Accepted solutions (1)
194 Views
2 Replies
Replies (2)
Message 2 of 3

Charles.Piro
Advisor
Advisor
Accepted solution

Hi,

 

you can create a duct with two points (XYZ) :

public static Duct Create(
	Document document,
	ElementId systemTypeId,
	ElementId ductTypeId,
	ElementId levelId,
	XYZ startPoint,
	XYZ endPoint
)

 

Next, for fittings, you need to create them with the connectors of the ducts. Here is a exemple of how to find the connectors and create an elbow :

 

//create the ducts
Duct newduct = Duct.Create(doc, mepSystemId, ductTypeId, levelId, pt1, pt2);
Duct newduct2 = Duct.Create(doc, mepSystemId, ductTypeId, levelId, pt2, pt3);

//find the connectors at point 2 :
Connector connectorElbow1 = null;
Connector connectorElbow2 = null;
foreach (Connector connectduct in newduct.ConnectorManager.Connectors)
{
      if (connectduct.Origin.IsAlmostEqualTo(pt2))
      {
          connectorElbow1 = connectduct;
      }
}

foreach (Connector connectduct in newduct2.ConnectorManager.Connectors)
{
        if (connectduct.Origin.IsAlmostEqualTo(pt2))
        {
             connectorElbow2 = connectduct;
        }
}

//Create Elbow
FamilyInstance newElbow = doc.Create.NewElbowFitting(connectorElbow1, connectorElbow2);

 

😉



PIRO Charles
Developer

PIRO CIE
Linkedin


0 Likes
Message 3 of 3

MohammedHussam
Explorer
Explorer

Thank you @Charles.Piro  i have tried ur method but with cabletrays   and it worked but what if there is a 3 way Tee Fitting and 4 Way Cross Fitting , how to  handle for such conditions .

 

MohammedHussam_1-1754743774343.png

 

0 Likes