diff --git a/src/specklepy/core/api/models/__init__.py b/src/specklepy/core/api/models/__init__.py index 92c72477..32103678 100644 --- a/src/specklepy/core/api/models/__init__.py +++ b/src/specklepy/core/api/models/__init__.py @@ -29,6 +29,8 @@ Stream, Streams, ) +from specklepy.core.api.models.instances import InstanceDefinitionProxy, InstanceProxy +from specklepy.core.api.models.proxies import ColorProxy, GroupProxy from specklepy.core.api.models.subscription_messages import ( ProjectModelsUpdatedMessage, ProjectUpdatedMessage, @@ -68,4 +70,8 @@ "Streams", "Activity", "ActivityCollection", + "InstanceProxy", + "InstanceDefinitionProxy", + "ColorProxy", + "GroupProxy", ] diff --git a/src/specklepy/core/api/models/instances.py b/src/specklepy/core/api/models/instances.py new file mode 100644 index 00000000..fd72030f --- /dev/null +++ b/src/specklepy/core/api/models/instances.py @@ -0,0 +1,28 @@ +from specklepy.objects.base import Base + + +class InstanceProxy( + Base, + speckle_type="Speckle.Core.Models.Instances.InstanceProxy", +): + """ + A proxy class for an instance (e.g, a rhino block, or an autocad block reference). + """ + + definitionId: str + transform: list[float] + units: str + maxDepth: int + + +class InstanceDefinitionProxy( + Base, + speckle_type="Speckle.Core.Models.Instances.InstanceDefinitionProxy", +): + """ + A proxy class for an instance definition. + """ + + objects: list[str] + maxDepth: int + name: str diff --git a/src/specklepy/core/api/models/proxies.py b/src/specklepy/core/api/models/proxies.py new file mode 100644 index 00000000..d0ac2964 --- /dev/null +++ b/src/specklepy/core/api/models/proxies.py @@ -0,0 +1,27 @@ +from specklepy.objects.base import Base + + +class ColorProxy( + Base, + speckle_type="Speckle.Core.Models.Proxies.ColorProxy", +): + """ + Represents a color that is found on objects and collections in a root collection. + """ + + objects: list[str] + value: int + name: str | None # nullable but required + + +class GroupProxy( + Base, + speckle_type="Speckle.Core.Models.Proxies.GroupProxy", +): + """ + Grouped objects with a meaningful way for host application so use this proxy if you want to group object references for any purpose. + i.e. in rhino -> creating group make objects selectable/moveable/editable together. + """ + + objects: list[str] + name: str diff --git a/src/specklepy/objects/GIS/CRS.py b/src/specklepy/objects/GIS/CRS.py deleted file mode 100644 index 2527fe55..00000000 --- a/src/specklepy/objects/GIS/CRS.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Optional - -from specklepy.objects.base import Base - - -class CRS(Base, speckle_type="Objects.GIS.CRS"): - """A Coordinate Reference System stored in wkt format""" - - name: Optional[str] = None - authority_id: Optional[str] = None - wkt: Optional[str] = None - units_native: Optional[str] = None - offset_x: Optional[float] = None - offset_y: Optional[float] = None - rotation: Optional[float] = None diff --git a/src/specklepy/objects/GIS/__init__.py b/src/specklepy/objects/GIS/__init__.py deleted file mode 100644 index 5ac3dff8..00000000 --- a/src/specklepy/objects/GIS/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Builtin Speckle object kit.""" - -from specklepy.objects.GIS.CRS import CRS -from specklepy.objects.GIS.geometry import ( - GisLineElement, - GisPointElement, - GisPolygonElement, - GisPolygonGeometry, - GisRasterElement, - PolygonGeometry, -) -from specklepy.objects.GIS.layers import RasterLayer, VectorLayer - -__all__ = [ - "VectorLayer", - "RasterLayer", - "GisPolygonGeometry", - "PolygonGeometry", - "GisPolygonElement", - "GisLineElement", - "GisPointElement", - "GisRasterElement", - "CRS", -] diff --git a/src/specklepy/objects/GIS/geometry.py b/src/specklepy/objects/GIS/geometry.py deleted file mode 100644 index 68df54cf..00000000 --- a/src/specklepy/objects/GIS/geometry.py +++ /dev/null @@ -1,74 +0,0 @@ -from typing import List, Optional, Union - -from specklepy.objects.base import Base -from specklepy.objects.geometry import ( - Arc, - Circle, - Line, - Mesh, - Point, - Polycurve, - Polyline, -) - - -class PolygonGeometry(Base, speckle_type="Objects.GIS.PolygonGeometry"): - """GIS Polygon Geometry""" - - boundary: Optional[Polyline] - voids: Optional[List[Polyline]] - - -GisPolygonGeometry = PolygonGeometry - - -class GisPolygonElement(Base, speckle_type="Objects.GIS.PolygonElement"): - """GIS Polygon element""" - - geometry: Optional[List[GisPolygonGeometry]] = None - attributes: Optional[Base] = None - - -class GisLineElement(Base, speckle_type="Objects.GIS.LineElement"): - """GIS Polyline element""" - - geometry: Optional[List[Union[Polyline, Arc, Line, Circle, Polycurve]]] = None - attributes: Optional[Base] = None - - -class GisPointElement(Base, speckle_type="Objects.GIS.PointElement"): - """GIS Point element""" - - geometry: Optional[List[Point]] = None - attributes: Optional[Base] = None - - -class GisRasterElement( - Base, speckle_type="Objects.GIS.RasterElement", detachable={"displayValue"} -): - """GIS Raster element""" - - band_count: Optional[int] = None - band_names: Optional[List[str]] = None - x_origin: Optional[float] = None - y_origin: Optional[float] = None - x_size: Optional[int] = None - y_size: Optional[int] = None - x_resolution: Optional[float] = None - y_resolution: Optional[float] = None - noDataValue: Optional[List[float]] = None - displayValue: Optional[List[Mesh]] = None - - -class GisTopography( - GisRasterElement, - speckle_type="Objects.GIS.GisTopography", - detachable={"displayValue"}, -): - """GIS Raster element with 3d Topography representation""" - - -class GisNonGeometryElement(Base, speckle_type="Objects.GIS.NonGeometryElement"): - """GIS Table feature""" - - attributes: Optional[Base] = None diff --git a/src/specklepy/objects/GIS/layers.py b/src/specklepy/objects/GIS/layers.py deleted file mode 100644 index 3db33351..00000000 --- a/src/specklepy/objects/GIS/layers.py +++ /dev/null @@ -1,142 +0,0 @@ -from typing import Any, Dict, List, Optional, Union - -from deprecated import deprecated - -from specklepy.objects.base import Base -from specklepy.objects.GIS.CRS import CRS -from specklepy.objects.other import Collection - - -@deprecated(version="2.15", reason="Use VectorLayer or RasterLayer instead") -class Layer(Base, detachable={"features"}): - """A GIS Layer""" - - def __init__( - self, - name: Optional[str] = None, - crs: Optional[CRS] = None, - units: str = "m", - features: Optional[List[Base]] = None, - layerType: str = "None", - geomType: str = "None", - renderer: Optional[Dict[str, Any]] = None, - **kwargs, - ) -> None: - super().__init__(**kwargs) - self.name = name - self.crs = crs - self.units = units - self.type = layerType - self.features = features or [] - self.geomType = geomType - self.renderer = renderer or {} - - -@deprecated(version="2.16", reason="Use VectorLayer or RasterLayer instead") -class VectorLayer( - Collection, - detachable={"elements"}, - speckle_type="VectorLayer", - serialize_ignore={"features"}, -): - """GIS Vector Layer""" - - name: Optional[str] = None - crs: Optional[Union[CRS, Base]] = None - units: Optional[str] = None - elements: Optional[List[Base]] = None - attributes: Optional[Base] = None - geomType: Optional[str] = "None" - renderer: Optional[Dict[str, Any]] = None - collectionType = "VectorLayer" - - @property - @deprecated(version="2.14", reason="Use elements") - def features(self) -> Optional[List[Base]]: - return self.elements - - @features.setter - def features(self, value: Optional[List[Base]]) -> None: - self.elements = value - - -@deprecated(version="2.16", reason="Use VectorLayer or RasterLayer instead") -class RasterLayer( - Collection, - detachable={"elements"}, - speckle_type="RasterLayer", - serialize_ignore={"features"}, -): - """GIS Raster Layer""" - - name: Optional[str] = None - crs: Optional[Union[CRS, Base]] = None - units: Optional[str] = None - rasterCrs: Optional[Union[CRS, Base]] = None - elements: Optional[List[Base]] = None - geomType: Optional[str] = "None" - renderer: Optional[Dict[str, Any]] = None - collectionType = "RasterLayer" - - @property - @deprecated(version="2.14", reason="Use elements") - def features(self) -> Optional[List[Base]]: - return self.elements - - @features.setter - def features(self, value: Optional[List[Base]]) -> None: - self.elements = value - - -class VectorLayer( # noqa: F811 - Collection, - detachable={"elements"}, - speckle_type="Objects.GIS.VectorLayer", - serialize_ignore={"features"}, -): - """GIS Vector Layer""" - - name: Optional[str] = None - crs: Optional[Union[CRS, Base]] = None - units: Optional[str] = None - elements: Optional[List[Base]] = None - attributes: Optional[Base] = None - geomType: Optional[str] = "None" - renderer: Optional[Dict[str, Any]] = None - collectionType = "VectorLayer" - - @property - @deprecated(version="2.14", reason="Use elements") - def features(self) -> Optional[List[Base]]: - return self.elements - - @features.setter - def features(self, value: Optional[List[Base]]) -> None: - self.elements = value - - -class RasterLayer( # noqa: F811 - Collection, - detachable={"elements"}, - speckle_type="Objects.GIS.RasterLayer", - serialize_ignore={"features"}, -): - """GIS Raster Layer""" - - name: Optional[str] = None - crs: Optional[Union[CRS, Base]] = None - units: Optional[str] = None - rasterCrs: Optional[Union[CRS, Base]] = None - elements: Optional[List[Base]] = None - geomType: Optional[str] = "None" - renderer: Optional[Dict[str, Any]] = None - collectionType = "RasterLayer" - - @property - @deprecated(version="2.14", reason="Use elements") - def features(self) -> Optional[List[Base]]: - return self.elements - - @features.setter - def features(self, value: Optional[List[Base]]) -> None: - self.elements = value diff --git a/src/specklepy/objects/__init__.py b/src/specklepy/objects/__init__.py index 85faa492..3305ac2c 100644 --- a/src/specklepy/objects/__init__.py +++ b/src/specklepy/objects/__init__.py @@ -1,14 +1,6 @@ """Builtin Speckle object kit.""" -from specklepy.objects import ( - GIS, - encoding, - geometry, - other, - primitive, - structural, - units, -) +from specklepy.objects import encoding, geometry, other, primitive, units from specklepy.objects.base import Base __all__ = [ @@ -17,7 +9,5 @@ "geometry", "other", "units", - "structural", "primitive", - "GIS", ] diff --git a/src/specklepy/objects/other.py b/src/specklepy/objects/other.py index 5a2576e4..27712a91 100644 --- a/src/specklepy/objects/other.py +++ b/src/specklepy/objects/other.py @@ -1,13 +1,12 @@ -from typing import Any, List, Optional +from typing import List, Optional from deprecated import deprecated -from specklepy.objects.geometry import Plane, Point, Polyline, Vector +from specklepy.objects.geometry import Point, Vector from .base import Base OTHER = "Objects.Other." -OTHER_REVIT = OTHER + "Revit." IDENTITY_TRANSFORM = [ 1.0, @@ -29,21 +28,6 @@ ] -class Material(Base, speckle_type=OTHER + "Material"): - """Generic class for materials containing generic parameters.""" - - name: Optional[str] = None - - -class RevitMaterial(Material, speckle_type="Objects.Other.Revit." + "RevitMaterial"): - materialCategory: Optional[str] = None - materialClass: Optional[str] = None - shininess: Optional[int] = None - smoothness: Optional[int] = None - transparency: Optional[int] = None - parameters: Optional[Base] = None - - class RenderMaterial(Base, speckle_type=OTHER + "RenderMaterial"): name: Optional[str] = None opacity: float = 1 @@ -53,36 +37,16 @@ class RenderMaterial(Base, speckle_type=OTHER + "RenderMaterial"): emissive: int = -16777216 # black arbg -class MaterialQuantity(Base, speckle_type=OTHER + "MaterialQuantity"): - material: Optional[Material] = None - volume: Optional[float] = None - area: Optional[float] = None - - -class DisplayStyle(Base, speckle_type=OTHER + "DisplayStyle"): - """ - Minimal display style class. - Developed primarily for display styles in Rhino and AutoCAD. - Rhino object attributes uses OpenNURBS definition for linetypes and lineweights. - """ - - name: Optional[str] = None - color: int = -2894893 # light gray arbg - linetype: Optional[str] = None - lineweight: float = 0 - - -class Text(Base, speckle_type=OTHER + "Text"): +class RenderMaterialProxy( + Base, + speckle_type="Speckle.Core.Models.Proxies.RenderMaterialProxy", +): """ - Text object to render it on viewer. + Used to store render material to object relationships in root collections. """ - plane: Plane - value: str - height: float - rotation: float - displayValue: Optional[List[Polyline]] = None - richText: Optional[str] = None + objects: list[str] + value: RenderMaterial class Transform( @@ -253,59 +217,10 @@ def from_list(cls, value: Optional[List[float]] = None) -> "Transform": return cls(value=value) -class BlockDefinition( - Base, speckle_type=OTHER + "BlockDefinition", detachable={"geometry"} -): - name: Optional[str] = None - basePoint: Optional[Point] = None - geometry: Optional[List[Base]] = None - - -class Instance(Base, speckle_type=OTHER + "Instance", detachable={"definition"}): - transform: Optional[Transform] = None - definition: Optional[Base] = None - - -class BlockInstance( - Instance, speckle_type=OTHER + "BlockInstance", serialize_ignore={"blockDefinition"} -): - @property - @deprecated(version="2.13", reason="Use definition") - def blockDefinition(self) -> Optional[BlockDefinition]: - if isinstance(self.definition, BlockDefinition): - return self.definition - return None - - @blockDefinition.setter - def blockDefinition(self, value: Optional[BlockDefinition]) -> None: - self.definition = value - - -class RevitInstance(Instance, speckle_type=OTHER_REVIT + "RevitInstance"): - level: Optional[Base] = None - facingFlipped: bool - handFlipped: bool - parameters: Optional[Base] = None - elementId: Optional[str] - - -# TODO: prob move this into a built elements module, but just trialling this for now -class RevitParameter(Base, speckle_type="Objects.BuiltElements.Revit.Parameter"): - name: Optional[str] = None - value: Any = None - applicationUnitType: Optional[str] = None # eg UnitType UT_Length - applicationUnit: Optional[str] = None # DisplayUnitType eg DUT_MILLIMITERS - applicationInternalName: Optional[ - str - ] = None # BuiltInParameterName or GUID for shared parameter - isShared: bool = False - isReadOnly: bool = False - isTypeParameter: bool = False - - class Collection( - Base, speckle_type="Speckle.Core.Models.Collection", detachable={"elements"} + Base, + speckle_type="Speckle.Core.Models.Collections.Collection", + detachable={"elements"}, ): name: Optional[str] = None - collectionType: Optional[str] = None elements: Optional[List[Base]] = None diff --git a/src/specklepy/objects/structural/__init__.py b/src/specklepy/objects/structural/__init__.py deleted file mode 100644 index dc91f3a2..00000000 --- a/src/specklepy/objects/structural/__init__.py +++ /dev/null @@ -1,142 +0,0 @@ -"""Builtin Speckle object kit.""" - -from specklepy.objects.structural.analysis import ( - Model, - ModelInfo, - ModelSettings, - ModelUnits, -) -from specklepy.objects.structural.axis import Axis, AxisType -from specklepy.objects.structural.geometry import ( - Element1D, - Element2D, - Element3D, - ElementType1D, - ElementType2D, - ElementType3D, - Node, - Restraint, -) -from specklepy.objects.structural.loading import ( - ActionType, - BeamLoadType, - CombinationType, - FaceLoadType, - Load, - LoadAxisType, - LoadBeam, - LoadCase, - LoadCombinations, - LoadDirection, - LoadDirection2D, - LoadFace, - LoadGravity, - LoadNode, - LoadType, -) -from specklepy.objects.structural.materials import ( - Concrete, - MaterialType, - Steel, - StructuralMaterial, - Timber, -) -from specklepy.objects.structural.properties import ( - BaseReferencePoint, - MemberType, - Property, - Property1D, - Property2D, - Property3D, - PropertyDamper, - PropertyMass, - PropertySpring, - PropertyType2D, - PropertyType3D, - PropertyTypeDamper, - PropertyTypeSpring, - ReferenceSurface, - ReferenceSurfaceEnum, - SectionProfile, - ShapeType, - shapeType, -) -from specklepy.objects.structural.results import ( - Result, - Result1D, - Result2D, - Result3D, - ResultGlobal, - ResultNode, - ResultSet1D, - ResultSet2D, - ResultSet3D, - ResultSetAll, - ResultSetNode, -) - -__all__ = [ - "Element1D", - "Element2D", - "Element3D", - "ElementType1D", - "ElementType2D", - "ElementType3D", - "AxisType", - "Axis", - "Node", - "Restraint", - "Load", - "LoadType", - "ActionType", - "BeamLoadType", - "FaceLoadType", - "LoadDirection", - "LoadDirection2D", - "LoadAxisType", - "CombinationType", - "LoadBeam", - "LoadCase", - "LoadCombinations", - "LoadFace", - "LoadGravity", - "LoadNode", - "Model", - "ModelInfo", - "ModelSettings", - "ModelUnits", - "MaterialType", - "Concrete", - "StructuralMaterial", - "Steel", - "Timber", - "Property", - "Property1D", - "Property2D", - "Property3D", - "PropertyDamper", - "PropertyMass", - "PropertySpring", - "SectionProfile", - "MemberType", - "BaseReferencePoint", - "ReferenceSurface", - "PropertyType2D", - "PropertyType3D", - "ShapeType", - "PropertyTypeSpring", - "PropertyTypeDamper", - "ReferenceSurfaceEnum", - "shapeType", - "Result", - "Result1D", - "ResultSet1D", - "Result2D", - "ResultSet2D", - "Result3D", - "ResultSet3D", - "ResultGlobal", - "ResultSetNode", - "ResultNode", - "ResultSetAll", -] diff --git a/src/specklepy/objects/structural/analysis.py b/src/specklepy/objects/structural/analysis.py deleted file mode 100644 index ee82eead..00000000 --- a/src/specklepy/objects/structural/analysis.py +++ /dev/null @@ -1,49 +0,0 @@ -from typing import List, Optional - -from specklepy.objects.base import Base - -STRUCTURAL_ANALYSIS = "Objects.Structural.Analysis." - - -class ModelUnits(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelUnits"): - length: Optional[str] = None - sections: Optional[str] = None - displacements: Optional[str] = None - stress: Optional[str] = None - force: Optional[str] = None - mass: Optional[str] = None - time: Optional[str] = None - temperature: Optional[str] = None - velocity: Optional[str] = None - acceleration: Optional[str] = None - energy: Optional[str] = None - angle: Optional[str] = None - strain: Optional[str] = None - - -class ModelSettings(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelSettings"): - modelUnits: Optional[ModelUnits] = None - steelCode: Optional[str] = None - concreteCode: Optional[str] = None - coincidenceTolerance: float = 0.0 - - -class ModelInfo(Base, speckle_type=STRUCTURAL_ANALYSIS + "ModelInfo"): - name: Optional[str] = None - description: Optional[str] = None - projectNumber: Optional[str] = None - projectName: Optional[str] = None - settings: Optional[ModelSettings] = None - initials: Optional[str] = None - application: Optional[str] = None - - -class Model(Base, speckle_type=STRUCTURAL_ANALYSIS + "Model"): - specs: Optional[ModelInfo] = None - nodes: Optional[List] = None - elements: Optional[List] = None - loads: Optional[List] = None - restraints: Optional[List] = None - properties: Optional[List] = None - materials: Optional[List] = None - layerDescription: Optional[str] = None diff --git a/src/specklepy/objects/structural/axis.py b/src/specklepy/objects/structural/axis.py deleted file mode 100644 index aa4408de..00000000 --- a/src/specklepy/objects/structural/axis.py +++ /dev/null @@ -1,17 +0,0 @@ -from enum import Enum -from typing import Optional - -from specklepy.objects.base import Base -from specklepy.objects.geometry import Plane - - -class AxisType(int, Enum): - Cartesian = 0 - Cylindrical = 1 - Spherical = 2 - - -class Axis(Base, speckle_type="Objects.Structural.Geometry.Axis"): - name: Optional[str] = None - axisType: Optional[AxisType] = None - plane: Optional[Plane] = None diff --git a/src/specklepy/objects/structural/geometry.py b/src/specklepy/objects/structural/geometry.py deleted file mode 100644 index f232529b..00000000 --- a/src/specklepy/objects/structural/geometry.py +++ /dev/null @@ -1,110 +0,0 @@ -from enum import Enum -from typing import List, Optional - -from specklepy.objects.base import Base -from specklepy.objects.geometry import Line, Mesh, Plane, Point, Vector -from specklepy.objects.structural.axis import Axis -from specklepy.objects.structural.properties import ( - Property1D, - Property2D, - Property3D, - PropertyDamper, - PropertyMass, - PropertySpring, -) - -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: Optional[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 - - -class Node(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Node"): - name: Optional[str] = None - basePoint: Optional[Point] = None - constraintAxis: Optional[Axis] = None - restraint: Optional[Restraint] = None - springProperty: Optional[PropertySpring] = None - massProperty: Optional[PropertyMass] = None - damperProperty: Optional[PropertyDamper] = None - - -class Element1D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element1D"): - name: Optional[str] = None - baseLine: Optional[Line] = None - property: Optional[Property1D] = None - type: Optional[ElementType1D] = None - end1Releases: Optional[Restraint] = None - end2Releases: Optional[Restraint] = None - end1Offset: Optional[Vector] = None - end2Offset: Optional[Vector] = None - orientationNode: Optional[Node] = None - orinetationAngle: float = 0.0 - localAxis: Optional[Plane] = None - parent: Optional[Base] = None - end1Node: Optional[Node] = None - end2Node: Optional[Node] = None - topology: Optional[List] = None - displayMesh: Optional[Mesh] = None - - -class Element2D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element2D"): - name: Optional[str] = None - property: Optional[Property2D] = None - type: Optional[ElementType2D] = None - offset: float = 0.0 - orientationAngle: float = 0.0 - parent: Optional[Base] = None - topology: Optional[List] = None - displayMesh: Optional[Mesh] = None - - -class Element3D(Base, speckle_type=STRUCTURAL_GEOMETRY + ".Element3D"): - name: Optional[str] = None - baseMesh: Optional[Mesh] = None - property: Optional[Property3D] = None - type: Optional[ElementType3D] = None - orientationAngle: float = 0.0 - parent: Optional[Base] = None - topology: List - - -# class Storey needs ependency on built elements first diff --git a/src/specklepy/objects/structural/loading.py b/src/specklepy/objects/structural/loading.py deleted file mode 100644 index 9e6f1e59..00000000 --- a/src/specklepy/objects/structural/loading.py +++ /dev/null @@ -1,137 +0,0 @@ -from enum import Enum -from typing import List, Optional - -from specklepy.objects.base import Base -from specklepy.objects.geometry import Vector -from specklepy.objects.structural.axis import Axis - -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: Optional[str] = None - loadType: Optional[LoadType] = None - group: Optional[str] = None - actionType: Optional[ActionType] = None - description: Optional[str] = None - - -class Load(Base, speckle_type=STRUCTURAL_LOADING + "Load"): - name: Optional[str] = None - loadCase: Optional[LoadCase] = None - - -class LoadBeam(Load, speckle_type=STRUCTURAL_LOADING + "LoadBeam"): - elements: Optional[List] = None - loadType: Optional[BeamLoadType] = None - direction: Optional[LoadDirection] = None - loadAxis: Optional[Axis] = None - loadAxisType: Optional[LoadAxisType] = None - isProjected: Optional[bool] = None - values: Optional[List] = None - positions: Optional[List] = None - - -class LoadCombinations(Base, speckle_type=STRUCTURAL_LOADING + "LoadCombination"): - name: Optional[str] = None - loadCases: List - loadFactors: List - combinationType: CombinationType - - -class LoadFace(Load, speckle_type=STRUCTURAL_LOADING + "LoadFace"): - elements: Optional[List] = None - loadType: Optional[FaceLoadType] = None - direction: Optional[LoadDirection2D] = None - loadAxis: Optional[Axis] = None - loadAxisType: Optional[LoadAxisType] = None - isProjected: Optional[bool] = None - values: Optional[List] = None - positions: Optional[List] = None - - -class LoadGravity(Load, speckle_type=STRUCTURAL_LOADING + "LoadGravity"): - elements: Optional[List] = None - nodes: Optional[List] = None - gravityFactors: Optional[Vector] = None - - -class LoadNode(Load, speckle_type=STRUCTURAL_LOADING + "LoadNode"): - nodes: Optional[List] = None - loadAxis: Optional[Axis] = None - direction: Optional[LoadDirection] = None - value: float = 0.0 diff --git a/src/specklepy/objects/structural/materials.py b/src/specklepy/objects/structural/materials.py deleted file mode 100644 index ab0abcda..00000000 --- a/src/specklepy/objects/structural/materials.py +++ /dev/null @@ -1,61 +0,0 @@ -from enum import Enum -from typing import Optional - -from specklepy.objects.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 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 - 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(StructuralMaterial): - 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: Optional[bool] = None - - -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(StructuralMaterial, speckle_type=STRUCTURAL_MATERIALS + ".Timber"): - species: Optional[str] = None diff --git a/src/specklepy/objects/structural/properties.py b/src/specklepy/objects/structural/properties.py deleted file mode 100644 index e0153a1e..00000000 --- a/src/specklepy/objects/structural/properties.py +++ /dev/null @@ -1,212 +0,0 @@ -from enum import Enum -from typing import Optional - -from specklepy.objects.base import Base -from specklepy.objects.structural.axis import Axis -from specklepy.objects.structural.materials import StructuralMaterial - -STRUCTURAL_PROPERTY = "Objects.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 # noqa: E741 - Tee = 3 - Angle = 4 - Channel = 5 - Perimeter = 6 - Box = 7 - Catalogue = 8 - Explicit = 9 - Undefined = 10 - - -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: Optional[str] = None - - -class SectionProfile( - Base, speckle_type=STRUCTURAL_PROPERTY + ".Profiles.SectionProfile" -): - 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 - - -class Property1D(Property, speckle_type=STRUCTURAL_PROPERTY + ".Property1D"): - 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: Optional[PropertyType2D] = None - thickness: float = 0.0 - material: Optional[StructuralMaterial] = None - orientationAxis: Optional[Axis] = None - refSurface: Optional[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"): - type: Optional[PropertyType3D] = None - material: Optional[StructuralMaterial] = None - orientationAxis: Optional[Axis] = None - - -class PropertyDamper(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertyDamper"): - damperType: Optional[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: Optional[bool] = None - massModifierX: float = 0.0 - massModifierY: float = 0.0 - massModifierZ: float = 0.0 - - -class PropertySpring(Property, speckle_type=STRUCTURAL_PROPERTY + ".PropertySpring"): - springType: Optional[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 diff --git a/src/specklepy/objects/structural/results.py b/src/specklepy/objects/structural/results.py deleted file mode 100644 index d014f458..00000000 --- a/src/specklepy/objects/structural/results.py +++ /dev/null @@ -1,172 +0,0 @@ -from typing import List, Optional - -from specklepy.objects.base import Base -from specklepy.objects.structural.analysis import Model -from specklepy.objects.structural.geometry import Element1D, Element2D, Element3D, Node - -STRUCTURAL_RESULTS = "Objects.Structural.Results." - - -class Result(Base, speckle_type=STRUCTURAL_RESULTS + "Result"): - resultCase: Optional[Base] = None - permutation: Optional[str] = None - description: Optional[str] = None - - -class ResultSet1D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet1D"): - results1D: List - - -class Result1D(Result, speckle_type=STRUCTURAL_RESULTS + "Result1D"): - element: Optional[Element1D] = None - position: Optional[float] = None - dispX: Optional[float] = None - dispY: Optional[float] = None - dispZ: Optional[float] = None - rotXX: Optional[float] = None - rotYY: Optional[float] = None - rotZZ: Optional[float] = None - forceX: Optional[float] = None - forceY: Optional[float] = None - forceZ: Optional[float] = None - momentXX: Optional[float] = None - momentYY: Optional[float] = None - momentZZ: Optional[float] = None - axialStress: Optional[float] = None - shearStressY: Optional[float] = None - shearStressZ: Optional[float] = None - bendingStressYPos: Optional[float] = None - bendingStressYNeg: Optional[float] = None - bendingStressZPos: Optional[float] = None - bendingStressZNeg: Optional[float] = None - combinedStressMax: Optional[float] = None - combinedStressMin: Optional[float] = None - - -class ResultSet2D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet2D"): - results2D: List - - -class Result2D(Result, speckle_type=STRUCTURAL_RESULTS + "Result2D"): - element: Optional[Element2D] = None - position: List - dispX: Optional[float] = None - dispY: Optional[float] = None - dispZ: Optional[float] = None - forceXX: Optional[float] = None - forceYY: Optional[float] = None - forceXY: Optional[float] = None - momentXX: Optional[float] = None - momentYY: Optional[float] = None - momentXY: Optional[float] = None - shearX: Optional[float] = None - shearY: Optional[float] = None - stressTopXX: Optional[float] = None - stressTopYY: Optional[float] = None - stressTopZZ: Optional[float] = None - stressTopXY: Optional[float] = None - stressTopYZ: Optional[float] = None - stressTopZX: Optional[float] = None - stressMidXX: Optional[float] = None - stressMidYY: Optional[float] = None - stressMidZZ: Optional[float] = None - stressMidXY: Optional[float] = None - stressMidYZ: Optional[float] = None - stressMidZX: Optional[float] = None - stressBotXX: Optional[float] = None - stressBotYY: Optional[float] = None - stressBotZZ: Optional[float] = None - stressBotXY: Optional[float] = None - stressBotYZ: Optional[float] = None - stressBotZX: Optional[float] = None - - -class ResultSet3D(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSet3D"): - results3D: List - - -class Result3D(Result, speckle_type=STRUCTURAL_RESULTS + "Result3D"): - element: Optional[Element3D] = None - position: List - dispX: Optional[float] = None - dispY: Optional[float] = None - dispZ: Optional[float] = None - stressXX: Optional[float] = None - stressYY: Optional[float] = None - stressZZ: Optional[float] = None - stressXY: Optional[float] = None - stressYZ: Optional[float] = None - stressZX: Optional[float] = None - - -class ResultGlobal(Result, speckle_type=STRUCTURAL_RESULTS + "ResultGlobal"): - model: Optional[Model] = None - loadX: Optional[float] = None - loadY: Optional[float] = None - loadZ: Optional[float] = None - loadXX: Optional[float] = None - loadYY: Optional[float] = None - loadZZ: Optional[float] = None - reactionX: Optional[float] = None - reactionY: Optional[float] = None - reactionZ: Optional[float] = None - reactionXX: Optional[float] = None - reactionYY: Optional[float] = None - reactionZZ: Optional[float] = None - mode: Optional[float] = None - frequency: Optional[float] = None - loadFactor: Optional[float] = None - modalStiffness: Optional[float] = None - modalGeoStiffness: Optional[float] = None - effMassX: Optional[float] = None - effMassY: Optional[float] = None - effMassZ: Optional[float] = None - effMassXX: Optional[float] = None - effMassYY: Optional[float] = None - effMassZZ: Optional[float] = None - - -class ResultSetNode(Result, speckle_type=STRUCTURAL_RESULTS + "ResultSetNode"): - resultsNode: List - - -class ResultNode(Result, speckle_type=STRUCTURAL_RESULTS + " ResultNode"): - node: Optional[Node] = None - dispX: Optional[float] = None - dispY: Optional[float] = None - dispZ: Optional[float] = None - rotXX: Optional[float] = None - rotYY: Optional[float] = None - rotZZ: Optional[float] = None - reactionX: Optional[float] = None - reactionY: Optional[float] = None - reactionZ: Optional[float] = None - reactionXX: Optional[float] = None - reactionYY: Optional[float] = None - reactionZZ: Optional[float] = None - constraintX: Optional[float] = None - constraintY: Optional[float] = None - constraintZ: Optional[float] = None - constraintXX: Optional[float] = None - constraintYY: Optional[float] = None - constraintZZ: Optional[float] = None - velX: Optional[float] = None - velY: Optional[float] = None - velZ: Optional[float] = None - velXX: Optional[float] = None - velYY: Optional[float] = None - velZZ: Optional[float] = None - accX: Optional[float] = None - accY: Optional[float] = None - accZ: Optional[float] = None - accXX: Optional[float] = None - accYY: Optional[float] = None - accZZ: Optional[float] = None - - -class ResultSetAll(Base, speckle_type=None): - resultSet1D: Optional[ResultSet1D] = None - resultSet2D: Optional[ResultSet2D] = None - resultSet3D: Optional[ResultSet3D] = None - resultsGlobal: Optional[ResultGlobal] = None - resultsNode: Optional[ResultSetNode] = None diff --git a/tests/unit/test_instances.py b/tests/unit/test_instances.py new file mode 100644 index 00000000..7d55ca10 --- /dev/null +++ b/tests/unit/test_instances.py @@ -0,0 +1,38 @@ +# pylint: disable=redefined-outer-name +import pytest + +from specklepy.core.api.models.instances import InstanceDefinitionProxy, InstanceProxy + + +@pytest.fixture() +def instance_proxy(): + return InstanceProxy( + definitionId="definitionId", transform=[1, 23.5], units="unit", maxDepth=3 + ) + + +@pytest.fixture() +def instance_definition_proxy(): + return InstanceDefinitionProxy( + objects=["app_id_1", "app_id_2"], maxDepth=2, name="group_proxy_name" + ) + + +def test_create_instance_proxy(): + try: + InstanceProxy(definitionId="", transform="", units="", maxDepth=1) # wrong type + assert False + except TypeError: + assert True + except: + assert False + + +def test_create_instance_definition_proxy(): + try: + InstanceDefinitionProxy(objects="", maxDepth=1, name="") # wrong type + assert False + except TypeError: + assert True + except: + assert False diff --git a/tests/unit/test_proxies.py b/tests/unit/test_proxies.py new file mode 100644 index 00000000..08224c52 --- /dev/null +++ b/tests/unit/test_proxies.py @@ -0,0 +1,59 @@ +# pylint: disable=redefined-outer-name +import pytest + +from specklepy.core.api.models.proxies import ColorProxy, GroupProxy +from specklepy.objects.other import RenderMaterial, RenderMaterialProxy + + +@pytest.fixture() +def color_proxy(): + return ColorProxy( + objects=["app_id_1", "app_id_2"], value=11111, name="color_proxy_name" + ) + + +@pytest.fixture() +def group_proxy(): + return GroupProxy(objects=["app_id_1", "app_id_2"], name="group_proxy_name") + + +@pytest.fixture() +def material(): + return RenderMaterial( + name="name", opacity=0.3, metalness=0, roughness=0, diffuse=1, emissive=1 + ) + + +@pytest.fixture() +def material_proxy(): + return RenderMaterialProxy(objects=["app_id_1", "app_id_2"], value=material()) + + +def test_create_color_proxy(): + try: + ColorProxy(objects="", value=2, name="") # wrong type + assert False + except TypeError: + assert True + except: + assert False + + +def test_create_group_proxy(): + try: + GroupProxy(objects="", name="") # wrong type + assert False + except TypeError: + assert True + except: + assert False + + +def test_create_material_proxy(): + try: + RenderMaterialProxy(objects="", name="") # wrong type + assert False + except TypeError: + assert True + except: + assert False diff --git a/tests/unit/test_registering_base.py b/tests/unit/test_registering_base.py index fddfcb73..7c9fc094 100644 --- a/tests/unit/test_registering_base.py +++ b/tests/unit/test_registering_base.py @@ -3,7 +3,7 @@ import pytest from specklepy.objects.base import Base -from specklepy.objects.structural import Concrete +from specklepy.objects.geometry import Line class Foo(Base): @@ -29,8 +29,8 @@ class Baz(Bar): "Tests.Unit.TestRegisteringBase.Foo:Custom.Bar:Tests.Unit.TestRegisteringBase.Baz", ), ( - Concrete, - "Objects.Structural.Materials.StructuralMaterial:Objects.Structural.Materials.Concrete", + Line, + "Objects.Geometry.Line", ), ], ) @@ -43,7 +43,7 @@ def test_determine_speckle_type(klass: Type[Base], speckle_type: str): [ (Base, "Base"), (Foo, "Tests.Unit.TestRegisteringBase.Foo"), - (Concrete, "Objects.Structural.Materials.Concrete"), + (Line, "Objects.Geometry.Line"), ], ) def test_full_name(klass: Type[Base], fully_qualified_name: str): diff --git a/tests/unit/test_structural.py b/tests/unit/test_structural.py deleted file mode 100644 index 84de472f..00000000 --- a/tests/unit/test_structural.py +++ /dev/null @@ -1,143 +0,0 @@ -import pytest - -from specklepy.objects.geometry import Line, Mesh, Point, Vector -from specklepy.objects.structural.analysis import Model -from specklepy.objects.structural.geometry import ( - Element1D, - Element2D, - ElementType1D, - ElementType2D, - Node, - Restraint, -) -from specklepy.objects.structural.loading import LoadGravity -from specklepy.objects.structural.materials import StructuralMaterial -from specklepy.objects.structural.properties import ( - MemberType, - Property1D, - Property2D, - SectionProfile, - ShapeType, -) - - -@pytest.fixture() -def point(): - return Point(x=1, y=10, z=0) - - -@pytest.fixture() -def vector(): - return Vector(x=0, y=0, z=-1) - - -@pytest.fixture() -def line(point, interval): - return Line( - start=point, - end=point, - domain=interval, - # These attributes are not handled in C# - # bbox=None, - # length=None - ) - - -@pytest.fixture() -def mesh(box): - return Mesh( - vertices=[2, 1, 2, 4, 77.3, 5, 33, 4, 2], - faces=[1, 2, 3, 4, 5, 6, 7], - colors=[111, 222, 333, 444, 555, 666, 777], - bbox=box, - area=233, - volume=232.2, - ) - - -@pytest.fixture() -def restraint(): - return Restraint(code="FFFFFF") - - -@pytest.fixture() -def node(restraint, point): - return Node(basePoint=point, restraint=restraint, name="node1") - - -@pytest.fixture() -def material(): - return StructuralMaterial(name="TestMaterial") - - -@pytest.fixture() -def memberType(): - return MemberType(0) - - -@pytest.fixture() -def shapeType(): - return ShapeType(8) - - -@pytest.fixture() -def sectionProfile(shapeType): - return SectionProfile(name="Test", shapeType=shapeType) - - -@pytest.fixture() -def property1D(memberType, sectionProfile, material): - return Property1D( - Material=material, - SectionProfile=sectionProfile, - memberType=memberType, - ) - - -@pytest.fixture() -def elementType1D(): - return ElementType1D(0) - - -@pytest.fixture() -def element1D(line, restraint, elementType1D, property1D): - return Element1D( - baseLine=line, - end1Releases=restraint, - end2Releases=restraint, - type=elementType1D, - property=property1D, - ) - - -@pytest.fixture() -def property2D(material): - return Property2D(Material=material) - - -@pytest.fixture() -def elementType2D(): - return ElementType2D(0) - - -@pytest.fixture() -def element2D(point, elementType2D): - return Element2D( - topology=[point], - type=elementType2D, - ) - - -@pytest.fixture() -def loadGravity(element1D, element2D, vector): - return LoadGravity(elements=[element1D, element2D], gravityFactors=vector) - - -@pytest.fixture() -def model(loadGravity, element1D, element2D, material, property1D, property2D): - return Model( - loads=[loadGravity], - elements=[element1D, element2D], - materials=[material], - properties=[property1D, property2D], - )