Skip to content

Quick Start

This guide will help you process your first IFC file and store it in Neo4j.

Prerequisites

Before starting, ensure you have:

  • [x] Installed ifc-graph (Installation Guide)
  • [x] A running Neo4j database
  • [x] An IFC file to process

Step 1: Configure Environment

Create a .env file in your working directory:

# Copy from example if available
cp .env.example .env

Edit the .env file with your Neo4j credentials:

NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your_password_here
IFC_FILE_PATH=./your_model.ifc

Environment Variables

You can also pass credentials directly via CLI arguments or programmatically. The .env file is just one option.

Step 2: Process an IFC File

Using the CLI

The simplest way to process an IFC file:

ifc-graph --ifc-file path/to/your_model.ifc

You should see output like:

2024-01-15 10:30:45 INFO Loading IFC file: path/to/your_model.ifc
2024-01-15 10:30:46 INFO Found 150 elements matching filter criteria
2024-01-15 10:30:47 INFO Connected to Neo4j at bolt://localhost:7687
2024-01-15 10:30:48 INFO Created 150 elements
2024-01-15 10:30:48 INFO Created 12 spatial structures
2024-01-15 10:30:48 INFO Linked 45 materials
2024-01-15 10:30:48 INFO Processing complete!

Using Python

from ifc_graph import filter_physical_elements, save_to_neo4j

# Extract elements from your IFC file
elements, ifc_file = filter_physical_elements(
    "path/to/your_model.ifc",
    element_types=['IfcWall', 'IfcDoor', 'IfcWindow', 'IfcColumn']
)

print(f"Found {len(elements)} elements")

# Store in Neo4j
stats = save_to_neo4j(
    elements,
    ifc_file,
    uri="bolt://localhost:7687",
    username="neo4j",
    password="your_password"
)

print(f"Created {stats['elements']} element nodes")
print(f"Created {stats['structures']} structure nodes")
print(f"Linked {stats['materials']} materials")

Step 3: View in Neo4j Browser

  1. Open Neo4j Browser (usually at http://localhost:7474)
  2. Run a Cypher query to view your data:
// View all elements
MATCH (e:Element) RETURN e LIMIT 25

// View elements with their materials
MATCH (e:Element)-[:HAS_MATERIAL]->(m:Material)
RETURN e, m LIMIT 25

// View the spatial structure
MATCH (s:Structure)-[:CONTAINS]->(e:Element)
RETURN s, e LIMIT 50

Step 4: Preview Before Import (Optional)

Use dry-run mode to see what would be imported without making changes:

ifc-graph --ifc-file model.ifc --dry-run

This shows element counts and types without modifying the database.

Common Operations

Clear Database Before Import

To replace existing data:

ifc-graph --ifc-file model.ifc --clear-db

Database Clearing

The --clear-db flag will delete all existing nodes and relationships in the database before importing.

Verbose Logging

For debugging, enable debug logging:

ifc-graph --ifc-file model.ifc --log-level DEBUG

Custom Configuration

Use a custom config file to specify which elements to extract:

ifc-graph --config my_config.yaml --ifc-file model.ifc

Next Steps