fix(objects): update structural objects to better match core

This commit is contained in:
Gergő Jedlicska
2022-12-09 19:46:48 +01:00
parent 1a9b847c44
commit c8808b07b3
4 changed files with 47 additions and 46 deletions
+15 -12
View File
@@ -1,6 +1,7 @@
from enum import Enum
from typing import Optional
from ..base import Base
from specklepy.objects.base import Base
STRUCTURAL_MATERIALS = "Objects.Structural.Materials"
@@ -21,12 +22,14 @@ class MaterialType(int, Enum):
Other = 11
class Material(Base, speckle_type=STRUCTURAL_MATERIALS):
name: str = None
grade: str = None
materialType: MaterialType = None
designCode: str = None
codeYear: str = None
class StructuralMaterial(
Base, speckle_type=STRUCTURAL_MATERIALS + ".StructuralMaterial"
):
name: Optional[str] = None
grade: Optional[str] = None
materialType: Optional[MaterialType] = None
designCode: Optional[str] = None
codeYear: Optional[str] = None
strength: float = 0.0
elasticModulus: float = 0.0
poissonsRatio: float = 0.0
@@ -38,22 +41,22 @@ class Material(Base, speckle_type=STRUCTURAL_MATERIALS):
materialSafetyFactor: float = 0.0
class Concrete(Material, speckle_type=STRUCTURAL_MATERIALS + ".Concrete"):
class Concrete(StructuralMaterial, speckle_type=STRUCTURAL_MATERIALS + ".Concrete"):
compressiveStrength: float = 0.0
tensileStrength: float = 0.0
flexuralStrength: float = 0.0
maxCompressiveStrain: float = 0.0
maxTensileStrain: float = 0.0
maxAggregateSize: float = 0.0
lightweight: bool = None
lightweight: Optional[bool] = None
class Steel(Material, speckle_type=STRUCTURAL_MATERIALS + ".Steel"):
class Steel(StructuralMaterial, 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
class Timber(StructuralMaterial, speckle_type=STRUCTURAL_MATERIALS + ".Timber"):
species: Optional[str] = None
+22 -22
View File
@@ -1,9 +1,9 @@
from enum import Enum
from typing import Optional
from ..base import Base
from .material import *
from .axis import Axis
from specklepy.objects.base import Base
from specklepy.objects.structural.material import StructuralMaterial
from specklepy.objects.structural.axis import Axis
STRUCTURAL_PROPERTY = "Objectives.Structural.Properties"
@@ -89,36 +89,36 @@ class PropertyTypeDamper(int, Enum):
class Property(Base, speckle_type=STRUCTURAL_PROPERTY):
name: str = None
name: Optional[str] = None
class SectionProfile(Base, speckle_type=STRUCTURAL_PROPERTY + ".SectionProfile"):
name: str = None
shapeType: ShapeType = None
name: Optional[str] = None
shapeType: Optional[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
units: Optional[str] = None
class Property1D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property1D"):
memberType: MemberType = None
material : Material = None
profile: SectionProfile = None
referencePoint : BaseReferencePoint = None
memberType: Optional[MemberType] = None
material: Optional[StructuralMaterial] = None
profile: Optional[SectionProfile] = None
referencePoint: Optional[BaseReferencePoint] = None
offsetY: float = 0.0
offsetZ: float = 0.0
class Property2D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property2D"):
type: PropertyType2D = None
type: Optional[PropertyType2D] = None
thickness: float = 0.0
material: Material = None
orientationAxis : Axis = None
refSurface : ReferenceSurface = None
material: Optional[StructuralMaterial] = None
orientationAxis: Optional[Axis] = None
refSurface: Optional[ReferenceSurface] = None
zOffset: float = 0.0
modifierInPlane: float = 0.0
modifierBending: float = 0.0
@@ -127,13 +127,13 @@ class Property2D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property2D"):
class Property3D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property3D"):
type: PropertyType3D = None
material: Material = None
orientationAxis: Axis = None
type: Optional[PropertyType3D] = None
material: Optional[StructuralMaterial] = None
orientationAxis: Optional[Axis] = None
class PropertyDamper(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertyDamper"):
damperType: PropertyTypeDamper = None
damperType: Optional[PropertyTypeDamper] = None
dampingX: float = 0.0
dampingY: float = 0.0
dampingZ: float = 0.0
@@ -150,14 +150,14 @@ class PropertyMass(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertyMass")
inertiaXY: float = 0.0
inertiaYZ: float = 0.0
inertiaZX: float = 0.0
massModified: bool = None
massModified: Optional[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
springType: Optional[PropertyTypeSpring] = None
springCurveX: float = 0.0
stiffnessX: float = 0.0
springCurveY: float = 0.0
+8 -2
View File
@@ -57,7 +57,10 @@ def get_units_from_encoding(unit: int):
return name
raise SpeckleException(
message=f"Could not understand what unit {unit} is referring to. Please enter a valid unit encoding (eg {UNITS_ENCODINGS})."
message=(
f"Could not understand what unit {unit} is referring to."
f"Please enter a valid unit encoding (eg {UNITS_ENCODINGS})."
)
)
@@ -66,5 +69,8 @@ def get_encoding_from_units(unit: Union[Units, None]):
return UNITS_ENCODINGS[unit]
except KeyError as e:
raise SpeckleException(
message=f"No encoding exists for unit {unit}. Please enter a valid unit to encode (eg {UNITS_ENCODINGS})."
message=(
f"No encoding exists for unit {unit}."
f"Please enter a valid unit to encode (eg {UNITS_ENCODINGS})."
)
) from e
+2 -10
View File
@@ -1,18 +1,10 @@
import json
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 (
Line,
Mesh,
Point,
Vector,
)
from specklepy.transports.memory import MemoryTransport
from specklepy.objects.structural.geometry import (
Node,
Element1D,
@@ -29,7 +21,7 @@ from specklepy.objects.structural.properties import (
ShapeType,
)
from specklepy.objects.structural.material import (
Material,
StructuralMaterial,
)
from specklepy.objects.structural.analysis import Model
@@ -82,7 +74,7 @@ def node(restraint, point):
@pytest.fixture()
def material():
return Material(name="TestMaterial")
return StructuralMaterial(name="TestMaterial")
@pytest.fixture()