A mechanical system is created and is not connected with a duct. Not quite familiar yet. record it.
Connectorset = New Connectorset ();
Connector baseconne = Null ;
Connectorsetiterator CSI = Null ;
Elementset Selection = Sel. elements;
Foreach (Element E In Selection)
{
If (E Is Familyinstance)
{
Familyinstance fi = E As Familyinstance;
Family = Fi. symbol. Family;
If (Family. familycategory. Name = " Mechanical Equipment " )
{
If ( Null ! = Fi. mepmodel)
{
CSI = Fi. mepmodel. connectormanager. connectors. forwarditerator ();
While (CSI. movenext ())
{
Connector Conn = CSI. Current As Connector;
If (Conn. Direction = Flowdirectiontype. Out && Conn. ductsystemtype = Ductsystemtype. supplyair)
{
Baseconnector = Conn;
Break ;
}
}
}
}
Else If (Family. familycategory. Name = " Air duct end " )
{
CSI = Fi. mepmodel. connectormanager. connectors. forwarditerator ();
CSI. movenext ();
Connectorset. insert (CSI. Current As Connector );
}
}
}
Mechanical System = Null ;
Pipingsystem = Null ;
If ( Null ! = Baseconnector && Connectorset. Size > 0 )
{
Machicalsys = Doc. Create. newmechanic icalsystem (baseconnector, connectorset, ductsystemtype. supplyair );
// Pipingsystem = Doc. Create. newpipingsystem (baseconnector, connectorset, pipesystemtype. supplyhydronic );
}
From: http://revit.5d6d.com/thread-858-1-1.html