-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathL6_Geometry_Defunct.py
More file actions
105 lines (81 loc) · 2.68 KB
/
L6_Geometry_Defunct.py
File metadata and controls
105 lines (81 loc) · 2.68 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import clr
import System
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*
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
doc = DocumentManager.Instance.CurrentDBDocument
view = doc.ActiveView
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
ele = UnwrapElement(IN[1])
def getSolidElement(element): # Get Geometry of Element
geo = []
opt = Options()
opt.ComputeReferences = True
opt.IncludeNonVisibleObjects = True
opt.DetailLevel = ViewDetailLevel.Fine
geometry = element.get_Geometry(opt)
for i in geometry: geo.append(i) # Way 1
#geo = [i for i in element.get_Geometry(opt)] # Way 2
return [i for i in geometry]
def getSolidFromGeo(lstGeo): # Get Solid of Geometry
sol = []
for i in lstGeo:
if i.GetType() == Solid and i.Volume > 0:
sol.append(i)
elif i.GetType() == GeometryInstance:
var = i.SymbolGeometry
for j in var:
if j.Volume > 0:
sol.append(j)
return sol
def getPlanarFormSolid(solids): # Get Faces from Solid
faces = []
for i in solids:
faces.append(i.Faces)
return faces[0]
def Isparallel(p,q):
return p.CrossProduct(q).IsZeroLength() # U.V = 0 it is CrossProduct between 2 Vectors
def getPlanarVertical(listPlanr): # Get Faces follow Vertical
reV = []
y = XYZ.BasisY
for i in listPlanr:
var = i.FaceNormal
check = Isparallel(var, y)
# if check == True:
# reV.append(i)
reV.append(i)
return reV
def getRefFromPlanar(listPlanr):
re = []
for i in listPlanr:
re.append(i.Reference)
return re
# def getPlanrHorizontal(listPlanr): # Get Faces follow Horizontal
# reH = []
# z = XYZ.BasisZ
# for i in listPlanr:
# var = i.FaceNormal
# check = Isparallel(z, var)
# if check == True:
# reH.append(i)
# return reH
geo = GetSolidElement(ele) # Get Geometry of Element
soli = GetSolidFromGeo(geo) # Get Solid of Geometry
planr = GetPlanarFormSolid(soli) # Get Faces from Solid
vPlanr = GetPlanarVertical(planr)
ref = GetRefFromPlanar(vPlanr) # Get References from Vertical Planars
#OUT =geo ,soli , planr, verti, hori
OUT = vPlanr, ref