Fabrication part connector value

Is there any way to access the connector value of a MEP fabrication duct through API ?

1 Like

Hello @shibujoseukken

here a small example

import clr
import sys
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

elem = UnwrapElement(IN[0])
conIndex = []
conValue = []

conf = FabricationConfiguration.GetFabricationConfiguration(doc)
connectors = elem.ConnectorManager.Connectors

for c in connectors:
	if c.ConnectorType == ConnectorType.End:
		connectInfo = c.GetFabricationConnectorInfo()
		cn = conf.GetFabricationConnectorName(connectInfo.BodyConnectorId)
		conValue.append(cn)
		conIndex.append("C" + str(connectInfo.FabricationIndex + 1))
		
OUT = conIndex, conValue
2 Likes

Hi @c.poupin ,
thanks for your solution, is there a way to set new connector type from drop down menu by dynamo?
I got all the connector available in project, and I am trying to select element and change their connector type by dynamo.
I appreciate if you share your ideas.

to have already tried it seems to me that currently this is not possible via the API

@amirjalaliafshar avoid asking same questions multiple times. You have already asked this here:

1 Like

Hello! It doesn’t work with list of elements. Could you fix that, please?

Hi @Modeler and welcome.

here is the updaded code

import clr
import sys
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

def toList(x):
    if isinstance(x, (list, dict)) or \
            (hasattr(x, "GetType") and x.GetType().GetInterface("ICollection") is not None):
        return x
    else : return [x]

lst_elem = toList(UnwrapElement(IN[0]))
conf = FabricationConfiguration.GetFabricationConfiguration(doc)

OUT = []
for elem in lst_elem:
    conIndex = []
    conValue = []
    connectors = elem.ConnectorManager.Connectors
    
    for c in connectors:
        if c.ConnectorType == ConnectorType.End:
            connectInfo = c.GetFabricationConnectorInfo()
            cn = conf.GetFabricationConnectorName(connectInfo.BodyConnectorId)
            conValue.append(cn)
            conIndex.append("C" + str(connectInfo.FabricationIndex + 1))
            
    OUT.append([conIndex, conValue])
1 Like

It works! Thanks a lot!!