-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bd78b7
commit 6516dca
Showing
3 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ifcopenshell | ||
import multiprocessing | ||
import ifcopenshell.geom | ||
|
||
ifc_filepath = "/home/frank/dev/tum-dev/Navigatum/map/data/5505_IFC4/02-55-5505-100_EG.ifc" | ||
ifc_file = ifcopenshell.open(ifc_filepath) | ||
|
||
settings = ifcopenshell.geom.settings() | ||
iterator = ifcopenshell.geom.iterator(settings, ifc_file, multiprocessing.cpu_count()) | ||
if iterator.initialize(): | ||
while True: | ||
shape = iterator.get() | ||
element = ifc_file.by_id(shape.id) | ||
matrix = shape.transformation.matrix | ||
faces = shape.geometry.faces | ||
edges = shape.geometry.edges | ||
verts = shape.geometry.verts | ||
|
||
if not iterator.next(): | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# pip install ifcopenshell | ||
# pip install mathutils | ||
|
||
import ifcopenshell | ||
import ifcopenshell.geom | ||
import ifcopenshell.draw | ||
import ifcopenshell.api.context | ||
import ifcopenshell.util.shape | ||
import plotly.express as px | ||
import pandas as pd | ||
|
||
ifc_file = "/home/frank/dev/tum-dev/Navigatum/map/data/5505_IFC4/02-55-5505-100_EG.ifc" | ||
|
||
model = ifcopenshell.open(ifc_file) | ||
rooms = model.by_type('IfcSpace') | ||
# doors = model.by_type('IfcDoor') | ||
setttings = ifcopenshell | ||
|
||
settings = ifcopenshell.geom.settings() | ||
settings.set(settings.USE_PYTHON_OPENCASCADE, True) | ||
|
||
try: | ||
shape = ifcopenshell.geom.create_shape(settings, rooms[0]) | ||
geometry = shape.geometry # see #1124 | ||
# These are methods of the TopoDS_Shape class from pythonOCC | ||
shape_gpXYZ = geometry.Location().Transformation().TranslationPart() | ||
# These are methods of the gpXYZ class from pythonOCC | ||
print(shape_gpXYZ.X(), shape_gpXYZ.Y(), shape_gpXYZ.Z()) | ||
except: | ||
print("Shape creation failed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# pip install ifcopenshell | ||
# pip install mathutils | ||
|
||
import ifcopenshell | ||
import ifcopenshell.draw | ||
import ifcopenshell.api.context | ||
import ifcopenshell.util.shape | ||
from ifcopenshell import geom | ||
import plotly.express as px | ||
import pandas as pd | ||
|
||
ifc_file = "/home/frank/dev/tum-dev/Navigatum/map/data/5505_IFC4/02-55-5505-100_EG.ifc" | ||
|
||
model = ifcopenshell.open(ifc_file) | ||
rooms = model.by_type('IfcSpace') | ||
# doors = model.by_type('IfcDoor') | ||
vertecies = [] | ||
for i, room in enumerate(rooms): | ||
settings = ifcopenshell.geom.settings() | ||
try: | ||
shape = ifcopenshell.geom.create_shape(settings, room) | ||
except Exception: | ||
continue | ||
# Since the lists are flattened, you may prefer to group them like so depending on your geometry kernel | ||
# A nested numpy array e.g. [[v1x, v1y, v1z], [v2x, v2y, v2z], ...] | ||
grouped_verts = ifcopenshell.util.shape.get_vertices(shape.geometry) | ||
# A nested numpy array e.g. [[e1v1, e1v2], [e2v1, e2v2], ...] | ||
# grouped_edges = ifcopenshell.util.shape.get_edges(shape.geometry) | ||
# A nested numpy array e.g. [[f1v1, f1v2, f1v3], [f2v1, f2v2, f2v3], ...] | ||
# grouped_faces = ifcopenshell.util.shape.get_faces(shape.geometry) | ||
ifcopenshell.util.geom | ||
matrix = shape.transformation.matrix | ||
(raw_x, raw_y, raw_z) = matrix[12:15] | ||
# print(location) | ||
vertecies.extend( | ||
dict(x=raw_x + x, y=raw_y + y, z=raw_z + z, id=i) for (x, y, z) in grouped_verts if (raw_z + z) < 2) | ||
if i > 2: | ||
continue | ||
|
||
df = pd.DataFrame(vertecies) | ||
fig = px.line(df, x="x", y="y", color="id") | ||
fig.update_yaxes(scaleanchor="x", scaleratio=1, overwrite=True) | ||
fig.show() | ||
# plan = ifcopenshell.api.context.add_context(model, context_type="Plan") | ||
settings = ifcopenshell.draw.draw_settings() | ||
ifcopenshell.draw.main(settings, [model]) |