From 21249f0a9a5eb9795568783ddf83bc682ee6d88c Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Mon, 2 Dec 2024 15:59:08 +0000 Subject: [PATCH 01/16] remove gis classes, rename collections --- src/specklepy/objects/GIS/CRS.py | 32 ++++-- src/specklepy/objects/GIS/__init__.py | 19 +--- src/specklepy/objects/GIS/geometry.py | 74 ------------- src/specklepy/objects/GIS/layers.py | 147 +++----------------------- src/specklepy/objects/geometry.py | 7 ++ src/specklepy/objects/other.py | 5 +- 6 files changed, 51 insertions(+), 233 deletions(-) delete mode 100644 src/specklepy/objects/GIS/geometry.py diff --git a/src/specklepy/objects/GIS/CRS.py b/src/specklepy/objects/GIS/CRS.py index 2527fe55..08afa179 100644 --- a/src/specklepy/objects/GIS/CRS.py +++ b/src/specklepy/objects/GIS/CRS.py @@ -4,12 +4,26 @@ 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 + """A Coordinate Reference System reconstructable from WKT string""" + + name: str + authority_id: Optional[str] + wkt: str + units_native: Optional[str] + offset_x: Optional[float] + offset_y: Optional[float] + rotation: Optional[float] + + def __init__( + self, + name: str, + authority_id: Optional[str], + wkt: str, + units_native: Optional[str] = None, + offset_x: Optional[float] = None, + offset_y: Optional[float] = None, + rotation: Optional[float] = None, + ) -> None: + super().__init__( + name=name, + ) diff --git a/src/specklepy/objects/GIS/__init__.py b/src/specklepy/objects/GIS/__init__.py index 5ac3dff8..2249efe2 100644 --- a/src/specklepy/objects/GIS/__init__.py +++ b/src/specklepy/objects/GIS/__init__.py @@ -1,24 +1,9 @@ """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 +from specklepy.objects.GIS.layers import GisLayer __all__ = [ - "VectorLayer", - "RasterLayer", - "GisPolygonGeometry", - "PolygonGeometry", - "GisPolygonElement", - "GisLineElement", - "GisPointElement", - "GisRasterElement", + "GisLayer", "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 index 3db33351..a60057e8 100644 --- a/src/specklepy/objects/GIS/layers.py +++ b/src/specklepy/objects/GIS/layers.py @@ -1,142 +1,27 @@ -from typing import Any, Dict, List, Optional, Union +from typing import Optional -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 +class GisLayer( Collection, detachable={"elements"}, - speckle_type="Objects.GIS.VectorLayer", - serialize_ignore={"features"}, + speckle_type="Objects.GIS.GisLayer", ): """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 + # crs: CRS + units: str + type: str - -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 + def __init__( + self, + # crs: str, + units: str, + type: str, + name: Optional[str] = None, + ) -> None: + super().__init__( + name=name, + ) diff --git a/src/specklepy/objects/geometry.py b/src/specklepy/objects/geometry.py index 2aaed6ec..98c9c9de 100644 --- a/src/specklepy/objects/geometry.py +++ b/src/specklepy/objects/geometry.py @@ -431,6 +431,13 @@ def to_list(self) -> List[Any]: ] +class PolygonGeometry(Base, speckle_type="Objects.GIS.PolygonGeometry"): + """GIS Polygon Geometry""" + + boundary: Polyline | Curve | Polycurve | Circle | Ellipse + voids: Optional[List[Polyline]] + + class Extrusion(Base, speckle_type=GEOMETRY + "Extrusion"): capped: Optional[bool] = None profile: Optional[Base] = None diff --git a/src/specklepy/objects/other.py b/src/specklepy/objects/other.py index 5a2576e4..3075540a 100644 --- a/src/specklepy/objects/other.py +++ b/src/specklepy/objects/other.py @@ -304,8 +304,9 @@ class RevitParameter(Base, speckle_type="Objects.BuiltElements.Revit.Parameter") 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 From 3362d094fffc681ed0e0b559b81076cbe8e61271 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Wed, 4 Dec 2024 18:01:35 +0000 Subject: [PATCH 02/16] remove gis classes --- src/specklepy/objects/GIS/CRS.py | 29 --------------------------- src/specklepy/objects/GIS/__init__.py | 9 --------- src/specklepy/objects/GIS/layers.py | 27 ------------------------- src/specklepy/objects/geometry.py | 7 ------- 4 files changed, 72 deletions(-) delete mode 100644 src/specklepy/objects/GIS/CRS.py delete mode 100644 src/specklepy/objects/GIS/__init__.py delete mode 100644 src/specklepy/objects/GIS/layers.py diff --git a/src/specklepy/objects/GIS/CRS.py b/src/specklepy/objects/GIS/CRS.py deleted file mode 100644 index 08afa179..00000000 --- a/src/specklepy/objects/GIS/CRS.py +++ /dev/null @@ -1,29 +0,0 @@ -from typing import Optional - -from specklepy.objects.base import Base - - -class CRS(Base, speckle_type="Objects.GIS.CRS"): - """A Coordinate Reference System reconstructable from WKT string""" - - name: str - authority_id: Optional[str] - wkt: str - units_native: Optional[str] - offset_x: Optional[float] - offset_y: Optional[float] - rotation: Optional[float] - - def __init__( - self, - name: str, - authority_id: Optional[str], - wkt: str, - units_native: Optional[str] = None, - offset_x: Optional[float] = None, - offset_y: Optional[float] = None, - rotation: Optional[float] = None, - ) -> None: - super().__init__( - name=name, - ) diff --git a/src/specklepy/objects/GIS/__init__.py b/src/specklepy/objects/GIS/__init__.py deleted file mode 100644 index 2249efe2..00000000 --- a/src/specklepy/objects/GIS/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Builtin Speckle object kit.""" - -from specklepy.objects.GIS.CRS import CRS -from specklepy.objects.GIS.layers import GisLayer - -__all__ = [ - "GisLayer", - "CRS", -] diff --git a/src/specklepy/objects/GIS/layers.py b/src/specklepy/objects/GIS/layers.py deleted file mode 100644 index a60057e8..00000000 --- a/src/specklepy/objects/GIS/layers.py +++ /dev/null @@ -1,27 +0,0 @@ -from typing import Optional - -from specklepy.objects.GIS.CRS import CRS -from specklepy.objects.other import Collection - - -class GisLayer( - Collection, - detachable={"elements"}, - speckle_type="Objects.GIS.GisLayer", -): - """GIS Vector Layer""" - - # crs: CRS - units: str - type: str - - def __init__( - self, - # crs: str, - units: str, - type: str, - name: Optional[str] = None, - ) -> None: - super().__init__( - name=name, - ) diff --git a/src/specklepy/objects/geometry.py b/src/specklepy/objects/geometry.py index 98c9c9de..2aaed6ec 100644 --- a/src/specklepy/objects/geometry.py +++ b/src/specklepy/objects/geometry.py @@ -431,13 +431,6 @@ def to_list(self) -> List[Any]: ] -class PolygonGeometry(Base, speckle_type="Objects.GIS.PolygonGeometry"): - """GIS Polygon Geometry""" - - boundary: Polyline | Curve | Polycurve | Circle | Ellipse - voids: Optional[List[Polyline]] - - class Extrusion(Base, speckle_type=GEOMETRY + "Extrusion"): capped: Optional[bool] = None profile: Optional[Base] = None From eafa6f223062905f0bdcdf2c7adc36ab51af1093 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Wed, 4 Dec 2024 18:01:56 +0000 Subject: [PATCH 03/16] add ISpeckleObject model --- .../core/api/models/ISpeckleObject.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/specklepy/core/api/models/ISpeckleObject.py diff --git a/src/specklepy/core/api/models/ISpeckleObject.py b/src/specklepy/core/api/models/ISpeckleObject.py new file mode 100644 index 00000000..28cea94f --- /dev/null +++ b/src/specklepy/core/api/models/ISpeckleObject.py @@ -0,0 +1,18 @@ +from abc import ABC, abstractmethod +from typing import Optional + +from specklepy.objects.base import Base + + +class ISpeckleObject(ABC): + @abstractmethod + def __init__( + self, + speckle_type: str, + id: Optional[str] = None, + applicationId: Optional[str] = None, + ): + + self.speckle_type = speckle_type + self.id = id or None + self.applicationId = applicationId or None From edfb5158f43e2aacd4a17282a944483de42962b4 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 15:00:21 +0000 Subject: [PATCH 04/16] add proxies --- src/specklepy/core/api/models/proxies.py | 29 ++++++++++++++++++++++++ src/specklepy/objects/__init__.py | 2 -- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/specklepy/core/api/models/proxies.py diff --git a/src/specklepy/core/api/models/proxies.py b/src/specklepy/core/api/models/proxies.py new file mode 100644 index 00000000..e5d7d310 --- /dev/null +++ b/src/specklepy/core/api/models/proxies.py @@ -0,0 +1,29 @@ +from typing import Optional + +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/__init__.py b/src/specklepy/objects/__init__.py index 85faa492..d38c5bec 100644 --- a/src/specklepy/objects/__init__.py +++ b/src/specklepy/objects/__init__.py @@ -1,7 +1,6 @@ """Builtin Speckle object kit.""" from specklepy.objects import ( - GIS, encoding, geometry, other, @@ -19,5 +18,4 @@ "units", "structural", "primitive", - "GIS", ] From 8e0d47b627194062feaf75333f133edd57350a59 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 15:12:51 +0000 Subject: [PATCH 05/16] add instances --- src/specklepy/core/api/models/__init__.py | 14 +++++++++++ src/specklepy/core/api/models/instances.py | 28 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/specklepy/core/api/models/instances.py diff --git a/src/specklepy/core/api/models/__init__.py b/src/specklepy/core/api/models/__init__.py index 92c72477..d70bf10a 100644 --- a/src/specklepy/core/api/models/__init__.py +++ b/src/specklepy/core/api/models/__init__.py @@ -36,6 +36,16 @@ UserProjectsUpdatedMessage, ) +from specklepy.core.api.models.instances import ( + InstanceProxy, + InstanceDefinitionProxy, +) + +from specklepy.core.api.models.proxies import ( + ColorProxy, + GroupProxy, +) + __all__ = [ "User", "ResourceCollection", @@ -68,4 +78,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 From 3ea301f498d9f776b0cde85436f925641d57fa72 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 15:13:07 +0000 Subject: [PATCH 06/16] remove interface --- .../core/api/models/ISpeckleObject.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/specklepy/core/api/models/ISpeckleObject.py diff --git a/src/specklepy/core/api/models/ISpeckleObject.py b/src/specklepy/core/api/models/ISpeckleObject.py deleted file mode 100644 index 28cea94f..00000000 --- a/src/specklepy/core/api/models/ISpeckleObject.py +++ /dev/null @@ -1,18 +0,0 @@ -from abc import ABC, abstractmethod -from typing import Optional - -from specklepy.objects.base import Base - - -class ISpeckleObject(ABC): - @abstractmethod - def __init__( - self, - speckle_type: str, - id: Optional[str] = None, - applicationId: Optional[str] = None, - ): - - self.speckle_type = speckle_type - self.id = id or None - self.applicationId = applicationId or None From 0a918ae73ab4700dd6ce6386fde5477edb9d78e3 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 15:34:48 +0000 Subject: [PATCH 07/16] formatting --- src/specklepy/core/api/models/__init__.py | 12 ++---------- src/specklepy/objects/__init__.py | 9 +-------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/specklepy/core/api/models/__init__.py b/src/specklepy/core/api/models/__init__.py index d70bf10a..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, @@ -36,16 +38,6 @@ UserProjectsUpdatedMessage, ) -from specklepy.core.api.models.instances import ( - InstanceProxy, - InstanceDefinitionProxy, -) - -from specklepy.core.api.models.proxies import ( - ColorProxy, - GroupProxy, -) - __all__ = [ "User", "ResourceCollection", diff --git a/src/specklepy/objects/__init__.py b/src/specklepy/objects/__init__.py index d38c5bec..0bf41d34 100644 --- a/src/specklepy/objects/__init__.py +++ b/src/specklepy/objects/__init__.py @@ -1,13 +1,6 @@ """Builtin Speckle object kit.""" -from specklepy.objects import ( - encoding, - geometry, - other, - primitive, - structural, - units, -) +from specklepy.objects import encoding, geometry, other, primitive, structural, units from specklepy.objects.base import Base __all__ = [ From 6c154b034fe9ddf68f66e1bf5abfbde9d94d7ce5 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 15:49:06 +0000 Subject: [PATCH 08/16] typo --- src/specklepy/core/api/models/proxies.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/specklepy/core/api/models/proxies.py b/src/specklepy/core/api/models/proxies.py index e5d7d310..d0ac2964 100644 --- a/src/specklepy/core/api/models/proxies.py +++ b/src/specklepy/core/api/models/proxies.py @@ -1,5 +1,3 @@ -from typing import Optional - from specklepy.objects.base import Base From 9358496f49193a479db8b3b0064b56122f066cbc Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 17:05:33 +0000 Subject: [PATCH 09/16] remove structural classes --- src/specklepy/objects/__init__.py | 3 +- src/specklepy/objects/structural/__init__.py | 142 ------------ src/specklepy/objects/structural/analysis.py | 49 ---- src/specklepy/objects/structural/axis.py | 17 -- src/specklepy/objects/structural/geometry.py | 110 --------- src/specklepy/objects/structural/loading.py | 137 ----------- src/specklepy/objects/structural/materials.py | 61 ----- .../objects/structural/properties.py | 212 ------------------ src/specklepy/objects/structural/results.py | 172 -------------- 9 files changed, 1 insertion(+), 902 deletions(-) delete mode 100644 src/specklepy/objects/structural/__init__.py delete mode 100644 src/specklepy/objects/structural/analysis.py delete mode 100644 src/specklepy/objects/structural/axis.py delete mode 100644 src/specklepy/objects/structural/geometry.py delete mode 100644 src/specklepy/objects/structural/loading.py delete mode 100644 src/specklepy/objects/structural/materials.py delete mode 100644 src/specklepy/objects/structural/properties.py delete mode 100644 src/specklepy/objects/structural/results.py diff --git a/src/specklepy/objects/__init__.py b/src/specklepy/objects/__init__.py index 0bf41d34..3305ac2c 100644 --- a/src/specklepy/objects/__init__.py +++ b/src/specklepy/objects/__init__.py @@ -1,6 +1,6 @@ """Builtin Speckle object kit.""" -from specklepy.objects import encoding, geometry, other, primitive, structural, units +from specklepy.objects import encoding, geometry, other, primitive, units from specklepy.objects.base import Base __all__ = [ @@ -9,6 +9,5 @@ "geometry", "other", "units", - "structural", "primitive", ] 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 From 46b56b9bd3f90c8fab32dc9a4c4a336b078b0397 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 20:48:52 +0000 Subject: [PATCH 10/16] remove more objects --- src/specklepy/objects/other.py | 102 +------------------- tests/unit/test_registering_base.py | 8 +- tests/unit/test_structural.py | 143 ---------------------------- 3 files changed, 6 insertions(+), 247 deletions(-) delete mode 100644 tests/unit/test_structural.py diff --git a/src/specklepy/objects/other.py b/src/specklepy/objects/other.py index 3075540a..4580a41f 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,38 +37,6 @@ 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"): - """ - Text object to render it on viewer. - """ - - plane: Plane - value: str - height: float - rotation: float - displayValue: Optional[List[Polyline]] = None - richText: Optional[str] = None - - class Transform( Base, speckle_type=OTHER + "Transform", @@ -253,56 +205,6 @@ 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.Collections.Collection", 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], - ) From f33bbbdbbaf5a6d6a2a69be1aecf447fb5f21d4c Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 20:49:22 +0000 Subject: [PATCH 11/16] add tests --- tests/unit/test_instances.py | 47 ++++++++++++++++++++++++++++++++++++ tests/unit/test_proxies.py | 44 +++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 tests/unit/test_instances.py create mode 100644 tests/unit/test_proxies.py diff --git a/tests/unit/test_instances.py b/tests/unit/test_instances.py new file mode 100644 index 00000000..caeeb431 --- /dev/null +++ b/tests/unit/test_instances.py @@ -0,0 +1,47 @@ +# pylint: disable=redefined-outer-name +import pytest + +from specklepy.core.api.models.instances import InstanceDefinitionProxy, InstanceProxy +from specklepy.core.api.models.proxies import ( + ColorProxy, + GroupProxy, +) + + +@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 create_instance_proxy(): + try: + InstanceProxy() # missing parameters + except AssertionError: + assert True + try: + InstanceProxy(definitionId="", transform="", units="", maxDepth=1) # wrong type + except AssertionError: + assert True + + assert False + + +def create_instance_definition_proxy(): + try: + GroupProxy() # missing parameters + except AssertionError: + assert True + try: + GroupProxy(objects="", maxDepth=1, name="") # wrong type + except AssertionError: + assert True + assert False diff --git a/tests/unit/test_proxies.py b/tests/unit/test_proxies.py new file mode 100644 index 00000000..97a08285 --- /dev/null +++ b/tests/unit/test_proxies.py @@ -0,0 +1,44 @@ +# pylint: disable=redefined-outer-name +import pytest + +from specklepy.core.api.models.proxies import ( + ColorProxy, + GroupProxy, +) + + +@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") + + +def create_color_proxy(): + try: + result = ColorProxy() # missing parameters + except AssertionError: + assert True + try: + result = ColorProxy(objects="", value=2, name="") # wrong type + except AssertionError: + assert True + + assert False + + +def create_group_proxy(): + try: + result = GroupProxy() # missing parameters + except AssertionError: + assert True + try: + result = GroupProxy(objects="", name="") # wrong type + except AssertionError: + assert True + assert False From 7d25b6b1949d1dd772a1a10845ed3fbd1ec96952 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 20:52:19 +0000 Subject: [PATCH 12/16] isort --- tests/unit/test_instances.py | 5 +---- tests/unit/test_proxies.py | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/unit/test_instances.py b/tests/unit/test_instances.py index caeeb431..de9dd817 100644 --- a/tests/unit/test_instances.py +++ b/tests/unit/test_instances.py @@ -2,10 +2,7 @@ import pytest from specklepy.core.api.models.instances import InstanceDefinitionProxy, InstanceProxy -from specklepy.core.api.models.proxies import ( - ColorProxy, - GroupProxy, -) +from specklepy.core.api.models.proxies import ColorProxy, GroupProxy @pytest.fixture() diff --git a/tests/unit/test_proxies.py b/tests/unit/test_proxies.py index 97a08285..790ba383 100644 --- a/tests/unit/test_proxies.py +++ b/tests/unit/test_proxies.py @@ -1,10 +1,7 @@ # pylint: disable=redefined-outer-name import pytest -from specklepy.core.api.models.proxies import ( - ColorProxy, - GroupProxy, -) +from specklepy.core.api.models.proxies import ColorProxy, GroupProxy @pytest.fixture() From 4ff2931eca600dd6f9ea0e30a3086c7362da0125 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 20:54:15 +0000 Subject: [PATCH 13/16] unused var --- tests/unit/test_proxies.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_proxies.py b/tests/unit/test_proxies.py index 790ba383..075676be 100644 --- a/tests/unit/test_proxies.py +++ b/tests/unit/test_proxies.py @@ -18,11 +18,11 @@ def group_proxy(): def create_color_proxy(): try: - result = ColorProxy() # missing parameters + ColorProxy() # missing parameters except AssertionError: assert True try: - result = ColorProxy(objects="", value=2, name="") # wrong type + ColorProxy(objects="", value=2, name="") # wrong type except AssertionError: assert True @@ -31,11 +31,11 @@ def create_color_proxy(): def create_group_proxy(): try: - result = GroupProxy() # missing parameters + GroupProxy() # missing parameters except AssertionError: assert True try: - result = GroupProxy(objects="", name="") # wrong type + GroupProxy(objects="", name="") # wrong type except AssertionError: assert True assert False From 58b04c246acec679649054194d8e5701e4e2cc42 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Thu, 5 Dec 2024 20:56:15 +0000 Subject: [PATCH 14/16] typo --- tests/unit/test_instances.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_instances.py b/tests/unit/test_instances.py index de9dd817..138b5e84 100644 --- a/tests/unit/test_instances.py +++ b/tests/unit/test_instances.py @@ -2,7 +2,6 @@ import pytest from specklepy.core.api.models.instances import InstanceDefinitionProxy, InstanceProxy -from specklepy.core.api.models.proxies import ColorProxy, GroupProxy @pytest.fixture() @@ -34,11 +33,11 @@ def create_instance_proxy(): def create_instance_definition_proxy(): try: - GroupProxy() # missing parameters + InstanceDefinitionProxy() # missing parameters except AssertionError: assert True try: - GroupProxy(objects="", maxDepth=1, name="") # wrong type + InstanceDefinitionProxy(objects="", maxDepth=1, name="") # wrong type except AssertionError: assert True assert False From 71ca5318b6cbe7d174a343ac3ac17b12941d5ca4 Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 6 Dec 2024 03:59:03 +0000 Subject: [PATCH 15/16] fix tests --- tests/unit/test_instances.py | 25 ++++++++++--------------- tests/unit/test_proxies.py | 25 ++++++++++--------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/tests/unit/test_instances.py b/tests/unit/test_instances.py index 138b5e84..7d55ca10 100644 --- a/tests/unit/test_instances.py +++ b/tests/unit/test_instances.py @@ -18,26 +18,21 @@ def instance_definition_proxy(): ) -def create_instance_proxy(): - try: - InstanceProxy() # missing parameters - except AssertionError: - assert True +def test_create_instance_proxy(): try: InstanceProxy(definitionId="", transform="", units="", maxDepth=1) # wrong type - except AssertionError: + assert False + except TypeError: assert True - - assert False + except: + assert False -def create_instance_definition_proxy(): - try: - InstanceDefinitionProxy() # missing parameters - except AssertionError: - assert True +def test_create_instance_definition_proxy(): try: InstanceDefinitionProxy(objects="", maxDepth=1, name="") # wrong type - except AssertionError: + assert False + except TypeError: assert True - assert False + except: + assert False diff --git a/tests/unit/test_proxies.py b/tests/unit/test_proxies.py index 075676be..e27af8ac 100644 --- a/tests/unit/test_proxies.py +++ b/tests/unit/test_proxies.py @@ -16,26 +16,21 @@ def group_proxy(): return GroupProxy(objects=["app_id_1", "app_id_2"], name="group_proxy_name") -def create_color_proxy(): - try: - ColorProxy() # missing parameters - except AssertionError: - assert True +def test_create_color_proxy(): try: ColorProxy(objects="", value=2, name="") # wrong type - except AssertionError: + assert False + except TypeError: assert True - - assert False + except: + assert False -def create_group_proxy(): - try: - GroupProxy() # missing parameters - except AssertionError: - assert True +def test_create_group_proxy(): try: GroupProxy(objects="", name="") # wrong type - except AssertionError: + assert False + except TypeError: assert True - assert False + except: + assert False From 0fcc3053ca00ee478994607782618afa18f9f44e Mon Sep 17 00:00:00 2001 From: KatKatKateryna Date: Fri, 6 Dec 2024 18:41:48 +0000 Subject: [PATCH 16/16] RenderMaterialProxy --- src/specklepy/objects/other.py | 12 ++++++++++++ tests/unit/test_proxies.py | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/specklepy/objects/other.py b/src/specklepy/objects/other.py index 4580a41f..27712a91 100644 --- a/src/specklepy/objects/other.py +++ b/src/specklepy/objects/other.py @@ -37,6 +37,18 @@ class RenderMaterial(Base, speckle_type=OTHER + "RenderMaterial"): emissive: int = -16777216 # black arbg +class RenderMaterialProxy( + Base, + speckle_type="Speckle.Core.Models.Proxies.RenderMaterialProxy", +): + """ + Used to store render material to object relationships in root collections. + """ + + objects: list[str] + value: RenderMaterial + + class Transform( Base, speckle_type=OTHER + "Transform", diff --git a/tests/unit/test_proxies.py b/tests/unit/test_proxies.py index e27af8ac..08224c52 100644 --- a/tests/unit/test_proxies.py +++ b/tests/unit/test_proxies.py @@ -2,6 +2,7 @@ import pytest from specklepy.core.api.models.proxies import ColorProxy, GroupProxy +from specklepy.objects.other import RenderMaterial, RenderMaterialProxy @pytest.fixture() @@ -16,6 +17,18 @@ 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 @@ -34,3 +47,13 @@ def test_create_group_proxy(): 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