I’m having a weird issue with MEP Connector Info+ from MEPover (@T_Pover). The first time I run my graph (from Player or from Dynamo) on a given selected element the node errors. Every selection I run after the initial failed attempt runs perfectly.
That line of code is just getting the direction of the connector.
Full code here
import clr
import math
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)
#The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[0], list):
fittings = UnwrapElement(IN[0])
toggle = 0
else:
toggle = 1
fittings = [UnwrapElement(IN[0])]
def getConnSysType(connector):
domain = connector.Domain
if domain == Domain.DomainHvac:
return connector.DuctSystemType.ToString()
elif domain == Domain.DomainPiping:
return connector.PipeSystemType.ToString()
elif domain == Domain.DomainElectrical:
return connector.ElectricalSystemType.ToString()
else:
return None
p = []
dir = []
fd = []
ref = []
conns = []
descript = []
H = []
W = []
R = []
MEP = []
Sys = []
Shap = []
sysClass = []
for fitting in fittings:
points = []
direction = []
flowdir = []
refs = []
connlist = []
description = []
height = []
width = []
radius = []
MEPSystem = []
systemType = []
shape = []
systemclass = []
try:
connectors = fitting.MEPModel.ConnectorManager.Connectors
except:
try:
connectors = fitting.ConnectorManager.Connectors
except:
p.append(None)
dir.append(None)
fd.append(None)
ref.append(None)
conns.append(None)
descript.append(None)
H.append(None)
W.append(None)
R.append(None)
Shap.append(None)
MEP.append(None)
Sys.append(None)
sysClass.append(None)
continue
for conn in connectors:
connlist.append(conn)
description.append(conn.Description)
try:
height.append(conn.Height)
width.append(conn.Width)
radius.append(None)
except:
try:
radius.append(conn.Radius)
height.append(None)
width.append(None)
except:
radius.append(None)
height.append(None)
width.append(None)
shape.append((conn.Shape).ToString())
try:
MEPSystem.append(conn.MEPSystem.Name)
systype = doc.GetElement(conn.MEPSystem.GetTypeId())
systemType.append(systype)
except:
MEPSystem.append(None)
systemType.append(None)
try:
systemclass.append(getConnSysType(conn))
except:
systemclass.append(None)
points.append(conn.Origin.ToPoint())
direction.append(conn.CoordinateSystem.BasisZ.ToVector())
try:
flowdir.append(conn.Direction.ToString())
except:
flowdir.append(None)
for c in conn.AllRefs:
refs.append(c.Owner)
p.append(points)
dir.append(direction)
fd.append(flowdir)
ref.append(refs)
conns.append(connlist)
descript.append(description)
H.append(height)
W.append(width)
R.append(radius)
MEP.append(MEPSystem)
Sys.append(systemType)
Shap.append(shape)
sysClass.append(systemclass)
#Assign your output to the OUT variable.
if toggle:
OUT = points, flowdir, refs, direction, connlist, description, height, width, radius, MEPSystem, systemType, shape, systemclass
else:
OUT = p,fd,ref, dir, conns, descript, H, W, R, MEP, Sys, Shap, sysClass
For some background: My graph is essentially replacing one large fitting with two smaller fittings. I delete the original fitting and reconnect the duct (so I have something to connect into with my new fittings). Then I draw new duct and create the two new fittings (Tee.By2MEPCurves
). The issue then comes when I try to get the connector info from those new fittings.
I have no idea what would make the coordinate system “inaccessible” on only the first run. Any help would be much appreciated.
EDIT: It does seem like forcing an additional transaction fixes the problem. But why is this only affecting the first object selected? I’ve been using this graph for months now and never had this issue before.