By Joe Ye
For a given duct object, we can get its section shape by the parameters. For example, rectangle duct has Height and Width parameter, and circle duct has Radius parameter.
However, for a given duct type, no methods/parameters/properties can be used to get the section shape. Here share a workaround how to retrieve the section shape for a given duct type.
The solution is to get the shape from the duct type’s related duct elbow fitting’s connector shape. The duct type has the parameter for different type of fittings, for example, “Elbow Fitttings”, “T Fittings”. We can get the fitting type. It is an FamilySymbol instance. Then open the family document that defined the elbow fitting. And get the DuctConnector objects. Now we can get the section shape by DuctConnector.Shape method.
Though this command can work, the performance is not good for a list of duct type. Because it needs to open family, this takes time for each one. Revit engineering team already know the request of a more efficient API to retrieve the duct section shape from the duct type.
Here is the full code for the command to get the duct type that is picked.
using Autodesk.Revit .DB;
using Autodesk.Revit .ApplicationServices;
using Autodesk.Revit.Attributes ;
public class RevitCommand : IExternalCommand
public Result Execute(
ref string messages,
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Selection sel = app.ActiveUIDocument.Selection;
Reference ref1 = sel.PickObject(
ObjectType.Element, "please pick a duct");
Duct duct = doc.GetElement(ref1) as Duct;
if(duct == null)
messages = "You didn't select a duct";
DuctType ductType = duct.DuctType;
//Get the duct type's elbow parameter value.
Parameter param = ductType.get_Parameter(
FamilySymbol symbol =
doc.get_Element(param.AsElementId()) as FamilySymbol;
Family family = symbol.Family;
Document familyDoc = doc.EditFamily(family);
FilteredElementCollector collector =
Element firstConnector = collector.FirstElement();
DuctConnector connector = firstConnector as DuctConnector;
TaskDialog.Show("Duct Section Shape", connector.Shape.ToString());
return Result.Succeeded ;