Compare commits

...

15 Commits

Author SHA1 Message Date
izzy lyseggen be85ddd159 feat(server): force utf-8 encoding (#163)
objects were being split on non-english characters causing receive fails

will also get fixed server side, but this will act as a double check
and an immediate fix for people dealing with this now
2022-02-18 10:33:25 +00:00
izzy lyseggen 77c538ced9 feat(server): allow unauth server transport (#162)
for receiving public objects
2022-02-17 10:10:25 +00:00
izzy lyseggen ee55680b03 feat(objects): add and test Mesh.create() (#161) 2022-02-08 16:56:33 +00:00
Reynold Chan 0728239915 Merge pull request #141 from specklesystems/structural/objects
Python Structural Objects Classes
2022-01-31 08:49:29 -05:00
izzy lyseggen 77016e6f0b chore(dev): update py and fix EOL errors (#157)
* chore(dev): fix eol probs on win

* chore(dev): bump py to 3.9
2022-01-24 15:17:23 +00:00
Antoine Dao ce39aa5101 chore(dev): add devcontainer configuration (#121)
This makes it easier to develop and run tests against an environment that has the right python virtualenv + a local speckle server + postgres + redis instance
2022-01-24 10:55:39 +00:00
Reynold Chan 3772c10b31 Create results.py 2021-12-12 13:30:50 -05:00
Reynold Chan 242be2fa60 fixed per izzy's suggestion for naming convention + circular dependency 2021-12-10 18:08:41 -05:00
izzy lyseggen ffa4f29200 fix(structural): correct import path for Axis 2021-12-10 11:18:24 +00:00
izzy lyseggen 40a691b098 style(structural): formatting pass
@Reynold-Chan please use Black for code formatting to keep the style
consistent with the rest of the repo. you can set your editor to
automatically format on save
2021-12-10 11:16:38 +00:00
Reynold Chan 487ce3aeb4 structural enums for geometry 2021-12-09 08:25:34 -05:00
Reynold Chan 6c0f10ae45 loading + analysis structural python + enums 2021-12-09 03:43:18 -05:00
Reynold Chan 436b26c91c structural geometries python classes 2021-12-08 08:47:22 -05:00
Reynold Chan f7bac26aed finished structural properties 2021-12-07 21:37:55 -05:00
Reynold Chan a31c049b51 materials done 2021-12-06 14:02:52 -05:00
15 changed files with 985 additions and 11 deletions
+27
View File
@@ -0,0 +1,27 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/python-3/.devcontainer/base.Dockerfile
# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
ARG VARIANT="3.9"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
USER vscode
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
ENV PATH=$PATH:$HOME/.poetry/env
+52
View File
@@ -0,0 +1,52 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/python-3
{
"name": "Python 3",
// "build": {
// "dockerfile": "Dockerfile",
// "context": "..",
// "args": {
// // Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9
// "VARIANT": "3.6",
// // Options
// "NODE_VERSION": "lts/*"
// }
// },
"dockerComposeFile": "./docker-compose.yaml",
"service": "specklepy",
"workspaceFolder": "/workspaces/specklepy",
"shutdownAction": "stopCompose",
// Set *default* container specific settings.json values on container create.
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.testing.pytestArgs": [
"tests/",
"-s"
],
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "poetry config virtualenvs.create false && poetry install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
+49
View File
@@ -0,0 +1,49 @@
version: "3.3" # optional since v1.27.0
services:
postgres:
image: circleci/postgres:12
environment:
POSTGRES_DB: speckle2_test
POSTGRES_PASSWORD: speckle
POSTGRES_USER: speckle
# ports:
# - "5432:5432"
network_mode: host
redis:
image: circleci/redis:6
# ports:
# - "6379:6379"
network_mode: host
speckle-server:
image: speckle/speckle-server
command: ["bash", "-c", "/wait && node bin/www"]
environment:
POSTGRES_URL: "localhost"
POSTGRES_USER: "speckle"
POSTGRES_PASSWORD: "speckle"
POSTGRES_DB: "speckle2_test"
REDIS_URL: "redis://localhost"
SESSION_SECRET: "keyboard cat"
STRATEGY_LOCAL: "true"
CANONICAL_URL: "http://localhost:3000"
WAIT_HOSTS: localhost:5432, localhost:6379
# ports:
# - "3000:3000"
network_mode: host
specklepy:
build:
dockerfile: Dockerfile
context: .
args:
VARIANT: 3.9
NODE_VERSION: lts/*
volumes:
# Mounts the project folder to '/workspace'. While this file is in .devcontainer,
# mounts are relative to the first file in the list, which is a level up.
- ..:/workspaces/specklepy:cached
# Overrides default command so things don't shut down after the process ends.
command: /bin/sh -c "while sleep 1000; do :; done"
network_mode: host
# networks:
# default:
+3
View File
@@ -0,0 +1,3 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
+25
View File
@@ -33,6 +33,7 @@ class Point(Base, speckle_type=GEOMETRY + "Point"):
@classmethod
def from_list(cls, args: List[float]) -> "Point":
"""Create a new Point from a list of three floats representing the x, y, and z coordinates"""
return cls(x=args[0], y=args[1], z=args[2])
def to_list(self) -> List[Any]:
@@ -40,6 +41,7 @@ class Point(Base, speckle_type=GEOMETRY + "Point"):
@classmethod
def from_coords(cls, x: float = 0.0, y: float = 0.0, z: float = 0.0):
"""Create a new Point from x, y, and z values"""
pt = Point()
pt.x, pt.y, pt.z = x, y, z
return pt
@@ -216,6 +218,7 @@ class Polyline(Base, speckle_type=GEOMETRY + "Polyline", chunkable={"value": 200
@classmethod
def from_points(cls, points: List[Point]):
"""Create a new Polyline from a list of Points"""
polyline = cls()
polyline.units = points[0].units
polyline.value = []
@@ -391,6 +394,28 @@ class Mesh(
area: float = None
volume: float = None
@classmethod
def create(
cls,
vertices: List[float],
faces: List[int],
colors: List[int] = None,
texture_coordinates: List[float] = None,
) -> "Mesh":
"""
Create a new Mesh from lists representing its vertices, faces,
colors (optional), and texture coordinates (optional).
This will initialise empty lists for colors and texture coordinates
if you do not provide any.
"""
return cls(
vertices=vertices,
faces=faces,
colors=colors or [],
textureCoordinates=texture_coordinates or [],
)
class Surface(Base, speckle_type=GEOMETRY + "Surface"):
degreeU: int = None
+40
View File
@@ -0,0 +1,40 @@
"""Builtin Speckle object kit."""
from specklepy.objects.structural.analysis import *
from specklepy.objects.structural.properties import *
from specklepy.objects.structural.material import *
from specklepy.objects.structural.geometry import *
from specklepy.objects.structural.loading import *
from specklepy.objects.structural.axis import Axis
__all__ = [
"Element1D",
"Element2D",
"Element3D",
"Axis",
"Node",
"Restraint",
"Load",
"LoadBeam",
"LoadCase",
"LoadCombinations",
"LoadFace",
"LoadGravity",
"LoadNode",
"Model",
"ModelInfo",
"ModelSettings",
"ModelUnits",
"Concrete",
"Material",
"Steel",
"Timber",
"Property",
"Property1D",
"Property2D",
"Property3D",
"PropertyDamper",
"PropertyMass",
"PropertySpring",
"SectionProfile",
]
+53
View File
@@ -0,0 +1,53 @@
from enum import Enum
import enum
from typing import Any, List, Optional
from ..base import Base
from ..geometry import *
from .properties import *
STRUCTURAL_ANALYSIS = "Objects.Structural.Analysis."
class ModelUnits(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelUnits"):
length: str = None
sections: str = None
displacements: str = None
stress: str = None
force: str = None
mass: str = None
time: str = None
temperature: str = None
velocity: str = None
acceleration: str = None
energy: str = None
angle: str = None
strain: str = None
class ModelSettings(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelSettings"):
modelUnits: ModelUnits = None
steelCode: str = None
concreteCode: str = None
coincidenceTolerance: float = 0.0
class ModelInfo(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelInfo"):
name: str = None
description: str = None
projectNumber: str = None
projectName: str = None
settings: ModelSettings = None
initials: str = None
application: str = None
class Model(Base, speckle_type=STRUCTURAL_ANALYSIS + "Model"):
specs: ModelInfo = None
nodes: List = None
elements: List = None
loads: List = None
restraints: List = None
properties: List = None
materials: List = None
layerDescription: str = None
+8
View File
@@ -0,0 +1,8 @@
from ..base import Base
from ..geometry import Plane
class Axis(Base, speckle_type="Objects.Structural.Geometry.Axis"):
name: str = None
axisType: str = None
plane: Plane = None
+109
View File
@@ -0,0 +1,109 @@
from enum import Enum
import enum
from typing import Any, List, Optional
from ..base import Base
from ..geometry import *
from .properties import *
from .axis import Axis
STRUCTURAL_GEOMETRY = "Objects.Structural.Geometry"
class ElementType1D(int, Enum):
Beam = 0
Brace = 1
Bar = 2
Column = 3
Rod = 4
Spring = 5
Tie = 6
Strut = 7
Link = 8
Damper = 9
Cable = 10
Spacer = 11
Other = 12
Null = 13
class ElementType2D(int, Enum):
Quad4 = 0
Quad8 = 1
Triangle3 = 2
Triangle6 = 3
class ElementType3D(int, Enum):
Brick8 = 0
Wedge6 = 1
Pyramid5 = 2
Tetra4 = 3
class Restraint(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Restraint"):
code: str = None
stiffnessX: float = 0.0
stiffnessY: float = 0.0
stiffnessZ: float = 0.0
stiffnessXX: float = 0.0
stiffnessYY: float = 0.0
stiffnessZZ: float = 0.0
units: str = None
class Node(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Node"):
name: str = None
basePoint: Point = None
constraintAxis: Axis = None
restraint: Restraint = None
springProperty: PropertySpring = None
massProperty: PropertyMass = None
damperProperty: PropertyDamper = None
units: str = None
class Element1D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element1D"):
name: str = None
baseLine: Line = None
property: Property1D = None
type: ElementType1D = None
end1Releases: Restraint = None
end2Releases: Restraint = None
end1Offset: Vector = None
end2Offset: Vector = None
orientationNode: Node = None
orinetationAngle: float = 0.0
localAxis: Plane = None
parent: Base = None
end1Node: Node = Node
end2Node: Node = Node
topology: List = None
displayMesh: Mesh = None
units: str = None
class Element2D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element2D"):
name: str = None
property: Property2D = None
type: ElementType2D = None
offset: float = 0.0
orientationAngle: float = 0.0
parent: Base = None
topology: List = None
displayMesh: Mesh = None
units: str = None
class Element3D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element3D"):
name: str = None
baseMesh: Mesh = None
property: Property3D = None
type: ElementType3D = None
orientationAngle: float = 0.0
parent: Base = None
topology: List
units: str = None
# class Storey needs ependency on built elements first
+144
View File
@@ -0,0 +1,144 @@
from enum import Enum
from typing import Any, List, Optional
from ..base import Base
from .geometry import *
STRUCTURAL_LOADING = "Objects.Structural.Loading."
class LoadType(int, Enum):
none = 0
Dead = 1
SuperDead = 2
Soil = 3
Live = 4
LiveRoof = 5
ReducibleLive = 6
Wind = 7
Snow = 8
Rain = 9
Thermal = 10
Notional = 11
Prestress = 12
Equivalent = 13
Accidental = 14
SeismicRSA = 15
SeismicAccTorsion = 16
SeismicStatic = 17
Other = 18
class ActionType(int, Enum):
none = 0
Permanent = 1
Variable = 2
Accidental = 3
class BeamLoadType(int, Enum):
Point = 0
Uniform = 1
Linear = 2
Patch = 3
TriLinear = 4
class FaceLoadType(int, Enum):
Constant = 0
Variable = 1
Point = 2
class LoadDirection2D(int, Enum):
X = 0
Y = 1
Z = 2
class LoadDirection(int, Enum):
X = 0
Y = 1
Z = 2
XX = 3
YY = 4
ZZ = 5
class LoadAxisType(int, Enum):
Global = 0
Local = 1 # local element axes
DeformedLocal = (
2 # element local axis that is embedded in the element as it deforms
)
class CombinationType(int, Enum):
LinearAdd = 0
Envelope = 1
AbsoluteAdd = 2
SRSS = 3
RangeAdd = 4
class LoadCase(Base, speckle_type=STRUCTURAL_LOADING + "LoadCase"):
name: str = None
loadType: LoadType = None
group: str = None
actionType: ActionType = None
description: str = None
class Load(Base, speckle_type=STRUCTURAL_LOADING + "Load"):
name: str = None
units: str = None
loadCase: LoadCase = None
class LoadBeam(Load, speckle_type=STRUCTURAL_LOADING + "LoadBeam"):
elements: List = None
loadType: BeamLoadType = None
direction: LoadDirection = None
loadAxis: Axis = None
loadAxisType: LoadAxisType = None
isProjected: bool = None
values: List = None
positions: List = None
class LoadCombinations(Base, speckle_type=STRUCTURAL_LOADING + "LoadCombination"):
name: str = None
loadCases: List
loadFactors: List
combinationType: CombinationType
class LoadFace(Load, speckle_type=STRUCTURAL_LOADING + "LoadFace"):
elements: List = None
loadType: FaceLoadType = None
direction: LoadDirection2D = None
loadAxis: Axis = None
loadAxisType: LoadAxisType = None
isProjected: bool = None
values: List = None
positions: List = None
class LoadGravity(Load, speckle_type=STRUCTURAL_LOADING + "LoadGravity"):
elements: List = None
nodes: List = None
gravityFactors: Vector = None
class LoadNode(Load, speckle_type=STRUCTURAL_LOADING + "LoadNode"):
nodes: List = None
loadAxis: Axis = None
direction: LoadDirection = None
value: float = 0.0
+60
View File
@@ -0,0 +1,60 @@
from enum import Enum
from typing import Any, List, Optional
from ..base import Base
STRUCTURAL_MATERIALS = "Objects.Structural.Materials"
class MaterialType(int, Enum):
Concrete = 0
Steel = 1
Timber = 2
Aluminium = 3
Masonry = 4
FRP = 5
Glass = 6
Fabric = 7
Rebar = 8
Tendon = 9
ColdFormed = 10
Other = 11
class Material(Base, speckle_type=STRUCTURAL_MATERIALS):
name: str = None
grade: str = None
materialType: MaterialType = None
designCode: str = None
codeYear: str = None
strength: float = 0.0
elasticModulus: float = 0.0
poissonsRatio: float = 0.0
shearModulus: float = 0.0
density: float = 0.0
thermalExpansivity: float = 0.0
dampingRatio: float = 0.0
cost: float = 0.0
materialSafetyFactor: float = 0.0
class Concrete(Material, speckle_type=STRUCTURAL_MATERIALS + ".Concrete"):
compressiveStrength: float = 0.0
tensileStrength: float = 0.0
flexuralStrength: float = 0.0
maxCompressiveStrength: float = 0.0
maxTensileStrength: float = 0.0
maxAggregateSize: float = 0.0
lightweight: bool = None
class Steel(Material, speckle_type=STRUCTURAL_MATERIALS + ".Steel"):
yieldStrength: float = 0.0
ultimateStrength: float = 0.0
maxStrain: float = 0.0
strainHardeningModulus: float = 0.0
class Timber(Material, speckle_type=STRUCTURAL_MATERIALS + ".Timber"):
species: str = None
+214
View File
@@ -0,0 +1,214 @@
from enum import Enum
from typing import Any, List, Optional
from ..base import Base
from .material import *
from .axis import Axis
STRUCTURAL_PROPERTY = "Objectives.Structural.Properties"
class MemberType(int, Enum):
Beam = 0
Column = 1
Generic1D = 2
Slab = 3
Wall = 4
Generic2D = 5
VoidCutter1D = 6
VoidCutter2D = 7
class BaseReferencePoint(int, Enum):
Centroid = 0
TopLeft = 1
TopCentre = 2
TopRight = 3
MidLeft = 4
MidRight = 5
BotLeft = 6
BotCentre = 7
BotRight = 8
class ReferenceSurface(int, Enum):
Top = 0
Middle = 1
Bottom = 2
class PropertyType2D(int, Enum):
Stress = 0
Fabric = 1
Plate = 2
Shell = 3
Curved = 4
Wall = 5
Strain = 6
Axi = 7
Load = 8
class PropertyType3D(int, Enum):
Solid = 0
Infinite = 1
class ShapeType(int, Enum):
Rectangular = 0
Circular = 1
I = 2
Tee = 3
Angle = 4
Channel = 5
Perimeter = 6
Box = 7
Catalogue = 8
Explicit = 9
class PropertyTypeSpring(int, Enum):
Axial = 0
Torsional = 1
General = 2
Matrix = 3
TensionOnly = 4
CompressionOnly = 5
Connector = 6
LockUp = 7
Gap = 8
Friction = 9
class PropertyTypeDamper(int, Enum):
Axial = 0
Torsional = 1
General = 2
class Property(Base, speckle_type=STRUCTURAL_PROPERTY):
name: str = None
class SectionProfile(Base, speckle_type=STRUCTURAL_PROPERTY + ".SectionProfile"):
name: str = None
shapeType: ShapeType = None
area: float = 0.0
Iyy: float = 0.0
Izz: float = 0.0
J: float = 0.0
Ky: float = 0.0
weight: float = 0.0
units: str = None
class Property1D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property1D"):
memberType: MemberType = None
Material: Material = None
SectionProfile: SectionProfile = None
BaseReferencePoint: BaseReferencePoint = None
offsetY: float = 0.0
offsetZ: float = 0.0
class Property2D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property2D"):
PropertyType2D: PropertyType2D = None
thickness: float = 0.0
Material: Material = None
axis: Axis = None
referenceSurface: ReferenceSurface = None
zOffset: float = 0.0
modifierInPlane: float = 0.0
modifierBending: float = 0.0
modifierShear: float = 0.0
modifierVolume: float = 0.0
class Property3D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property3D"):
PropertyType3D: PropertyType3D = None
Material: Material = None
axis: Axis = None
class PropertyDamper(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertyDamper"):
damperType: PropertyTypeDamper = None
dampingX: float = 0.0
dampingY: float = 0.0
dampingZ: float = 0.0
dampingXX: float = 0.0
dampingYY: float = 0.0
dampingZZ: float = 0.0
class PropertyMass(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertyMass"):
mass: float = 0.0
inertiaXX: float = 0.0
inertiaYY: float = 0.0
inertiaZZ: float = 0.0
inertiaXY: float = 0.0
inertiaYZ: float = 0.0
inertiaZX: float = 0.0
massModified: bool = None
massModifierX: float = 0.0
massModifierY: float = 0.0
massModifierZ: float = 0.0
class PropertySpring(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertySpring"):
springType: PropertyTypeSpring = None
springCurveX: float = 0.0
stiffnessX: float = 0.0
springCurveY: float = 0.0
stiffnessY: float = 0.0
springCurveZ: float = 0.0
stiffnessZ: float = 0.0
springCurveXX: float = 0.0
stiffnessXX: float = 0.0
springCurveYY: float = 0.0
stiffnessYY: float = 0.0
springCurveZZ: float = 0.0
stiffnessZZ: float = 0.0
dampingRatio: float = 0.0
dampingX: float = 0.0
dampingY: float = 0.0
dampingZ: float = 0.0
dampingXX: float = 0.0
dampingYY: float = 0.0
dampingZZ: float = 0.0
matrix: float = 0.0
postiveLockup: float = 0.0
frictionCoefficient: float = 0.0
class ReferenceSurfaceEnum(int, Enum):
Concrete = 0
Steel = 1
Timber = 2
Aluminium = 3
Masonry = 4
FRP = 5
Glass = 6
Fabric = 7
Rebar = 8
Tendon = 9
ColdFormed = 10
Other = 11
class shapeType(int, Enum):
Concrete = 0
Steel = 1
Timber = 2
Aluminium = 3
Masonry = 4
FRP = 5
Glass = 6
Fabric = 7
Rebar = 8
Tendon = 9
ColdFormed = 10
Other = 11
+176
View File
@@ -0,0 +1,176 @@
from enum import Enum
import enum
from typing import Any, List, Optional
from ..base import Base
from ..geometry import *
from .loading import *
from .geometry import *
from .analysis import Model
STRUCTURAL_RESULTS = "Objects.Structural.Results."
class Result(Base, speckle_type=STRUCTURAL_RESULTS + "Result"):
resultCase: Base = None
permutation: str = None
description: str = None
class ResultSet1D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet1D"):
results1D: List
class Result1D(Result, speckle_type=STRUCTURAL_RESULTS + "Result1D"):
element: Element1D = None
position: float = 0.0
dispX: float = 0.0
dispY: float = 0.0
dispZ: float = 0.0
rotXX: float = 0.0
rotYY: float = 0.0
rotZZ: float = 0.0
forceX: float = 0.0
forceY: float = 0.0
forceZ: float = 0.0
momentXX: float = 0.0
momentYY: float = 0.0
momentZZ: float = 0.0
axialStress: float = 0.0
shearStressY: float = 0.0
shearStressZ: float = 0.0
bendingStressYPos: float = 0.0
bendingStressYNeg: float = 0.0
bendingStressZPos: float = 0.0
bendingStressZNeg: float = 0.0
combinedStressMax: float = 0.0
combinedStressMin: float = 0.0
class ResultSet2D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet2D"):
results2D: List
class Result2D(Result, speckle_type=STRUCTURAL_RESULTS + "Result2D"):
element: Element2D = None
position: List
dispX: float = 0.0
dispY: float = 0.0
dispZ: float = 0.0
forceXX: float = 0.0
forceYY: float = 0.0
forceXY: float = 0.0
momentXX: float = 0.0
momentYY: float = 0.0
momentXY: float = 0.0
shearX: float = 0.0
shearY: float = 0.0
stressTopXX: float = 0.0
stressTopYY: float = 0.0
stressTopZZ: float = 0.0
stressTopXY: float = 0.0
stressTopYZ: float = 0.0
stressTopZX: float = 0.0
stressMidXX: float = 0.0
stressMidYY: float = 0.0
stressMidZZ: float = 0.0
stressMidXY: float = 0.0
stressMidYZ: float = 0.0
stressMidZX: float = 0.0
stressBotXX: float = 0.0
stressBotYY: float = 0.0
stressBotZZ: float = 0.0
stressBotXY: float = 0.0
stressBotYZ: float = 0.0
stressBotZX: float = 0.0
class ResultSet3D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet3D"):
results3D: List
class Result3D(Result, speckle_type=STRUCTURAL_RESULTS + "Result3D"):
element: Element3D = None
position: List
dispX: float = 0.0
dispY: float = 0.0
dispZ: float = 0.0
stressXX: float = 0.0
stressYY: float = 0.0
stressZZ: float = 0.0
stressXY: float = 0.0
stressYZ: float = 0.0
stressZX: float = 0.0
class ResultGlobal(Result, speckle_type=STRUCTURAL_RESULTS + "ResultGlobal"):
model: Model = None
loadX: float = 0.0
loadY: float = 0.0
loadZ: float = 0.0
loadXX: float = 0.0
loadYY: float = 0.0
loadZZ: float = 0.0
reactionX: float = 0.0
reactionY: float = 0.0
reactionZ: float = 0.0
reactionXX: float = 0.0
reactionYY: float = 0.0
reactionZZ: float = 0.0
mode: float = 0.0
frequency: float = 0.0
loadFactor: float = 0.0
modalStiffness: float = 0.0
modalGeoStiffness: float = 0.0
effMassX: float = 0.0
effMassY: float = 0.0
effMassZ: float = 0.0
effMassXX: float = 0.0
effMassYY: float = 0.0
effMassZZ: float = 0.0
class ResultSetNode(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSetNode"):
resultsNode: List
class ResultNode(Result, speckle_type=STRUCTURAL_RESULTS + " ResultNode"):
node: Node = None
dispX: float = 0.0
dispY: float = 0.0
dispZ: float = 0.0
rotXX: float = 0.0
rotYY: float = 0.0
rotZZ: float = 0.0
reactionX: float = 0.0
reactionY: float = 0.0
reactionZ: float = 0.0
reactionXX: float = 0.0
reactionYY: float = 0.0
reactionZZ: float = 0.0
constraintX: float = 0.0
constraintY: float = 0.0
constraintZ: float = 0.0
constraintXX: float = 0.0
constraintYY: float = 0.0
constraintZZ: float = 0.0
velX: float = 0.0
velY: float = 0.0
velZ: float = 0.0
velXX: float = 0.0
velYY: float = 0.0
velZZ: float = 0.0
accX: float = 0.0
accY: float = 0.0
accZ: float = 0.0
accXX: float = 0.0
accYY: float = 0.0
accZZ: float = 0.0
class ResultSetAll(Base, speckle_type=None):
resultSet1D: ResultSet1D = None
resultSet2D: ResultSet2D = None
resultSet3D: ResultSet3D = None
resultsGlobal: ResultGlobal = None
resultsNode: ResultSetNode = None
+12 -11
View File
@@ -1,12 +1,12 @@
import json
import time
import requests
from warnings import warn
from typing import Any, Dict, List, Type
from specklepy.api.client import SpeckleClient
from specklepy.logging.exceptions import SpeckleException
from specklepy.logging.exceptions import SpeckleException, SpeckleWarning
from specklepy.transports.abstract_transport import AbstractTransport
from .batch_sender import BatchSender
@@ -65,12 +65,15 @@ class ServerTransport(AbstractTransport):
)
if client:
if not client.me:
raise SpeckleException(
"The provided SpeckleClient was not authenticated."
)
token = client.me["token"]
url = client.url
if not client.me:
warn(
SpeckleWarning(
f"Unauthenticated Speckle Client provided to Server Transport for {self.url}. Receiving from private streams will fail."
)
)
else:
token = client.me["token"]
self.stream_id = stream_id
self.url = url
@@ -120,8 +123,7 @@ class ServerTransport(AbstractTransport):
) -> str:
endpoint = f"{self.url}/objects/{self.stream_id}/{id}/single"
r = self.session.get(endpoint)
if r.encoding is None:
r.encoding = "utf-8"
r.encoding = "utf-8"
if r.status_code != 200:
raise SpeckleException(
@@ -143,8 +145,7 @@ class ServerTransport(AbstractTransport):
r = self.session.post(
endpoint, data={"objects": json.dumps(new_children_ids)}, stream=True
)
if r.encoding is None:
r.encoding = "utf-8"
r.encoding = "utf-8"
lines = r.iter_lines(decode_unicode=True)
# iter through returned objects saving them as we go
+13
View File
@@ -3,6 +3,7 @@ from typing import Callable
import pytest
from specklepy.api import operations
from specklepy.logging.exceptions import SpeckleException
from specklepy.objects.base import Base
from specklepy.objects.encoding import CurveArray, ObjectArray
from specklepy.objects.geometry import (
@@ -450,3 +451,15 @@ def test_serialized_brep_attributes(brep: Brep):
for k in removed_keys:
assert k not in serialized_dict.keys()
def test_mesh_create():
vertices = [2, 1, 2, 4, 77.3, 5, 33, 4, 2]
faces = [1, 2, 3, 4, 5, 6, 7]
mesh = Mesh.create(vertices, faces)
with pytest.raises(SpeckleException):
bad_mesh = Mesh.create(vertices=7, faces=faces)
assert mesh.vertices == vertices
assert mesh.textureCoordinates == []