-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathL6_Geometry_Defunct_L2.py
More file actions
109 lines (87 loc) · 3 KB
/
L6_Geometry_Defunct_L2.py
File metadata and controls
109 lines (87 loc) · 3 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
106
107
108
109
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 getGeoElemnt(element): # Get Geometry of Element
geo = []
opt = Options()
opt.ComputeReferences = True
opt.IncludeNonVisibleObjects = True
opt.DetailLevel = ViewDetailLevel.Fine
geometry = element.get_Geometry(opt)
geo = [i for i in geometry]
return geo
def getSolidFromGeo(lstgeometry): # Get Solid from Geometry
sol = []
for i in lstgeometry:
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 getPlanarFromSolid(lstsolids): # Get PlanarFace from Solid
pfaces = []
for i in lstsolids:
pfaces.append(i.Faces)
return pfaces[0]
def Isparalel(p,q):
return p.CrossProduct(q).IsZeroLength() # Tich co huong 2 Vector
def RemoveFaceNone(dbPlanarFaces): # Get planarFaces Not Null Value
pfaces = []
for i in dbPlanarFaces:
if i.Reference != None:
pfaces.append(i)
return pfaces
def FilterVerticalPlanar(dbPlanarFaces): # Get plannar follow Vertical
faV = []
Y = XYZ.BasisY
for i in RemoveFaceNone(dbPlanarFaces):
var = i.FaceNormal
check = Isparalel(Y,var)
if check == True:
faV.append(i)
return faV
def FilterHorizontalPlanar(lstplans): # Get plannar follow Horizantal
faH = []
Z = XYZ.BasisZ
for i in lstplans:
var = i.FaceNormal
check = Isparalel(Z,var)
if check == True:
faH.append(i)
return faH
def RefFromPlanar(listPlanr): # Get References of Plannars
re = []
for i in listPlanr:
if i.Reference != None:
re.append(i.Reference)
return re
geoEle = GetGeoElemnt(ele) # Get Geometry of Element
soli = GetSolidFromGeo(geoEle) # Get Solid from Geometry
planar = GetPlanarFromSolid(soli) # Get PlanarFace from Solid
faceVeti = FilterVerticalPlanar(planar) # Get plannarFaces follow Vertical
faceHori = FilterHorizontalPlanar(planar) # Get plannarFaces follow Horizantal
reV = RefFromPlanar(faceVeti) # Get References of Plannars --> Vertical
reH = RefFromPlanar(faceHori) # Get References of Plannars ---> Horizontal
OUT = reV, reH