Update Point Commit.py
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
from array import array
|
||||
from hashlib import new
|
||||
from logging import NullHandler
|
||||
from types import AsyncGeneratorType
|
||||
from typing import List
|
||||
from specklepy.api import operations
|
||||
from specklepy.api.client import SpeckleClient
|
||||
from specklepy.api.credentials import get_default_account
|
||||
from specklepy.api.resources import stream
|
||||
from specklepy.transports.server import ServerTransport
|
||||
from specklepy.objects.geometry import Point
|
||||
from specklepy.objects.geometry import GEOMETRY, Box, Point
|
||||
from specklepy.objects import Base
|
||||
from numpy import ndarray
|
||||
|
||||
from random import randint
|
||||
|
||||
client = SpeckleClient(host = "https://latest.speckle.dev/")
|
||||
@@ -19,26 +23,41 @@ stream_id = "Point Cloud"
|
||||
new_stream_id = client.stream.create(name = stream_id)
|
||||
new_stream = client.stream.get(id = new_stream_id)
|
||||
|
||||
PointsArr = []
|
||||
class PointCloud(Base,speckle_type = GEOMETRY + "Pointcloud",chunkable = {"points":31250,"colors":62500,"sizes":62500}):
|
||||
|
||||
colors: List[int] = None
|
||||
sizes: List[float] = None
|
||||
points: List[float] = None
|
||||
bbox: Box = None
|
||||
|
||||
|
||||
num_points = 1000
|
||||
size_coord = 100
|
||||
|
||||
points = []
|
||||
num_points = 100000
|
||||
size_coord = 1000
|
||||
colors = []
|
||||
|
||||
for i in range(num_points):
|
||||
x = randint(0,size_coord)
|
||||
y = randint(0,size_coord)
|
||||
z = randint(0,size_coord)
|
||||
new_point = Point()
|
||||
Point.x = x
|
||||
Point.y = y
|
||||
Point.z = z
|
||||
PointsArr.append(new_point)
|
||||
R = randint(0,255)
|
||||
B= randint (0,0)
|
||||
G = randint (0,0)
|
||||
RGBint = (R<<16) + (G<<8) + B
|
||||
colors.append(RGBint)
|
||||
points.append(x)
|
||||
points.append(y)
|
||||
points.append(z)
|
||||
|
||||
pointscloud = PointCloud()
|
||||
pointscloud.colors = colors
|
||||
pointscloud.points = points
|
||||
|
||||
|
||||
|
||||
|
||||
base = Base()
|
||||
base["@Points"] = PointsArr
|
||||
|
||||
base["@PointCloud"] = pointscloud
|
||||
|
||||
transport = ServerTransport(client = client,stream_id = new_stream_id )
|
||||
|
||||
@@ -46,6 +65,6 @@ hash = operations.send(base= base,transports= [transport])
|
||||
|
||||
commit_id = client.commit.create(
|
||||
stream_id= new_stream_id,
|
||||
obj_id=hash,
|
||||
object_id=hash,
|
||||
message = "this is a point cloud array"
|
||||
)
|
||||
Reference in New Issue
Block a user