Add database auto-creation and fix IFC parser flush logic
- Create tables on application startup via lifespan event - Flush project before creating elements (generate project_id) - Flush each element before creating properties (generate element_id) - Add IfcWallStandardCase to parsed element types - Include FZK-Haus sample IFC file for testing - Tested: 58 elements, 3601 properties parsed successfully
This commit is contained in:
parent
fbd8c88942
commit
4951671f63
2 changed files with 44263 additions and 3 deletions
|
|
@ -38,10 +38,11 @@ async def parse_ifc_file(
|
||||||
ifc_schema=ifc.schema,
|
ifc_schema=ifc.schema,
|
||||||
)
|
)
|
||||||
db.add(project)
|
db.add(project)
|
||||||
|
await db.flush()
|
||||||
|
|
||||||
# Extract elements
|
# Extract elements
|
||||||
element_types = [
|
element_types = [
|
||||||
"IfcWall", "IfcDoor", "IfcWindow", "IfcSlab",
|
"IfcWall", "IfcWallStandardCase", "IfcDoor", "IfcWindow", "IfcSlab",
|
||||||
"IfcColumn", "IfcBeam", "IfcStair", "IfcRoof",
|
"IfcColumn", "IfcBeam", "IfcStair", "IfcRoof",
|
||||||
"IfcSpace", "IfcFurnishingElement", "IfcBuildingElementProxy",
|
"IfcSpace", "IfcFurnishingElement", "IfcBuildingElementProxy",
|
||||||
]
|
]
|
||||||
|
|
@ -59,6 +60,7 @@ async def parse_ifc_file(
|
||||||
storey=storey,
|
storey=storey,
|
||||||
)
|
)
|
||||||
db.add(element)
|
db.add(element)
|
||||||
|
await db.flush()
|
||||||
|
|
||||||
# Extract property sets
|
# Extract property sets
|
||||||
for pset_name, props in _get_properties(ifc_element).items():
|
for pset_name, props in _get_properties(ifc_element).items():
|
||||||
|
|
@ -75,7 +77,6 @@ async def parse_ifc_file(
|
||||||
await db.refresh(project)
|
await db.refresh(project)
|
||||||
return project
|
return project
|
||||||
|
|
||||||
|
|
||||||
def _extract_project_name(ifc, fallback_filename: str) -> str:
|
def _extract_project_name(ifc, fallback_filename: str) -> str:
|
||||||
"""Try to get the project name from the IFC file."""
|
"""Try to get the project name from the IFC file."""
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
44259
data/sample/AC20-FZK-Haus.ifc
Normal file
44259
data/sample/AC20-FZK-Haus.ifc
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue