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
886919d77f
commit
50b55cee42
2 changed files with 44263 additions and 3 deletions
|
|
@ -30,7 +30,7 @@ async def parse_ifc_file(
|
|||
finally:
|
||||
tmp_path.unlink()
|
||||
|
||||
# Create project record
|
||||
# Create project record
|
||||
project = Project(
|
||||
name=_extract_project_name(ifc, filename),
|
||||
filename=filename,
|
||||
|
|
@ -38,10 +38,11 @@ async def parse_ifc_file(
|
|||
ifc_schema=ifc.schema,
|
||||
)
|
||||
db.add(project)
|
||||
await db.flush()
|
||||
|
||||
# Extract elements
|
||||
element_types = [
|
||||
"IfcWall", "IfcDoor", "IfcWindow", "IfcSlab",
|
||||
"IfcWall", "IfcWallStandardCase", "IfcDoor", "IfcWindow", "IfcSlab",
|
||||
"IfcColumn", "IfcBeam", "IfcStair", "IfcRoof",
|
||||
"IfcSpace", "IfcFurnishingElement", "IfcBuildingElementProxy",
|
||||
]
|
||||
|
|
@ -59,6 +60,7 @@ async def parse_ifc_file(
|
|||
storey=storey,
|
||||
)
|
||||
db.add(element)
|
||||
await db.flush()
|
||||
|
||||
# Extract property sets
|
||||
for pset_name, props in _get_properties(ifc_element).items():
|
||||
|
|
@ -75,7 +77,6 @@ async def parse_ifc_file(
|
|||
await db.refresh(project)
|
||||
return project
|
||||
|
||||
|
||||
def _extract_project_name(ifc, fallback_filename: str) -> str:
|
||||
"""Try to get the project name from the IFC file."""
|
||||
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