27 lines
863 B
Python
27 lines
863 B
Python
from pydantic import BaseModel, Field, field_validator
|
|
from typing import Optional
|
|
|
|
class Bt_element(BaseModel):
|
|
"""Das sind beide BTMT Elemente"""
|
|
teileid: str
|
|
drehung: Optional [float] = Field(default=0.0,description="Rotation des Elements")
|
|
hoehe: Optional [float] = Field(default=0.0,description="Hoehe des Elements")
|
|
|
|
@classmethod
|
|
def from_merkmale(cls, teileid: str, x: float, y: float, merkmale: dict) -> 'Bt_element':
|
|
try:
|
|
hoehe = float(merkmale.get("Höhe in Meter"))
|
|
except Exception as e:
|
|
hoehe = 0.0
|
|
try:
|
|
drehung = float(merkmale.get("Drehung"))
|
|
except Exception as e:
|
|
drehung = 0.0
|
|
|
|
return cls(
|
|
teileid = teileid,
|
|
x = x,
|
|
y = y,
|
|
hoehe = hoehe,
|
|
drehung = drehung
|
|
) |