Files
plant2dxf/lib/Elemente/Bt_element.py
T

26 lines
792 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)