-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNoted.py
More file actions
84 lines (73 loc) · 2.35 KB
/
Noted.py
File metadata and controls
84 lines (73 loc) · 2.35 KB
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
"""Copyright(c) 2023 by: duengocnguyen@gmail.com"""
'https://www.youtube.com/channel/UCt2JhCDDFxpYho575WTMZ4g'
"""________________Welcome to BIM3DM-DYNAMO API___________________"""
import clr
import sys
sys.path.append(r'C:\Program Files\Autodesk\Revit 2020\AddIns\DynamoForRevit\IronPython.StdLib.2.7.8')
import math
from System.Collections.Generic import *
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import*
from Autodesk.Revit.UI.Selection import*
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#########################################################################
def is_array(obj):
return "List" in obj.__class__.__name__ or "list" in obj.__class__.__name__
def get_array_rank(array):
if is_array(array):
return 1 + max(get_array_rank(item) for item in array)
else:
return 0
def flatten_to_1d(arr):
result = []
def recursive_flatten(subarray):
for item in subarray:
if is_array(item):
recursive_flatten(item)
else:
result.append(item)
recursive_flatten(arr)
return result
def returnOUT(objects, fn):
rank = get_array_rank(objects)
if rank == 1: #a
return fn(objects)
elif rank == 2: #[a]
return [fn(element) for element in objects]
elif rank == 3: #[[a]]
return [fn(i) for j in objects for i in j]
else:
elements = flatten_to_1d(objects) #[a]
return fn(elements)
return None
#########################################################################
doc = DocumentManager.Instance.CurrentDBDocument
View = doc.ActiveView
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
app = uidoc.Application
###############################CODE HERE#################################
def getPointsFromXYZ(lstXYZ):
result = []
for xyz in lstXYZ:
x = xyz.X/304.8
y = xyz.Y/304.8
z = xyz.Z/304.8
result.append(XYZ(x,y,z).ToPoint())
return result
objects = IN[1]
#change name of your def
fn = getPointsFromXYZ
###############################END CODE##################################
OUT = returnOUT(objects, fn)