Getting each connected network as a sublist from each connector of a family instance

Really looking for TPover on this one!

So, I’ve tried modifing TPover’s “Elements in connected network” node from MEPover package to give me the individual connected networks in sub-lists that are connected to a family instance that has multiple connectors. The reason I need to do this is to be able to report primary and secondary conduit lengths for each transformer so that we can order the correct lengths of wire to prefab the transformers with. See examples of scenarios:

Currently, I have a script that essentially uses the Transformer Revit schedule that looks at the XFMR names and finds those elements with that name. From there I can get the the primary and secondary flex from each transformer in a sorted list of sub-lists. From there, I feed each flex element into the modified connected element node that I made to only give me each element or connected network of elements into sublists by transformer. However, I’m getting unexpected/inconsistent results.

The cleanest approach would be to have a python script that would accept the family elements and list all the connected networks in sub-lists from each connector in the family.

I apologize for not having a screen shot of the script. For some reason when I use the Dynamo capture function, you cannot see any text on the nodes. If anyone knows what’s causing this, I’m all ears! Anyway, since I can’t get a good snapshot and new users cannot upload attachments, here are a few screenshots. Just hit me up and I can email you the script if you want to play with it.

XFMR_Script_ex1

Python for modified node:

import clr
import math

import sys
pyt_path = r’C:\Program Files (x86)\IronPython 2.7\Lib’
sys.path.append(pyt_path)
import System

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

import collections
#The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[0],list):
element = UnwrapElement(IN[0])
toggle = 0
else:
element = [UnwrapElement(IN[0])]
toggle = 1

def nextElements(elem):
listout = [elem]
try:
connectors = elem.ConnectorManager.Connectors
except:
connectors = elem.MEPModel.ConnectorManager.Connectors
for conn in connectors:
for c in conn.AllRefs:
if c.Owner.Id.Equals(elem.Id):
continue
#elif c.Owner.GetType() == Mechanical.MechanicalSystem:
elif c.Owner.GetType() == Plumbing.PipingSystem:
continue
elif c.Owner.Id in lookup:
continue
else:
newelem = c.Owner
listout.append(newelem)
return listout

def systemcheck(elem):
if elem.GetType() == Mechanical.MechanicalSystem or elem.GetType() == Electrical.ElectricalEquipment:
return True
params = elem.Parameters
for param in params:
if param.Definition.Name == “Panel Name”:
return True
return False

def collector(elem):
cont = 0
elements = nextElements(elem)
for x in elements:
if x.Id in lookup:
cont += 1
else:
item = doc.GetElement(x.Id)
if systemcheck(item):
return None
else:
lookup[x.Id] = item
collector(x)
if cont == len(elements):
return elem

listout =
lookup = collections.OrderedDict()
for x in element:
collector(x)
listout.append(lookup.Values)

#Assign your output to the OUT variable.
if toggle:
OUT = lookup.Values
else:
OUT = listout

Since it wouldn’t let me post more than one picture because I am a new user, here are the others one at a time:

I’ve made a few modifications to the code: you can input a connector (instead of an element) and it will return all the elements that are connected from the connector and onward.

Here is the graph with the python node: elements in connected network by connector.dyn (4.5 KB)

If it works I will add it to the package, I can see the use in this for other cases as well.

Again, sorry I can’t post attachments yet or I would post the XFMR family with my script. So, here are the results from that script. (One picture at a time per post for now!)

image

I found another error in the code, let’s give it another try :slight_smile:
elements in connected network by connector.dyn (4.5 KB)

It’s working perfect. Thanks TPover!

image

1 Like

Good to hear! I updated my package with a new version of the ‘Elements in connected network’ node. You can now also input connectors and then the node will give back all the elements that are connected to that connector and onward.

2 Likes