Get SystemType value from a MEPSystem

wils02
Enthusiast

Get SystemType value from a MEPSystem

wils02
Enthusiast
Enthusiast

Below is a snippet from my code trying to just get the SystemType from a MEPSystem...

 

I took some code from Jeremy's post on Traversing the MEPSystems, but for the life of me cannot figure out how to return the SystemType of the system I am looping through. I can print the name, but I specifically need the SystemType. I want to see HydronicSupply or HydronicReturn or SupplyAir...etc.

 

Will someone please educate me on how to get this? if I have my elementfilter for MEPsystems, why can I not just loop through and say system.type.toString(); or something like this?

 

FilteredElementCollector systemCollector = new FilteredElementCollector(doc).OfClass(typeof(MEPSystem));

            IEnumerable<MEPSystem> desirableSystems 
                = systemCollector.Cast<MEPSystem>().Where<MEPSystem>
                (s => IsDesirableSystemPredicate(s));
            
            foreach (MEPSystem system in desirableSystems) {
                
                string cntdSys = system.*** WHAT DO I DO HERE? ***
                sb.Append("System Type: " + cntdSys + "\n");

0 Likes
Reply
Accepted solutions (1)
2,650 Views
3 Replies
Replies (3)

MarryTookMyCoffe
Collaborator
Collaborator
Accepted solution

MepSystem is base class for all systems

try this simple macro

		public void MepSystem()
		{
			Document doc = this.Application.ActiveUIDocument.Document;
			FilteredElementCollector systemCollector = new FilteredElementCollector(doc).OfClass(typeof(MEPSystem));
		
			        IEnumerable<MEPSystem> desirableSystems 
                = systemCollector.Cast<MEPSystem>();
            
            foreach (MEPSystem system in desirableSystems) {
			        	if(system.GetType() == typeof(Autodesk.Revit.DB.Plumbing.PipingSystem))
			        	{
			        		  Autodesk.Revit.DB.Plumbing.PipeSystemType type =  (system as Autodesk.Revit.DB.Plumbing.PipingSystem).SystemType;
			        	}
                string name = system.Name;
                
		}
		}

read about

Autodesk.Revit.DB.Plumbing.PipingSystem

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes

Anonymous
Not applicable

try this code

 FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(MEPSystem)).WhereElementIsNotElementType();
                    IList<ElementId> eids = collector.ToElementIds() as IList<ElementId>;
                   
                    foreach(ElementId eid in eids)
                    {

                        Element e = doc.GetElement(eid) as Element;
                        MEPSystem mepsys = e as MEPSystem;
                        ParameterSet ps = mepsys.Parameters as ParameterSet;
                        foreach(Parameter p in ps)
                        {
                           if(p.Definition.Name=="Type" && p.AsValueString()!="")
                           {
                                s = s + p.AsValueString()+"\n";
                           }
                        }
                    }
                    TaskDialog.Show("name",s);
0 Likes

wils02
Enthusiast
Enthusiast

MTMC,

 

Thanks, this got me pointed in the right direction. I didn't realize I could do this sort of thing:

 

PipeSystemType type =  (system as PipingSystem).SystemType;

 

I think I have some working code now that I will publish on the forums soon!

 

wils

 

0 Likes