Sort Plumbing Fixture list such as System Browser

Sort Plumbing Fixture list such as System Browser

reylorente1
Collaborator Collaborator
584 Views
3 Replies
Message 1 of 4

Sort Plumbing Fixture list such as System Browser

reylorente1
Collaborator
Collaborator

I would like to the list of Plumbing Fixture, as it appears in the System Browse

 

Quisiera ordenar la lista de mueble sanitario, tal como aparece en el System Browser

2021-03-07 (2).png Here is the script

 

public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Aplicación app = uiapp.Application;
Document doc = uidoc.Document;

string nombre_mueble = string.Empty;

//Extract all pipe system
foreach (PipingSystem pipingSystem in new FilteredElementCollector(doc)
.OfClass(typeof(PipingSystem)).WhereElementIsNotElementType().ToList())
{
// Get the Domestic Cold Water type
if (pipingSystem.SystemType == PipeSystemType.DomesticColdWater)
{
var elemset = pipingSystem.PipingNetwork;
foreach (Element elem in elemset)
{
FamilyInstance fi;
if (elem is FamilyInstance)
{
fi = elem as FamilyInstance;
if (fi != null)
{
MEPModel mEPModel = fi.MEPModel;
if (mEPModel is MechanicalFitting)
{
MechanicalFitting mf = mEPModel as MechanicalFitting;
//....
//...
//...
}
if (fi.Category.Id == new Elemento(BuiltInCategory.OST_PipeFitting))
{
//...
//...
//...
}
if (fi.Category.Id == new ElementId(BuiltInCategory.OST_PlumbingFixtures))
{
IList<Connector> connectorse = GetConnectors(fi);

foreach (var connector in connectorse)
{
if (connector.PipeSystemType == PipeSystemType.DomesticColdWater)
{
// var mepConnectorInfo = connector.GetMEPConnectorInfo() as MEPFamilyConnectorInfo;
// var parameterValue = (DoubleParameterValue)mepConnectorInfo.GetConnectorParameterValue(new ElementId(BuiltInParameter.CONNECTOR_DIAMETER));

// diametro_mueble = UnitUtils.ConvertFromInternalUnits(parameterValue. Value, UnitTypeId.Millimeters).ToString();
nombre_mueble += connector.Owner.Name + "\n"; //This is where I find the names
}
// demanda_m = connector.Demand.ToString();//Demanda del mueble

}
}

}
}
}

}
TaskDialog.Show("Revit_Informacion", nombre_mueble);
}
return Result.Succeeded;
}

 

#region Recuperar conectores de FamilyInstance
static IList<Connector> GetConnectors(FamilyInstance inst)
{
//1. Cast Element to FamilyInstance
//FamilyInstance inst = element as FamilyInstance;
//2. Get MEPModel Property
MEPModel mepModel = inst.MEPModel;
//3. Get connector set of inst
ConnectorSet connectorSet = mepModel.ConnectorManager.Connectors;
//4. Initialise empty list of connectors
List<Connector> connectorList = new List<Connector>();
//5. Loop through connector set and add to list
foreach (Connector connector in connectorSet)
{
connectorList.Add(connector);
}
return connectorList;
}
#endregion

 

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

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @reylorente1,

I am not aware of any such API.

 

Have a look at this below link

https://forums.autodesk.com/t5/revit-api-forum/filteredelementcollector-or-elementset-order-by-close... 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

jeremy_tammik
Alumni
Alumni
Accepted solution
0 Likes
Message 4 of 4

reylorente1
Collaborator
Collaborator

Gracias!!

Thank You!!

Спасибо!!

0 Likes