alles neu mit black formatiert. handler_context.py impl. um weniger Übergabeparameter zu haben
This commit is contained in:
+54
-45
@@ -1,31 +1,37 @@
|
||||
|
||||
from ezdxf.entities import Line
|
||||
import math
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from typing import Optional
|
||||
import plant2dxf
|
||||
import plant2dxf
|
||||
import block_methoden
|
||||
|
||||
|
||||
class Omniflo(BaseModel):
|
||||
teileid:str
|
||||
x:float
|
||||
y:float
|
||||
sivasnummer:str
|
||||
laenge: Optional [float]
|
||||
teileid: str
|
||||
x: float
|
||||
y: float
|
||||
sivasnummer: str
|
||||
laenge: Optional[float]
|
||||
drehung: float
|
||||
hoehe : Optional[float]
|
||||
h0: Optional[float] = Field(default = 0.0,description="Höhe unten im CSV")
|
||||
h1: Optional[float] = Field(default = 0.0, description="Höhe Oben im CSV")
|
||||
anzahl_scanner: Optional [int] = Field(default=0, description="Anzahl der Scanner")
|
||||
anzahl_stopper: Optional [int] = Field(default=0, description="Anzahl der Separatoren")
|
||||
hoehe: Optional[float]
|
||||
h0: Optional[float] = Field(default=0.0, description="Höhe unten im CSV")
|
||||
h1: Optional[float] = Field(default=0.0, description="Höhe Oben im CSV")
|
||||
anzahl_scanner: Optional[int] = Field(default=0, description="Anzahl der Scanner")
|
||||
anzahl_stopper: Optional[int] = Field(
|
||||
default=0, description="Anzahl der Separatoren"
|
||||
)
|
||||
|
||||
@property
|
||||
def hight_zwischen(self):
|
||||
return ((self.h0 + self.h1) /2)
|
||||
return (self.h0 + self.h1) / 2
|
||||
|
||||
@classmethod
|
||||
def from_merkmale(cls, teileid,x,y, merkmale):
|
||||
def from_merkmale(cls, teileid, x, y, merkmale):
|
||||
sivasnummer = merkmale.get("SivasNummer")
|
||||
try:
|
||||
laenge = float(merkmale.get("Länge in Meter", "0").replace(",", ".")) * 1000 # Meter → mm
|
||||
laenge = (
|
||||
float(merkmale.get("Länge in Meter", "0").replace(",", ".")) * 1000
|
||||
) # Meter → mm
|
||||
except Exception:
|
||||
laenge = 0
|
||||
try:
|
||||
@@ -37,7 +43,7 @@ class Omniflo(BaseModel):
|
||||
except Exception:
|
||||
hoehe = 0.0
|
||||
try:
|
||||
h0 = float(merkmale.get("Höhe unten"))
|
||||
h0 = float(merkmale.get("Höhe unten"))
|
||||
except Exception:
|
||||
h0 = 0.0
|
||||
try:
|
||||
@@ -45,26 +51,27 @@ class Omniflo(BaseModel):
|
||||
except Exception:
|
||||
h1 = 0.0
|
||||
try:
|
||||
anzahl_scanner = float(merkmale.get("Anzahl der Scanner", "0"))
|
||||
anzahl_scanner = float(merkmale.get("Anzahl der Scanner", "0"))
|
||||
except Exception:
|
||||
anzahl_scanner = 0
|
||||
try:
|
||||
anzahl_separatoren = float(merkmale.get("Anzahl der Separatoren", "0"))
|
||||
anzahl_separatoren = float(merkmale.get("Anzahl der Separatoren", "0"))
|
||||
except Exception:
|
||||
anzahl_separatoren = 0
|
||||
return cls(
|
||||
teileid= teileid,
|
||||
teileid=teileid,
|
||||
x=x,
|
||||
y=y,
|
||||
sivasnummer = sivasnummer,
|
||||
laenge = laenge,
|
||||
drehung = winkel,
|
||||
hoehe = hoehe,
|
||||
h0 = h0,
|
||||
h1 = h1,
|
||||
anzahl_scanner = anzahl_scanner,
|
||||
anzahl_stopper = anzahl_separatoren
|
||||
sivasnummer=sivasnummer,
|
||||
laenge=laenge,
|
||||
drehung=winkel,
|
||||
hoehe=hoehe,
|
||||
h0=h0,
|
||||
h1=h1,
|
||||
anzahl_scanner=anzahl_scanner,
|
||||
anzahl_stopper=anzahl_separatoren,
|
||||
)
|
||||
|
||||
def Omniflo_geraden_erstellung(msp, doc, tefsivas, omniflo_objekt):
|
||||
"""Erstellung der Tef gerade und Omniflo gerade"""
|
||||
winkel_rad = math.radians(omniflo_objekt.drehung)
|
||||
@@ -74,21 +81,22 @@ class Omniflo(BaseModel):
|
||||
# Man muss bei sin -1 machen wegen des links koordinaten system
|
||||
dx = halbe_laenge * math.sin(winkel_rad * -1)
|
||||
dy = halbe_laenge * math.cos(winkel_rad)
|
||||
start = (x + dx, y + dy, omniflo_objekt.h1 )
|
||||
ende = (x - dx, y - dy, omniflo_objekt.h0)
|
||||
start = (x + dx, y + dy, omniflo_objekt.h1)
|
||||
ende = (x - dx, y - dy, omniflo_objekt.h0)
|
||||
if "A-2" not in doc.layers:
|
||||
doc.layers.add(name="A-2", color=2)
|
||||
if "F-1" not in doc.layers:
|
||||
doc.layers.add(name="F-1", color =1)
|
||||
linie=msp.add_line(start, ende)
|
||||
doc.layers.add(name="F-1", color=1)
|
||||
linie = msp.add_line(start, ende)
|
||||
if omniflo_objekt.sivasnummer == tefsivas:
|
||||
linie.dxf.layer = "F-1"
|
||||
else:
|
||||
linie.dxf.layer = "A-2"
|
||||
|
||||
def omniflo_foerdererstellung(msp, doc, lib_doc, omniflo_objekt):
|
||||
""""Erstellung des Kettenförderers aktuell nur grundriss"""
|
||||
block_methoden.import_block("bogen1",lib_doc,doc)
|
||||
block_methoden.import_block("bogen2",lib_doc,doc)
|
||||
""" "Erstellung des Kettenförderers aktuell nur grundriss"""
|
||||
block_methoden.import_block("bogen1", lib_doc, doc)
|
||||
block_methoden.import_block("bogen2", lib_doc, doc)
|
||||
x = omniflo_objekt.x
|
||||
y = omniflo_objekt.y
|
||||
rotation = omniflo_objekt.drehung
|
||||
@@ -96,21 +104,22 @@ class Omniflo(BaseModel):
|
||||
h0 = omniflo_objekt.h0
|
||||
h1 = omniflo_objekt.h1
|
||||
h_zwischen = omniflo_objekt.hight_zwischen
|
||||
blockname = (f"OF_Förderer_{laenge}_{h_zwischen}")
|
||||
blockname = f"OF_Förderer_{laenge}_{h_zwischen}"
|
||||
winkel_rad = math.radians(rotation)
|
||||
halbe_laenge = laenge / 2
|
||||
# Man muss bei sin -1 machen wegen des links koordinaten system
|
||||
# Man muss bei sin -1 machen wegen des links koordinaten system
|
||||
dx = halbe_laenge * math.sin(rotation * -1)
|
||||
dy = halbe_laenge * math.cos(rotation)
|
||||
start = (x + dx, y + dy, h1 )
|
||||
ende = (x - dx, y - dy, h0)
|
||||
start = (x + dx, y + dy, h1)
|
||||
ende = (x - dx, y - dy, h0)
|
||||
if blockname not in doc.blocks:
|
||||
block = doc.blocks.new(blockname, base_point=(0,0,0))
|
||||
block.add_blockref("bogen1",start)
|
||||
block.add_blockref("bogen2",ende)
|
||||
line = Line.new(dxfattribs={"start": start,"end":ende})
|
||||
block = doc.blocks.new(blockname, base_point=(0, 0, 0))
|
||||
block.add_blockref("bogen1", start)
|
||||
block.add_blockref("bogen2", ende)
|
||||
line = Line.new(dxfattribs={"start": start, "end": ende})
|
||||
copy = line.copy()
|
||||
copy.translate(-x,-y,-h_zwischen)
|
||||
copy.translate(-x, -y, -h_zwischen)
|
||||
block.add_entity(copy)
|
||||
msp.add_blockref(blockname,(x,y,h_zwischen),dxfattribs={"rotation": rotation})
|
||||
|
||||
msp.add_blockref(
|
||||
blockname, (x, y, h_zwischen), dxfattribs={"rotation": rotation}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user