MEP Fabrication Parts Service Group


Is the a way to know the service group of an element (MEP Fabrication Pipework). I looked up the Revit API 2020 and haven’t found anything.


Thank you in advance.


Hello @blsalvio
try this

import clr
from Autodesk.DesignScript.Geometry import *

import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Fabrication import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
def getGroupName(lstServiceFab, fabPart):	
	famName = fabPart.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString()
	for servicFab in lstServiceFab:
		for x in range(servicFab.GroupCount):
			countButton = servicFab.GetButtonCount(x)
			groupName = servicFab.GetGroupName(x)
			for y in range(countButton):
				fabServiceButton = servicFab.GetButton(x,y)
				for conditionInt in range(fabServiceButton.ConditionCount):
					condName = fabServiceButton.GetConditionName(conditionInt)
					if 	fabServiceButton.ServiceId == fabPart.ServiceId and condName == famName:				
						return groupName				

fabPart = UnwrapElement(IN[0])
fabConf = FilteredElementCollector(doc).OfClass(FabricationConfiguration).FirstElement()
lstServ = fabConf.GetAllServices()
groupName = getGroupName(lstServ, fabPart)

OUT = groupName

hi @c.poupin

i got the same solution. thank you. i was hoping for a document class api or fabrication class api for this one because I am afraid I have a lot of elements and its going to be processed in 4-5 for loops which will take a lot of time and computer resource.

anyways thank you again.