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);
😉