/
RevitGetUnitTypes.dyf
368 lines (368 loc) · 11.7 KB
/
RevitGetUnitTypes.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
{
"Uuid": "188c3e69-da99-4eba-a859-d030d4b45a9f",
"IsCustomNode": true,
"Category": "Crumple.Application.Query",
"Description": "Returns the unit type or forgetypeId of the document's units.",
"Name": "© Revit.GetUnitTypes",
"ElementResolver": {
"ResolutionMap": {}
},
"Inputs": [],
"Outputs": [],
"Nodes": [
{
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
"NodeType": "PythonScriptNode",
"Code": "# Made by Gavin Crump\r\n# Free for use\r\n# BIM Guru, www.bimguru.com.au\r\n\r\n# Boilerplate text\r\nimport clr\r\n\r\nclr.AddReference(\"RevitServices\")\r\nimport RevitServices\r\nfrom RevitServices.Persistence import DocumentManager \r\n\r\n# Current doc/app/ui\r\ndoc = IN[0]\r\n\r\n# Get app version\r\nuiapp = DocumentManager.Instance.CurrentUIApplication \r\napp = uiapp.Application\r\nrvt_year = int(app.VersionNumber)\r\n\r\n# Import API references by version\r\nclr.AddReference(\"RevitAPI\")\r\nimport Autodesk \r\n\r\nif rvt_year < 2022:\r\n\tfrom Autodesk.Revit.DB import UnitType\r\nelse:\r\n\tfrom Autodesk.Revit.DB import SpecTypeId\r\n\r\n# Get units\r\nif rvt_year < 2022:\r\n\tintLenUnits = doc.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits\r\n\tintAreaUnits = doc.GetUnits().GetFormatOptions(UnitType.UT_Area).DisplayUnits\r\n\tintVolUnits = doc.GetUnits().GetFormatOptions(UnitType.UT_Volume).DisplayUnits\r\nelse:\r\n\tintLenUnits = doc.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId()\r\n\tintAreaUnits = doc.GetUnits().GetFormatOptions(SpecTypeId.Area).GetUnitTypeId()\r\n\tintVolUnits = doc.GetUnits().GetFormatOptions(SpecTypeId.Volume).GetUnitTypeId()\r\n\r\n# Preparing output to Dynamo\r\nOUT = intLenUnits, intAreaUnits, intVolUnits",
"Engine": "CPython3",
"VariableInputPorts": true,
"Id": "e2836d27dcd447bda3a62ec066f6e9e0",
"Inputs": [
{
"Id": "eda176ffc0f14381bfacf69e9a70f117",
"Name": "IN[0]",
"Description": "Input #0",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "86de75d807a347ca9381de9e046f6657",
"Name": "OUT",
"Description": "Result of the python script",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Runs an embedded Python script."
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore",
"NodeType": "OutputNode",
"ElementResolver": null,
"Symbol": "lengthType",
"Id": "ab9a9a7747644ed78e0f62dbbda632e8",
"Inputs": [
{
"Id": "30fcc3c960834c9b8bb41f4c665e8bd6",
"Name": "",
"Description": "",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [],
"Replication": "Disabled",
"Description": "A function output, use with custom nodes"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Function, DynamoCore",
"FunctionSignature": "4a8a580b-b56f-4e35-a1c0-dacf9b9c62bc",
"FunctionType": "Graph",
"NodeType": "FunctionNode",
"Id": "b191aba6ab604f6db8174cce7e54548d",
"Inputs": [
{
"Id": "df0a428109c040e69a982a24050de9be",
"Name": "docOrLink",
"Description": "var[]..[]\nDefault value : null",
"UsingDefaultValue": true,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "9d4bb96059554748b412cea9ea9bb996",
"Name": "document",
"Description": "return value",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "9579e439bc2148829ff862324239a8e6",
"Name": "outcome",
"Description": "return value",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Auto",
"Description": "If no input is specified or an invalid one is, returns current document. If a link instance is provided, it returns the linked document. If a document is provided it will pass it through."
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore",
"NodeType": "InputNode",
"Parameter": {
"Name": "docOrLink",
"TypeName": "var",
"TypeRank": -1,
"DefaultValue": "null",
"Description": "Uses current if none provided.\nAccepts document or link instance."
},
"Id": "805db28cdbe94fcfb3a96d1767ce3937",
"Inputs": [],
"Outputs": [
{
"Id": "79f181c3988b41e5bcc764aa01aff782",
"Name": "",
"Description": "Symbol",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "A function parameter, use with custom nodes.\r\n\r\nYou can specify the type and default value for parameter. E.g.,\r\n\r\ninput : var[]..[]\r\nvalue : bool = false"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore",
"NodeType": "CodeBlockNode",
"Code": "x[0];\nx[1];\nx[2];",
"Id": "66e857bab5804eeebfff2086f22998ab",
"Inputs": [
{
"Id": "5d43cd88a432469ea487b38ed738dcde",
"Name": "x",
"Description": "x",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "2d4ed08aa7534f71ba5cb9436f251a9c",
"Name": "",
"Description": "Value of expression at line 1",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "ca82b4440b294d7cb8637357861c476c",
"Name": "",
"Description": "Value of expression at line 2",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
},
{
"Id": "faf73e6062ea443e9918d385ed0b1153",
"Name": "",
"Description": "Value of expression at line 3",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Allows for DesignScript code to be authored directly"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore",
"NodeType": "OutputNode",
"ElementResolver": null,
"Symbol": "areaType",
"Id": "5a83f6afbb6143b598101ddd852283c9",
"Inputs": [
{
"Id": "f92c9bfc1ef04a1d8bf10455ef17231e",
"Name": "",
"Description": "",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [],
"Replication": "Disabled",
"Description": "A function output, use with custom nodes"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore",
"NodeType": "OutputNode",
"ElementResolver": null,
"Symbol": "volumeType",
"Id": "88af116bc9c74ba7b301a37fb57e04fb",
"Inputs": [
{
"Id": "9d13c030c8db43c19c9f634c3088bfd3",
"Name": "",
"Description": "",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [],
"Replication": "Disabled",
"Description": "A function output, use with custom nodes"
}
],
"Connectors": [
{
"Start": "86de75d807a347ca9381de9e046f6657",
"End": "5d43cd88a432469ea487b38ed738dcde",
"Id": "3c26b79b705045dfaa5433d322bceb0a"
},
{
"Start": "9d4bb96059554748b412cea9ea9bb996",
"End": "eda176ffc0f14381bfacf69e9a70f117",
"Id": "9d048f66fd4d4e3d904f745049050dad"
},
{
"Start": "79f181c3988b41e5bcc764aa01aff782",
"End": "df0a428109c040e69a982a24050de9be",
"Id": "6072ec89b1214a6cb766fac1490872d8"
},
{
"Start": "2d4ed08aa7534f71ba5cb9436f251a9c",
"End": "30fcc3c960834c9b8bb41f4c665e8bd6",
"Id": "c75bd8e9ded846d0bd7066c8e923f61a"
},
{
"Start": "ca82b4440b294d7cb8637357861c476c",
"End": "f92c9bfc1ef04a1d8bf10455ef17231e",
"Id": "1d45f93425e44494b0f05bca77dd3016"
},
{
"Start": "faf73e6062ea443e9918d385ed0b1153",
"End": "9d13c030c8db43c19c9f634c3088bfd3",
"Id": "f051d35c2dce4c7fbcbd33f9007ac738"
}
],
"Dependencies": [
"4a8a580b-b56f-4e35-a1c0-dacf9b9c62bc"
],
"NodeLibraryDependencies": [
{
"Name": "Crumple",
"Version": "2022.5.27",
"ReferenceType": "Package",
"Nodes": [
"b191aba6ab604f6db8174cce7e54548d"
]
}
],
"Author": "None provided",
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": false,
"IsVisibleInDynamoLibrary": true,
"Version": "2.12.1.8246",
"RunType": "Manual",
"RunPeriod": "1000"
},
"Camera": {
"Name": "Background Preview",
"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
},
"NodeViews": [
{
"ShowGeometry": true,
"Name": "Python Script",
"Id": "e2836d27dcd447bda3a62ec066f6e9e0",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 442.0,
"Y": -149.0
},
{
"ShowGeometry": true,
"Name": "Output",
"Id": "ab9a9a7747644ed78e0f62dbbda632e8",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 852.5,
"Y": -224.0
},
{
"ShowGeometry": true,
"Name": "© Revit.GetDocument",
"Id": "b191aba6ab604f6db8174cce7e54548d",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 147.27110886496666,
"Y": -149.0
},
{
"ShowGeometry": true,
"Name": "Input",
"Id": "805db28cdbe94fcfb3a96d1767ce3937",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": -230.99999999999994,
"Y": -149.67103139060549
},
{
"ShowGeometry": true,
"Name": "Code Block",
"Id": "66e857bab5804eeebfff2086f22998ab",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 620.0,
"Y": -145.0
},
{
"ShowGeometry": true,
"Name": "Output",
"Id": "5a83f6afbb6143b598101ddd852283c9",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 856.5,
"Y": -132.0
},
{
"ShowGeometry": true,
"Name": "Output",
"Id": "88af116bc9c74ba7b301a37fb57e04fb",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"X": 859.5,
"Y": -32.0
}
],
"Annotations": [],
"X": 132.89419608791491,
"Y": 438.16279146185991,
"Zoom": 0.49618648738281262
}
}