Metadata-Version: 2.4
Name: Speckle2Graph
Version: 0.0.5
Summary: Enable graph-based analysis of any Speckle model.
Author-email: Arsy <arseneyworking@gmail.com>
License: Apache
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: specklepy>=3.1.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: scipy>=1.10.0
Requires-Dist: trimesh>=4.0.0
Requires-Dist: python-fcl>=0.7.0
Requires-Dist: networkx>=3.0
Requires-Dist: rtree>=1.0.0
Requires-Dist: neo4j>=5.0.0
Requires-Dist: tqdm>=4.65.0
Requires-Dist: loguru>=0.7.0
Dynamic: license-file

# Speckle2Graph
!["test"](/static/Speckle2GraphVersion6.gif "Enable Speckle to Graph Pipeline")
<!-- <img src="static/Speckle2GraphVersion5.gif" alt="Sample Image" width="650" height="400"> -->

**⚠️ Currently in alpha - bug reports and feedback are appreciated!**

# Purpose of the Library
speckle2graph is a framework for establishing pipelines from BIM models to graph databases with just a few lines of code.

The semantics of a BIM model are locked within the modelling software, which creates a bottleneck for implementing AI agents that truly understand the model. Converting a BIM model to a knowledge graph with a custom ontology is an ideal foundation for building AI-driven applications.

Currently we support Neo4j only.

# Key Features
- Convert BIM models to Neo4j graph databases in 3 lines of code
- Support for Revit models via Speckle
- Preserves model relationships and hierarchies
- Extensible for custom ontologies

# What Gets Created
The library traverses your Speckle BIM model and creates:
- **Nodes**: Representing BIM elements with their properties
- **Relationships**: Spatial and hierarchical connections between elements
- **Graph structure**: Ready for AI agents, path-finding, and semantic queries

# Prerequisites
- Ensure that the Speckle models were uploaded using the **latest versions of the connectors**.

# Usage
```python
# Install the library
pip install speckle2graph

# To follow latest developments install it from the github
pip install git+https://github.com/2twenity/Speckle2Graph.git
```

```python
# Authorize to Speckle 
client = SpeckleClient()
client.authenticate_with_token(SPECKLE_TOKEN)
transport = ServerTransport(PROJECT_ID, client)

# Receive the root object from Speckle (must be the model root for geometry to build correctly)
root = operations.receive(ROOT, remote_transport = transport) 
```

```python
# Build a Graph in 3 lines of code
traversed_object = TraverseRevitDAG(root)
graph_builder = DataGraphBuilder(traversed_speckle_object=traversed_object)
graph_builder.build()
```

```python
# Write the graph to a neo4j database
from speckle2graph import Neo4jRevitLabelAssigner
from speckle2graph import Neo4jClientDriverWrapper
from neo4j import GraphDatabase

# Authorize and write the graph to Neo4j for further analysis. 
with GraphDatabase.driver(URI, auth=auth) as driver:
    driver.verify_connectivity()
    neo4j_client_wrapper = Neo4jClientDriverWrapper(
        driver=driver,
        graph_builder_object=graph_builder,
        label_assigner=Neo4jRevitLabelAssigner()
    )
    neo4j_client_wrapper.write_graph()
```

# Example
!["test"](/static/BIM2Graph.png "Models example")
