Metadata-Version: 2.4
Name: Speckle2Graph
Version: 0.0.2
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"](/pictures/Speckle2GraphVersion4.gif "Enable Speckle 2Graph Pipeline") -->

<img src="pictures/Speckle2GraphVersion4.gif" alt="Sample Image" width="650" height="400">

# Purpose of the Library
This is an alpha version, so any feedback of bugs is very appreciated

The library aims to enrich the Speckle-Directed Acyclic Graph (DAG) by adding edges between BIM elements, enabling more specific graph-based analysis.

Currently we support Neo4j only

# Prerequisites
- Ensure that the Speckle models were uploaded using the **latest versions of the connectors**.
- Ensure that your Neo4j instance has the **APOC plugin** installed. Since Cypher queries are used to insert data and they don't support dynamic labels from parameters, we are forced to use APOC to save time on writing label-assigning queries manually.

# Usage
```python
# Install the library (PYPI will be added soon)
!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)

# Make sure you paste the root of the speckle model, otherwise, the geometries will fail to build.
root = operations.receive(ROOT, remote_transport = transport) 
```

```python
# Build a Graph in 4 lines of code
traversed_object = TraverseRevitDAG(root)
graph_builder = GraphBuilder(traversed_speckle_object=traversed_object)
graph_builder.build_logical_graph()
graph_builder.build_geometrical_graph()
```

```python
# Some predefined quries could be imported
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=full_graph_builder_object
    )
    neo4j_client_wrapper.write_geometrical_graph_to_neo4j(neo4j_client_wrapper)
    neo4j_client_wrapper.write_logical_graph_to_neo4j(neo4j_client_wrapper)
```

# Development Roadmap

Will be added soon!
