Compare commits

..

13 Commits

Author SHA1 Message Date
Jedd Morgan b19b85c9d1 Merge pull request #263 from specklesystems/jrm/instances
Updated instances to match sharp 2.13 changes
2023-03-21 13:12:50 +00:00
Jedd Morgan db4b2b7f87 Removed new collections class as we are not ready 2023-03-20 15:16:03 +00:00
Jedd Morgan 77916995bc Updated instances to match sharp 2.13 changes 2023-03-19 03:11:10 +00:00
Gergő Jedlicska 3dd56dc38e Merge pull request #260 from specklesystems/gergo/forward_ref_type
gergo/forward ref type
2023-02-15 20:48:55 +01:00
Gergő Jedlicska ae42bec1c3 style(formatting): rerun formatting 2023-02-15 19:21:48 +01:00
Gergő Jedlicska ea7baf8eb5 fix(type_checking): make sure forwardrefs blank pass type checking 2023-02-15 19:20:45 +01:00
Gergő Jedlicska 8352bb5c9a Merge pull request #257 from Knuttatutta/knuttatutta/add_axis_type
Fix: Add AxisType and fix its type in Axis
2023-02-01 15:27:34 +02:00
Gergő Jedlicska fc34b876fd Merge branch 'main' into knuttatutta/add_axis_type 2023-02-01 15:26:10 +02:00
Gergő Jedlicska 183993cfc5 Merge pull request #254 from RobClaessensRHDHV/feature/revit_analytical_to_specklepy_structural_fixes
Fix: Interoperability from Revit analytical to specklepy structural
2023-02-01 15:24:45 +02:00
Knuttatutta 9be3b4b93d Added AxisType in module init 2023-02-01 10:34:01 +01:00
Knuttatutta 0b14660115 Add AxisType, fix type in Axis 2023-02-01 10:16:13 +01:00
908599 68c4c682a0 Revert incorrect type hint change 2023-01-17 10:46:31 +01:00
908599 4f93ddcaf3 Update speckle_type of SectionProfile to match C#, update type hints with C# Enum values to int.
For the SectionProfile, a separate static variable e.g. STRUCTURAL_PROFILE could be created later, I now just made an easy fix.
For the enumeration attributes, I believe they should be integer, as e.g. Revit pushes them as integers, not strings.
2023-01-16 16:01:33 +01:00
6 changed files with 61 additions and 11 deletions
+4
View File
@@ -5,6 +5,7 @@ from typing import (
Any,
ClassVar,
Dict,
ForwardRef,
List,
Optional,
Set,
@@ -217,6 +218,9 @@ def _validate_type(t: Optional[type], value: Any) -> Tuple[bool, Any]:
return True, t(value)
if getattr(t, "__module__", None) == "typing":
if isinstance(t, ForwardRef):
return True, value
origin = getattr(t, "__origin__")
# below is what in nicer for >= py38
# origin = get_origin(t)
+42 -8
View File
@@ -1,10 +1,12 @@
from typing import Any, List, Optional
from deprecated import deprecated
from specklepy.objects.geometry import Point, Vector
from .base import Base
OTHER = "Objects.Other."
OTHER_REVIT = OTHER + "Revit."
IDENTITY_TRANSFORM = [
1.0,
@@ -72,7 +74,7 @@ class DisplayStyle(Base, speckle_type=OTHER + "DisplayStyle"):
class Transform(
Base,
speckle_type=OTHER + "Transform",
serialize_ignore={"translation", "scaling", "is_identity"},
serialize_ignore={"translation", "scaling", "is_identity", "value"},
):
"""The 4x4 transformation matrix
@@ -84,12 +86,21 @@ class Transform(
_value: Optional[List[float]] = None
@property
@deprecated(version="2.12", reason="Use matrix")
def value(self) -> List[float]:
"""The transform matrix represented as a flat list of 16 floats"""
return self._value
@value.setter
def value(self, value: List[float]) -> None:
self.matrix = value
@property
def matrix(self) -> List[float]:
"""The transform matrix represented as a flat list of 16 floats"""
return self._value
@matrix.setter
def matrix(self, value: List[float]) -> None:
try:
value = [float(x) for x in value]
except (ValueError, TypeError) as error:
@@ -118,7 +129,7 @@ class Transform(
@property
def is_identity(self) -> bool:
return self.value == IDENTITY_TRANSFORM
return self._value == IDENTITY_TRANSFORM
def apply_to_point(self, point: Point) -> Point:
"""Transform a single speckle Point
@@ -236,15 +247,38 @@ class BlockDefinition(
geometry: Optional[List[Base]] = None
class BlockInstance(
Base, speckle_type=OTHER + "BlockInstance", detachable={"blockDefinition"}
class Instance(
Base, speckle_type=OTHER + "Instance", detachable={"definition"}
):
blockDefinition: Optional[BlockDefinition] = None
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"):
class RevitParameter(
Base, speckle_type="Objects.BuiltElements.Revit.Parameter"
):
name: Optional[str] = None
value: Any = None
applicationUnitType: Optional[str] = None # eg UnitType UT_Length
@@ -254,4 +288,4 @@ class RevitParameter(Base, speckle_type="Objects.BuiltElements.Revit.Parameter")
] = None # BuiltInParameterName or GUID for shared parameter
isShared: bool = False
isReadOnly: bool = False
isTypeParameter: bool = False
isTypeParameter: bool = False
+5 -1
View File
@@ -6,7 +6,10 @@ from specklepy.objects.structural.analysis import (
ModelSettings,
ModelUnits,
)
from specklepy.objects.structural.axis import Axis
from specklepy.objects.structural.axis import (
AxisType,
Axis
)
from specklepy.objects.structural.geometry import (
Element1D,
Element2D,
@@ -82,6 +85,7 @@ __all__ = [
"ElementType1D",
"ElementType2D",
"ElementType3D",
"AxisType",
"Axis",
"Node",
"Restraint",
+8 -1
View File
@@ -1,10 +1,17 @@
from typing import Optional
from enum import Enum
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[str] = None
axisType: Optional[AxisType] = None
plane: Optional[Plane] = None
@@ -90,7 +90,7 @@ class Property(Base, speckle_type=STRUCTURAL_PROPERTY):
name: Optional[str] = None
class SectionProfile(Base, speckle_type=STRUCTURAL_PROPERTY + ".SectionProfile"):
class SectionProfile(Base, speckle_type=STRUCTURAL_PROPERTY + ".Profiles.SectionProfile"):
name: Optional[str] = None
shapeType: Optional[ShapeType] = None
area: float = 0.0
+1
View File
@@ -106,6 +106,7 @@ fake_bases = [FakeBase("foo"), FakeBase("bar")]
True,
fake_bases,
),
(List["int"], [2, 3, 4], True, [2, 3, 4]),
],
)
def test_validate_type(