/
Room ToElement.dyf
222 lines (222 loc) · 8.55 KB
/
Room ToElement.dyf
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
{
"Uuid": "41469f80-bd49-418a-9aba-cf06e3e3178a",
"IsCustomNode": true,
"Category": "GeniusLoci.Room",
"Description": "Reports the elements of the current or linked model that are inside the given room of the current document.",
"Name": "Room ToElement",
"ElementResolver": {
"ResolutionMap": {}
},
"Inputs": [],
"Outputs": [],
"Nodes": [
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore",
"NodeType": "OutputNode",
"ElementResolver": null,
"Symbol": "//Elements of current document or linked model\r\nElement",
"Id": "e94d13fefdf24ca3978bf5ccc71571da",
"Inputs": [
{
"Id": "ca9eaa72420a45c9a68dc9a27738a928",
"Name": "",
"Description": "",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [],
"Replication": "Disabled",
"Description": "Sortie de fonction, utiliser avec les noeuds personnalisés"
},
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"NodeType": "PythonScriptNode",
"Code": "#Alban de Chasteigner 2021\n#twitter : @geniusloci_bim\n#geniusloci.bim@gmail.com\n#https://github.com/albandechasteigner/GeniusLociForDynamo\n \nimport clr\nclr.AddReference('RevitAPI')\nimport Autodesk\nfrom Autodesk.Revit.DB import *\nclr.AddReference(\"RevitServices\")\nimport RevitServices\nfrom RevitServices.Persistence import DocumentManager\n\nrooms = UnwrapElement(IN[0]) if isinstance(IN[0],list) else [UnwrapElement(IN[0])]\ninputdoc = UnwrapElement(IN[1])\nresult=[]\n\nif inputdoc is None:\n\tdoc = DocumentManager.Instance.CurrentDBDocument\n\ttransform = Transform.Identity\nelif isinstance (inputdoc, RevitLinkInstance):\n\tdoc = inputdoc.GetLinkDocument()\n\ttransform = inputdoc.GetTotalTransform()\nfor room in rooms:\n\telem=[]\n\tfec = FilteredElementCollector(doc).WhereElementIsNotElementType().WhereElementIsViewIndependent().ToElements().FindAll(lambda x : type(x.Location) == LocationPoint and x.Category.Id != ElementId(BuiltInCategory.OST_Rooms) or type(x.Location) == LocationCurve or isinstance(x, CeilingAndFloor) or isinstance(x,RoofBase))\n\tfor e in fec:\n\t\tloc = e.Location\n\t\tif type(loc) == LocationPoint:\n\t\t\tpt=loc.Point\n\t\telif type(loc) == LocationCurve:\n\t\t\tpt=loc.Curve.Evaluate(0.5, False)\n\t\t# sketch-based elements (ceiling, floor and roof)\n\t\telif isinstance(e, CeilingAndFloor) or isinstance(e,RoofBase) :\n\t\t\ttry:\n\t\t\t\tfor ref in HostObjectUtils.GetTopFaces(e):\n\t\t\t\t\tgeomFace=e.GetGeometryObjectFromReference(ref)\n\t\t\t\t\t#Get UV BoundingBox\n\t\t\t\t\tbbox = geomFace.GetBoundingBox()\n\t\t\t\t\tuv=(bbox.Min+bbox.Max)/2\n\t\t\t\t\tpt=geomFace.Evaluate(uv)\n\t\t\texcept:\n\t\t\t\tbox = e.get_BoundingBox(None)\n\t\t\t\tpt = (box.Min+box.Max)/2\n\t\t\t\t\n\t\tlocationPoint = transform.OfPoint(pt)\n\t\tif room.IsPointInRoom(locationPoint):\n\t\t\telem.append(e)\n\tresult.append(elem)\n\t\nif isinstance(IN[0], list): OUT = result\nelse: OUT = result[0]",
"Engine": "IronPython2",
"EngineName": "IronPython2",
"VariableInputPorts": true,
"Id": "72275071b68c4567919796410543dfd4",
"Inputs": [
{
"Id": "8a8d2b758de341bc9239d24d23564aaf",
"Name": "IN[0]",
"Description": "Input #0",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "2f4cf38486024c3f984603595d8820e9",
"Name": "IN[1]",
"Description": "Input #1",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "f96b2c6186a04f9fbff4be8f456048af",
"Name": "OUT",
"Description": "Résultat du script Python",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Exécute un script Python intégré."
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore",
"NodeType": "InputNode",
"Parameter": {
"Name": "room",
"TypeName": "var",
"TypeRank": -1,
"DefaultValue": null,
"Description": "Room of current document"
},
"Id": "be4dc2845b954d5d9a990bc2d76c790f",
"Inputs": [],
"Outputs": [
{
"Id": "9dd75ab84771477193321fce9dccea90",
"Name": "",
"Description": "Symbole",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Un paramètre de fonction, utiliser avec des noeuds personnalisés.\r\n\r\nVous pouvez spécifier le type et la valeur par défaut du paramètre. Par exemple,\r\n\r\nentrée: var[]..[]\r\nvaleur: bool = false"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore",
"NodeType": "InputNode",
"Parameter": {
"Name": "RevitLinksInstance",
"TypeName": "var",
"TypeRank": -1,
"DefaultValue": "null",
"Description": "Optional input to retrieve linked elements"
},
"Id": "5a451f676b4347328b6394a449899df4",
"Inputs": [],
"Outputs": [
{
"Id": "ee2aef422ff24e7f85556074fcc63473",
"Name": "",
"Description": "Symbole",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Un paramètre de fonction, utiliser avec des noeuds personnalisés.\r\n\r\nVous pouvez spécifier le type et la valeur par défaut du paramètre. Par exemple,\r\n\r\nentrée: var[]..[]\r\nvaleur: bool = false"
}
],
"Connectors": [
{
"Start": "f96b2c6186a04f9fbff4be8f456048af",
"End": "ca9eaa72420a45c9a68dc9a27738a928",
"Id": "df2be8036de14ca1aaffdb5b00ef34e0",
"IsHidden": "False"
},
{
"Start": "9dd75ab84771477193321fce9dccea90",
"End": "8a8d2b758de341bc9239d24d23564aaf",
"Id": "143cd11fca7d4cb98e15c12e5d84ed8c",
"IsHidden": "False"
},
{
"Start": "ee2aef422ff24e7f85556074fcc63473",
"End": "2f4cf38486024c3f984603595d8820e9",
"Id": "d81eaebcdf254e63b1cf9be069527062",
"IsHidden": "False"
}
],
"Dependencies": [],
"NodeLibraryDependencies": [],
"Author": "None provided",
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": false,
"IsVisibleInDynamoLibrary": true,
"Version": "2.16.2.5624",
"RunType": "Manual",
"RunPeriod": "1000"
},
"Camera": {
"Name": "Aperçu en arrière-plan",
"EyeX": -17.0,
"EyeY": 24.0,
"EyeZ": 50.0,
"LookX": 12.0,
"LookY": -13.0,
"LookZ": -58.0,
"UpX": 0.0,
"UpY": 1.0,
"UpZ": 0.0
},
"ConnectorPins": [],
"NodeViews": [
{
"Name": "Output",
"ShowGeometry": true,
"Id": "e94d13fefdf24ca3978bf5ccc71571da",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 857.495407829748,
"Y": 300.211051402016
},
{
"Name": "Python Script",
"ShowGeometry": true,
"Id": "72275071b68c4567919796410543dfd4",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 660.58230727373,
"Y": 298.965737278584
},
{
"Name": "Input",
"ShowGeometry": true,
"Id": "be4dc2845b954d5d9a990bc2d76c790f",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 261.531883387657,
"Y": 293.82753877909221
},
{
"Name": "Input",
"ShowGeometry": true,
"Id": "5a451f676b4347328b6394a449899df4",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 122.37314501692771,
"Y": 447.27368927725058
}
],
"Annotations": [],
"X": -89.8354173404662,
"Y": 75.3631967776531,
"Zoom": 0.627408126597635
}
}