Get the devices a Wire connects to

hi people, trying to select a wire and get the devices the wire is connected to. (2 fire alarm devices in my case)

i can get the connectors of the wire but that’s where it all ends. there’s even a node for that.

revit lookup add-in sees the connector set of 2 that the wire owns but gives no details about the devices they connect to.
or am i mising something?

I checked the Connector class but could not see any property / method that does what i need.
starting to get worried.

i checked similar topics, a lot of people want to get the location of connectors but i don’t know what they do with that.

or how else can i approach this?
try and look for another connector from another device that’s in the exact same point as the wire connectors?

thanks!

A wire is just an annotation object that stores some of the connected system information. The wire itself won’t have any info on the connected elements. You first need to get the system (MEPSystem) from the wire and that will contain the methods for getting all the connected elements (BaseEquipment and Elements).

@Nick_Boyts : nice.
can’t wait to check it out.

how did you know of this?
did you read the entire API or?.. :smiley:

mysterious are the revit ways…

thank you!

Hello,
a Python solution with AllRefs property

import clr
import sys
import System
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
import Autodesk.Revit.DB as DB

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

def get_wire_elements(wire):
    out = []
    for con in wire.ConnectorManager.Connectors:
        for cRef in con.AllRefs:
            if isinstance(cRef.Owner, DB.FamilyInstance):
                out.append(cRef.Owner)
    return out

toList = lambda x : x if hasattr(x, '__iter__') else [x]

#Preparing input from dynamo to revit
lst_wires = toList(UnwrapElement(IN[0]))

OUT = [get_wire_elements(w_) for w_ in lst_wires]
5 Likes

@c.poupin monsieur Poupin this is NOT the first time you’ve came out of the blue and saved my soul :smiley:

cannot wait to give it a try and of course smash that “mark as solution” :slight_smile:

thanks!!!

1 Like

You have to be careful using ConnectorManager with Wires. While it does work sometimes, it’s very easy for Wires to move around and get physically “disconnected” from their devices. You can see this with home runs as they won’t show connecting equipment by default.

The MEPSystem property can help here, at least as an initial filter. The system connection to the wire is much more stable and will always contain all the connected elements. The problem is that it contains all the connected elements.

Using both options (plus the panel and circuit information to further filter devices when necessary) would probably be necessary to get a good idea of what’s actually going on. Tracking devices by wire is actually more complicated than it seems.

1 Like

You are right, a little improvement for some case

wire elements

import clr
import sys
import System
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
import Autodesk.Revit.DB as DB

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

def get_wire_elements(wire): 
    out = []
    for con in wire.ConnectorManager.Connectors:
        if any(c.Owner.Id == wire.MEPSystem.Id for cRef in con.AllRefs for c in cRef.AllRefs):
            for cRef in con.AllRefs:
                if isinstance(cRef.Owner, DB.FamilyInstance):
                    out.append(cRef.Owner)
    return out

toList = lambda x : x if hasattr(x, '__iter__') else [x]

#Preparing input from dynamo to revit
lst_wires = toList(UnwrapElement(IN[0]))

OUT = [get_wire_elements(w_) for w_ in lst_wires]
3 Likes