alles neu mit black formatiert. handler_context.py impl. um weniger Übergabeparameter zu haben
This commit is contained in:
+30
-24
@@ -1,15 +1,22 @@
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from typing import Optional
|
||||
import block_methoden
|
||||
|
||||
RADIUS = 400
|
||||
|
||||
|
||||
class Eckrad(BaseModel):
|
||||
teileid: str
|
||||
drehung: Optional [float] = Field(default=0.0,description="Rotation des Elements")
|
||||
hoehe: Optional [float] = Field(default=0.0,description="Hoehe des Elements")
|
||||
drehrichtung: Optional [str] =Field(default=None,description="Richtung des Eckrads")
|
||||
drehung: Optional[float] = Field(default=0.0, description="Rotation des Elements")
|
||||
hoehe: Optional[float] = Field(default=0.0, description="Hoehe des Elements")
|
||||
drehrichtung: Optional[str] = Field(
|
||||
default=None, description="Richtung des Eckrads"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def from_merkmale(cls, teileid: str, x: float, y: float, merkmale: dict) -> 'Eckrad':
|
||||
def from_merkmale(
|
||||
cls, teileid: str, x: float, y: float, merkmale: dict
|
||||
) -> "Eckrad":
|
||||
try:
|
||||
hoehe = float(merkmale.get("Höhe in Meter")) * 1000
|
||||
except Exception as e:
|
||||
@@ -22,27 +29,26 @@ class Eckrad(BaseModel):
|
||||
drehrichtung = merkmale.get("Drehrichtung")
|
||||
except Exception as e:
|
||||
drehrichtung = None
|
||||
return cls(
|
||||
teileid = teileid,
|
||||
x = x,
|
||||
y = y,
|
||||
hoehe = hoehe,
|
||||
drehrichtung = drehrichtung
|
||||
)
|
||||
return cls(teileid=teileid, x=x, y=y, hoehe=hoehe, drehrichtung=drehrichtung)
|
||||
|
||||
def erstellung_eckrad_richtung(merkmale, doc, lib_doc):
|
||||
block_methoden.import_block("AN8",lib_doc,doc)
|
||||
block_methoden.import_block("Richtungspfeil",lib_doc,doc)
|
||||
block_methoden.import_block("AN8", lib_doc, doc)
|
||||
block_methoden.import_block("Richtungspfeil", lib_doc, doc)
|
||||
eckrad_rechts = "eckrad_UZS"
|
||||
eckrad_links = "eckrad_GUZS"
|
||||
hight = float(merkmale.get("Höhe in m")) * 1000
|
||||
# Erstellung der Richtungung Blöcke der Eckrads
|
||||
if eckrad_rechts not in doc.blocks:
|
||||
block_rechts = doc.blocks.new(name= eckrad_rechts,base_point=(0,0,0))
|
||||
block_links = doc.blocks.new(name= eckrad_links,base_point=(0,0,0))
|
||||
block_rechts.add_blockref("AN8",(0,0,0))
|
||||
block_links.add_blockref("AN8",(0,0,0))
|
||||
block_rechts.add_blockref("Richtungspfeil",(0+200,0+ RADIUS,0))
|
||||
block_rechts.add_blockref("Richtungspfeil",(0-200,0- RADIUS,0),dxfattribs={"rotation": 180})
|
||||
block_links.add_blockref("Richtungspfeil",(0+200,0- RADIUS,0))
|
||||
block_links.add_blockref("Richtungspfeil",(0-200,0+ RADIUS,0),dxfattribs={"rotation": 180})
|
||||
return eckrad_rechts,eckrad_links,hight
|
||||
# Erstellung der Richtungung Blöcke der Eckrads
|
||||
if eckrad_rechts not in doc.blocks:
|
||||
block_rechts = doc.blocks.new(name=eckrad_rechts, base_point=(0, 0, 0))
|
||||
block_links = doc.blocks.new(name=eckrad_links, base_point=(0, 0, 0))
|
||||
block_rechts.add_blockref("AN8", (0, 0, 0))
|
||||
block_links.add_blockref("AN8", (0, 0, 0))
|
||||
block_rechts.add_blockref("Richtungspfeil", (0 + 200, 0 + RADIUS, 0))
|
||||
block_rechts.add_blockref(
|
||||
"Richtungspfeil", (0 - 200, 0 - RADIUS, 0), dxfattribs={"rotation": 180}
|
||||
)
|
||||
block_links.add_blockref("Richtungspfeil", (0 + 200, 0 - RADIUS, 0))
|
||||
block_links.add_blockref(
|
||||
"Richtungspfeil", (0 - 200, 0 + RADIUS, 0), dxfattribs={"rotation": 180}
|
||||
)
|
||||
return eckrad_rechts, eckrad_links, hight
|
||||
|
||||
Reference in New Issue
Block a user