-
Notifications
You must be signed in to change notification settings - Fork 0
/
Run.py
83 lines (72 loc) · 1.78 KB
/
Run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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 = []
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:
continue
else:
newelem = c.Owner
listout.append(newelem)
return listout
def systemcheck(elem):
if elem.GetType() == Mechanical.MechanicalSystem or elem.GetType() == Plumbing.PipingSystem:
return True
else:
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 elem
else:
lookup[x.Id] = item
collector(x)
if cont == len(elements):
return elem
listout = []
for x in element:
lookup = collections.OrderedDict()
collector(x)
listout.append(lookup.Values)
#Assign your output to the OUT variable.
if toggle:
OUT = lookup.Values
else:
OUT = listout