A Python client for Speckle servers.
Project description
PySpeckle
A Python Speckle Client
Speckle: open digital infrastructure for designing, making and operating the built environment. We reimagine the design process from the Internet up: Speckle is an open source (MIT) initiative for developing an extensible Design & AEC data communication and collaboration platform.
Installation
PySpeckle can be installed through pip
:
pip install speckle
Disclaimer
This code is WIP and as such should be used with caution, on non-sensitive projects.
Description
PySpeckle is a light Python wrapper / interface for the Speckle framework. It can be used independently through Python scripts, or as a base for building various plug-ins, such as SpeckleBlender.
Quick Start
Here is how you initialise a client, authenticate and start speckling:
from speckle import SpeckleApiClient
# Create a client using the appropriate server
client = SpeckleApiClient('hestia.speckle.works')
# Login with your details
client.login(
email='test@test.com',
password='Speckle<3Python'
)
# Stream ID to get
stream_id = 'HjenwS2s'
# Get stream data using its ID
stream = client.streams.get(stream_id)
# Print the list of placeholder objects in the stream
for object in stream.objects:
print(object)
To get a list of all available streams and find a particular one by name:
# Fetch the list of all available streams
streams = client.streams.list()
name = "JetStream"
# Go through the list and find the stream by name
stream = None
for s in streams:
if s.name == name:
stream = s
break
# If the stream is found, fetch the full stream data, using an optional query dict
# to omit some data
if stream:
stream_data = client.streams.get(stream.streamId, {'omit':['layers','comments']})
To get object data from a stream:
stream = client.streams.get(streamId)
# Fetch a single object using its placeholder ID
object = client.objects.get(stream.objects[0].id)
# Fetch the objects all at once using an optional query dict
objects = client.objects.get_bulk([o.id for o in stream.objects], {'omit':'base64','displayValue'})
# Print out some object info
for o in objects:
print("Object {} is type {}".format(o.id, o.type)
To create some data and upload it to a stream:
import speckle.schemas
# Create some mesh data
vertices = [[0,0,0],[1,0,0],[1,1,0], [0,1,0]]
faces = [[0,1,2,3]]
# Create a Speckle Mesh object
sm = speckle.schemas.Mesh()
# Add vertices
for v in vertices:
sm.vertices.extend(v)
# Add faces
for f in faces:
if len(f) == 3: # if it is a triangle...
sm.faces.append(0)
elif len(f) == 4: # if it is a quad...
sm.faces.append(1)
sm.faces.extend(f)
# Give it a nice name
sm.name = "FancyMesh"
# Create the object on the server and receive a list of
# placeholders in return (with only one placeholder)
placeholders = client.objects.create(sm)
# Fetch the stream that we want to update
stream = client.streams.get(streamId)
# Set the stream object list to the created object or
# extend it to add the object to the existing list
stream.objects = placeholders
#stream.objects.extend(placeholders)
# Update the stream with the new data
client.streams.update(stream.streamId, stream)
Usage documentation can be found here.
Maintainers
SpeckleBlender is written and maintained by Tom Svilans (Github), Izzy Lyseggen and Antoine Dao.
Notes
Commit formatting can be found here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file speckle-2.3.0.tar.gz
.
File metadata
- Download URL: speckle-2.3.0.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.6.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9f73190d6799ff918217edfd3ba7610b52a4650e5819de1b458cb875a725fb8 |
|
MD5 | 918208dd012679c706eeffc1749bae35 |
|
BLAKE2b-256 | cabf481be1c54bcb817cc599b2244ea7a8e4b2939b3a290b36d340c231840295 |
File details
Details for the file speckle-2.3.0-py3-none-any.whl
.
File metadata
- Download URL: speckle-2.3.0-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.6.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f5660cbe3a3323ff62b7330aa4414f84590294158c59a92ca88ad54544a1e44 |
|
MD5 | cc807f63ea36d9b246b50a2420d3856a |
|
BLAKE2b-256 | 8b2b5a98258849befbfdb9cca41b532ceaa8d55eafd583e90c8193f341d87b61 |