alles neu mit black formatiert. handler_context.py impl. um weniger Übergabeparameter zu haben
This commit is contained in:
@@ -1,29 +1,35 @@
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
|
||||
class Angetriebene_Kurve(BaseModel):
|
||||
teileid: str
|
||||
x: float
|
||||
y:float
|
||||
drehung: float = Field(default=0.0,description="Rotation der Kurve")
|
||||
hoehe0: float = Field(default=0.0,description="Hoehe Anfang der Kurve")
|
||||
hoehe1: float = Field(default=0.0,description="Hoehe Ende der Kurve")
|
||||
y: float
|
||||
drehung: float = Field(default=0.0, description="Rotation der Kurve")
|
||||
hoehe0: float = Field(default=0.0, description="Hoehe Anfang der Kurve")
|
||||
hoehe1: float = Field(default=0.0, description="Hoehe Ende der Kurve")
|
||||
kurvenrichtung: str = Field(description="Kurvenrichtung der Kurve")
|
||||
antriebNebenStrecke: str =Field(description="wo die Angetriebene Strecke ist abhängig von der kurvenrichtung")
|
||||
antriebNebenStrecke: str = Field(
|
||||
description="wo die Angetriebene Strecke ist abhängig von der kurvenrichtung"
|
||||
)
|
||||
winkel: int = Field(description="Der Winkel der Kurve")
|
||||
|
||||
|
||||
@property
|
||||
def antrieb(self):
|
||||
if self.antriebNebenStrecke == "Aussen":
|
||||
self.antriebNebenStrecke = "außen"
|
||||
elif self.antriebNebenStrecke == "Innen":
|
||||
elif self.antriebNebenStrecke == "Innen":
|
||||
self.antriebNebenStrecke = "innen"
|
||||
return self.antriebNebenStrecke
|
||||
|
||||
@property
|
||||
def hight_zwischen(self):
|
||||
return ((self.hoehe0 + self.hoehe1) /2)
|
||||
return (self.hoehe0 + self.hoehe1) / 2
|
||||
|
||||
@classmethod
|
||||
def from_merkmale(cls, teileid: str, x: float, y: float, merkmale: dict) -> 'Angetriebene_Kurve':
|
||||
def from_merkmale(
|
||||
cls, teileid: str, x: float, y: float, merkmale: dict
|
||||
) -> "Angetriebene_Kurve":
|
||||
hoehe0 = float(merkmale.get("Höhe Anfang")) * 1000
|
||||
hoehe1 = float(merkmale.get("Höhe Ende")) * 1000
|
||||
winkel = int(merkmale.get("Kurvenwinkel"))
|
||||
@@ -33,16 +39,15 @@ class Angetriebene_Kurve(BaseModel):
|
||||
drehung = float(merkmale.get("Drehung"))
|
||||
except Exception as e:
|
||||
drehung = 0.0
|
||||
|
||||
return cls(
|
||||
teileid = teileid,
|
||||
x = x,
|
||||
y = y,
|
||||
drehung = drehung,
|
||||
hoehe0 = hoehe0,
|
||||
hoehe1 = hoehe1,
|
||||
kurvenrichtung = kurvenrichtung,
|
||||
antriebNebenStrecke = antriebNebenstrecke,
|
||||
winkel = winkel
|
||||
|
||||
)
|
||||
return cls(
|
||||
teileid=teileid,
|
||||
x=x,
|
||||
y=y,
|
||||
drehung=drehung,
|
||||
hoehe0=hoehe0,
|
||||
hoehe1=hoehe1,
|
||||
kurvenrichtung=kurvenrichtung,
|
||||
antriebNebenStrecke=antriebNebenstrecke,
|
||||
winkel=winkel,
|
||||
)
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
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")
|
||||
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':
|
||||
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:
|
||||
@@ -17,11 +21,5 @@ class Bt_element(BaseModel):
|
||||
drehung = float(merkmale.get("Drehung"))
|
||||
except Exception as e:
|
||||
drehung = 0.0
|
||||
|
||||
return cls(
|
||||
teileid = teileid,
|
||||
x = x,
|
||||
y = y,
|
||||
hoehe = hoehe,
|
||||
drehung = drehung
|
||||
)
|
||||
|
||||
return cls(teileid=teileid, x=x, y=y, hoehe=hoehe, drehung=drehung)
|
||||
|
||||
+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
|
||||
|
||||
@@ -38,11 +38,11 @@ class Gefaellestrecke(BaseModel):
|
||||
anzahl_scanner = int(merkmale.get("Anzahl der Scanner")),
|
||||
anzahl_separatoren = int(merkmale.get("Anzahl der Separatoren"))
|
||||
)
|
||||
def erstehlung_von_gefalle_ohne_aussnahmen(msp, x, y, upper_hoehe_gefaehlle, lower_hoehe_gefaehlle, halbe_laenge, winkel):
|
||||
def erstehlung_von_gefalle_ohne_aussnahmen(msp, x, y, upper_hoehe_gefaelle, lower_hoehe_gefaelle, halbe_laenge, winkel):
|
||||
dx = halbe_laenge *math.sin(winkel * -1)
|
||||
dy = halbe_laenge * math.cos(winkel)
|
||||
start = x +dx, y + dy,upper_hoehe_gefaehlle
|
||||
ende = x -dx, y - dy,lower_hoehe_gefaehlle
|
||||
start = x +dx, y + dy,upper_hoehe_gefaelle
|
||||
ende = x -dx, y - dy,lower_hoehe_gefaelle
|
||||
line =msp.add_line(start,ende)
|
||||
line.dxf.layer = "6-SP"
|
||||
def rotation_mit_zwei_verbunden(gefaellestrecke_nachbarn,richtung2, richtung0, am_kreisel, kreisel_verbunden, hight_position):
|
||||
@@ -137,7 +137,7 @@ class Gefaellestrecke(BaseModel):
|
||||
elif gefaelle == "rechts" :
|
||||
rotation = 270
|
||||
return rotation,drehung0,drehung1,hight_position
|
||||
def ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaehlle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade):
|
||||
def ein_motor_oder_eine_umlenk(x, y,start,ende, doc, lib_doc, hoehe_gefaelle, block_Vario_Umlenkstation_500mm, block_Vario_Motorstation_500mm, blockname_motor_links, blockname_umlenk_links, hat_motor_0, hat_umlenk_0, tefkurve_0, block,umlenk_gerade,motor_gerade):
|
||||
|
||||
block_Vario_Bogen_auf = (f"Vario_Bogen_auf_3°")
|
||||
block_Vario_Bogen_ab = (f"Vario_Bogen_ab_3°")
|
||||
@@ -165,48 +165,48 @@ class Gefaellestrecke(BaseModel):
|
||||
if hat_motor_0 == True:
|
||||
if tefkurve_0 == "links":
|
||||
if motor_gerade == False:
|
||||
block.add_blockref(block_Vario_Bogen_ab_links,(start[0]-x,start[1]-Vario_Bogen_ab_Delta_SP_0[0]-y,start[2]- Vario_Bogen_ab_Delta_SP_0[2]-hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref(block_Vario_Bogen_ab_links,(start[0]-x,start[1]-Vario_Bogen_ab_Delta_SP_0[0]-y,start[2]- Vario_Bogen_ab_Delta_SP_0[2]-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start = [start[0],start[1]-Vario_Bogen_ab_Delta_SP_0[0]- Vario_Bogen_ab_Delta_SP_1[0],start[2]-Vario_Bogen_ab_Delta_SP_0[2]- Vario_Bogen_ab_Delta_SP_1[2]]
|
||||
block.add_blockref(blockname_motor_links, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref(blockname_motor_links, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start[1]= start[1] - 500* math.cos(math.radians(3))
|
||||
start[2] = start[2] - 500* math.sin(math.radians(3))
|
||||
else:
|
||||
block.add_blockref("Vario_Motorstation_500mm_links", (start[0]-x,start[1] -250 -y,start[2] -hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref("Vario_Motorstation_500mm_links", (start[0]-x,start[1] -250 -y,start[2] -hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start[1]= start[1] - 500
|
||||
|
||||
else:
|
||||
if motor_gerade == False:
|
||||
block.add_blockref(block_Vario_Bogen_ab,(start[0]-x,start[1]-Vario_Bogen_ab_Delta_SP_0[0]-y,start[2]- Vario_Bogen_ab_Delta_SP_0[2]-hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref(block_Vario_Bogen_ab,(start[0]-x,start[1]-Vario_Bogen_ab_Delta_SP_0[0]-y,start[2]- Vario_Bogen_ab_Delta_SP_0[2]-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start = [start[0],start[1]-Vario_Bogen_ab_Delta_SP_0[0]- Vario_Bogen_ab_Delta_SP_1[0],start[2]-Vario_Bogen_ab_Delta_SP_0[2]- Vario_Bogen_ab_Delta_SP_1[2]]
|
||||
block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref(block_Vario_Motorstation_500mm, (start[0]-x,start[1] - 250* math.cos(math.radians(3))-y,start[2] - 250* math.sin(math.radians(3))-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start[1]= start[1] - 500* math.cos(math.radians(3))
|
||||
start[2] = start[2] - 500* math.sin(math.radians(3))
|
||||
else:
|
||||
block.add_blockref("Vario_Motorstation_500mm", (start[0]-x,start[1]- 250 -y,start[2] -hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref("Vario_Motorstation_500mm", (start[0]-x,start[1]- 250 -y,start[2] -hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
start[1]= start[1] - 500
|
||||
|
||||
if hat_umlenk_0 == True:
|
||||
if tefkurve_0 == "links":
|
||||
if umlenk_gerade == False:
|
||||
block.add_blockref(block_Vario_Bogen_auf,(ende[0]-x,ende[1]+Vario_Bogen_auf_Delta_SP_0[0]-y,ende[2] + Vario_Bogen_auf_Delta_SP_0[2]-hoehe_gefaehlle),dxfattribs={"rotation": 90})
|
||||
block.add_blockref(block_Vario_Bogen_auf,(ende[0]-x,ende[1]+Vario_Bogen_auf_Delta_SP_0[0]-y,ende[2] + Vario_Bogen_auf_Delta_SP_0[2]-hoehe_gefaelle),dxfattribs={"rotation": 90})
|
||||
ende = [ende[0],ende[1]+ Vario_Bogen_auf_Delta_SP_0[0]+ Vario_Bogen_auf_Delta_SP_1[0],ende[2]+Vario_Bogen_auf_Delta_SP_0[2]+ Vario_Bogen_auf_Delta_SP_1[2]]
|
||||
block.add_blockref(blockname_umlenk_links, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref(blockname_umlenk_links, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
|
||||
ende [1]= ende[1] + 500* math.cos(math.radians(3))
|
||||
ende[2] = ende[2] + 500* math.sin(math.radians(3))
|
||||
else:
|
||||
block.add_blockref("Vario_Umlenkstation_500mm_links", (ende[0]-x,ende[1] + 250-y,ende[2] -hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref("Vario_Umlenkstation_500mm_links", (ende[0]-x,ende[1] + 250-y,ende[2] -hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
ende [1]= ende[1] + 500
|
||||
|
||||
else:
|
||||
if umlenk_gerade == False:
|
||||
block.add_blockref(block_Vario_Bogen_auf_links,(ende[0]-x,ende[1]+Vario_Bogen_auf_Delta_SP_0[0]-y,ende[2] + Vario_Bogen_auf_Delta_SP_0[2]-hoehe_gefaehlle),dxfattribs={"rotation": 90})
|
||||
block.add_blockref(block_Vario_Bogen_auf_links,(ende[0]-x,ende[1]+Vario_Bogen_auf_Delta_SP_0[0]-y,ende[2] + Vario_Bogen_auf_Delta_SP_0[2]-hoehe_gefaelle),dxfattribs={"rotation": 90})
|
||||
ende = [ende[0],ende[1]+ Vario_Bogen_auf_Delta_SP_0[0]+ Vario_Bogen_auf_Delta_SP_1[0],ende[2]+Vario_Bogen_auf_Delta_SP_0[2]+ Vario_Bogen_auf_Delta_SP_1[2]]
|
||||
block.add_blockref(block_Vario_Umlenkstation_500mm, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref(block_Vario_Umlenkstation_500mm, (ende[0]-x,ende[1] + 250* math.cos(math.radians(3))-y,ende[2] + 250* math.sin(math.radians(3))-hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
ende [1]= ende[1] + 500* math.cos(math.radians(3))
|
||||
ende[2] = ende[2] + 500* math.sin(math.radians(3))
|
||||
else:
|
||||
block.add_blockref("Vario_Umlenkstation_500mm", (ende[0]-x,ende[1] + 250-y,ende[2] -hoehe_gefaehlle),dxfattribs={"rotation": 270})
|
||||
block.add_blockref("Vario_Umlenkstation_500mm", (ende[0]-x,ende[1] + 250-y,ende[2] -hoehe_gefaelle),dxfattribs={"rotation": 270})
|
||||
ende [1]= ende[1] + 500
|
||||
return start,ende
|
||||
def hat_motor_umlenk_station (gefaelle_objekt, gefaellestrecke_nachbarn):
|
||||
@@ -218,8 +218,8 @@ class Gefaellestrecke(BaseModel):
|
||||
tefkurve_1 = None
|
||||
umlenk_gerade = False
|
||||
motor_gerade = False
|
||||
upper_hoehe_gefaehlle = gefaelle_objekt.h1
|
||||
lower_hoehe_gefaehlle = gefaelle_objekt.h0
|
||||
upper_hoehe_gefaelle = gefaelle_objekt.h1
|
||||
lower_hoehe_gefaelle = gefaelle_objekt.h0
|
||||
rotation = gefaelle_objekt.drehung
|
||||
x = gefaelle_objekt.x
|
||||
y = gefaelle_objekt.y
|
||||
@@ -238,13 +238,13 @@ class Gefaellestrecke(BaseModel):
|
||||
else:
|
||||
tefkurve_0 = "links"
|
||||
|
||||
if upper_hoehe_gefaehlle > lower_hoehe_gefaehlle:
|
||||
if vario_hoehe_0 == upper_hoehe_gefaehlle or vario_hoehe_1 == upper_hoehe_gefaehlle:
|
||||
if upper_hoehe_gefaelle > lower_hoehe_gefaelle:
|
||||
if vario_hoehe_0 == upper_hoehe_gefaelle or vario_hoehe_1 == upper_hoehe_gefaelle:
|
||||
hat_motor_0 = True
|
||||
else:
|
||||
hat_umlenk_0 = True
|
||||
elif upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
|
||||
if vario_hoehe_0 == lower_hoehe_gefaehlle or vario_hoehe_1 == lower_hoehe_gefaehlle:
|
||||
elif upper_hoehe_gefaelle < lower_hoehe_gefaelle:
|
||||
if vario_hoehe_0 == lower_hoehe_gefaelle or vario_hoehe_1 == lower_hoehe_gefaelle:
|
||||
hat_motor_0 = True
|
||||
else:
|
||||
hat_umlenk_0 = True
|
||||
@@ -270,13 +270,13 @@ class Gefaellestrecke(BaseModel):
|
||||
tefkurve_1 = "rechts"
|
||||
else:
|
||||
tefkurve_1 = "links"
|
||||
if upper_hoehe_gefaehlle > lower_hoehe_gefaehlle:
|
||||
if vario_hoehe_0_1 == upper_hoehe_gefaehlle or vario_hoehe_1_1 == upper_hoehe_gefaehlle:
|
||||
if upper_hoehe_gefaelle > lower_hoehe_gefaelle:
|
||||
if vario_hoehe_0_1 == upper_hoehe_gefaelle or vario_hoehe_1_1 == upper_hoehe_gefaelle:
|
||||
hat_motor_1 = True
|
||||
else:
|
||||
hat_umlenk_1 = True
|
||||
elif upper_hoehe_gefaehlle < lower_hoehe_gefaehlle:
|
||||
if vario_hoehe_0_1 == lower_hoehe_gefaehlle or vario_hoehe_1_1 == lower_hoehe_gefaehlle:
|
||||
elif upper_hoehe_gefaelle < lower_hoehe_gefaelle:
|
||||
if vario_hoehe_0_1 == lower_hoehe_gefaelle or vario_hoehe_1_1 == lower_hoehe_gefaelle:
|
||||
hat_motor_1 = True
|
||||
else:
|
||||
hat_umlenk_1 = True
|
||||
|
||||
+111
-62
@@ -1,29 +1,36 @@
|
||||
|
||||
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
|
||||
|
||||
|
||||
ATTR_TAG = "TeileId" # Attributtag im Block
|
||||
RADIUS = 400 # Radius der Kreiselkreise (mm)
|
||||
ATTR_TAG = "TeileId" # Attributtag im Block
|
||||
RADIUS = 400 # Radius der Kreiselkreise (mm)
|
||||
|
||||
|
||||
class Kreisel(BaseModel):
|
||||
"""Pydantic-Modell für Kreisel-Komponenten."""
|
||||
|
||||
teileid: str
|
||||
x: float = Field(description="X-Koordinate des Kreisel-Zentrums")
|
||||
y: float = Field(description="Y-Koordinate des Kreisel-Zentrums")
|
||||
hoehe: float = Field(description="Höhe in mm")
|
||||
drehung: float = Field(default=0.0, description="Drehung/Winkel in Grad")
|
||||
drehrichtung: Optional[str] = Field(default=None, description="Drehrichtung: UZS oder GUZS")
|
||||
abstand: float = Field(default=20000.0, description="Abstand zwischen Kreiselachsen in mm")
|
||||
kreiselart: Optional[str] = Field(default=None, description="Kreiselart, z.B. 'Pin'")
|
||||
drehrichtung: Optional[str] = Field(
|
||||
default=None, description="Drehrichtung: UZS oder GUZS"
|
||||
)
|
||||
abstand: float = Field(
|
||||
default=20000.0, description="Abstand zwischen Kreiselachsen in mm"
|
||||
)
|
||||
kreiselart: Optional[str] = Field(
|
||||
default=None, description="Kreiselart, z.B. 'Pin'"
|
||||
)
|
||||
anzahl_scanner: float = Field(default=0.0, description="Anzahl der Scanner")
|
||||
anzahl_separatoren: float = Field(default=0.0, description="Anzahl der Separatoren")
|
||||
|
||||
@field_validator('abstand')
|
||||
|
||||
@field_validator("abstand")
|
||||
@classmethod
|
||||
def validate_abstand(cls, v):
|
||||
"""Konvertiert Abstand von Meter zu mm, falls nötig."""
|
||||
@@ -34,8 +41,8 @@ class Kreisel(BaseModel):
|
||||
except ValueError:
|
||||
v = 10000.0 # Fallback 10 m
|
||||
return v
|
||||
|
||||
@field_validator('hoehe')
|
||||
|
||||
@field_validator("hoehe")
|
||||
@classmethod
|
||||
def validate_hoehe(cls, v):
|
||||
"""Konvertiert Höhe von Meter zu mm, falls nötig."""
|
||||
@@ -46,12 +53,12 @@ class Kreisel(BaseModel):
|
||||
except ValueError:
|
||||
v = 0.0
|
||||
return v
|
||||
|
||||
|
||||
@property
|
||||
def halbabstand(self) -> float:
|
||||
"""Halbabstand zwischen den beiden Blöcken."""
|
||||
return self.abstand / 2
|
||||
|
||||
|
||||
@property
|
||||
def winkel_rad(self) -> float:
|
||||
"""Winkel in Radianten für Berechnungen."""
|
||||
@@ -59,62 +66,66 @@ class Kreisel(BaseModel):
|
||||
return math.radians(self.drehung)
|
||||
else:
|
||||
return math.radians(self.drehung - 180)
|
||||
|
||||
|
||||
@property
|
||||
def richtung_rad(self) -> float:
|
||||
"""Richtung in Radianten (für am_kreisel_direct_verbunden)."""
|
||||
# Wird aus drehung abgeleitet oder separat gesetzt
|
||||
return math.radians(self.drehung)
|
||||
|
||||
|
||||
@property
|
||||
def pos1(self) -> tuple[float, float, float]:
|
||||
"""Position des ersten Blocks (x, y, z)."""
|
||||
dx = self.halbabstand * math.cos(self.winkel_rad)
|
||||
dy = self.halbabstand * math.sin(self.winkel_rad)
|
||||
return (self.x - dx, self.y - dy, self.hoehe)
|
||||
|
||||
|
||||
@property
|
||||
def pos2(self) -> tuple[float, float, float]:
|
||||
"""Position des zweiten Blocks (x, y, z)."""
|
||||
dx = self.halbabstand * math.cos(self.winkel_rad)
|
||||
dy = self.halbabstand * math.sin(self.winkel_rad)
|
||||
return (self.x + dx, self.y + dy, self.hoehe)
|
||||
|
||||
|
||||
@property
|
||||
def z(self) -> float:
|
||||
"""Z-Koordinate (gleich der Höhe)."""
|
||||
return self.hoehe
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_merkmale(cls, teileid: str, x: float, y: float, merkmale: dict) -> 'Kreisel':
|
||||
def from_merkmale(
|
||||
cls, teileid: str, x: float, y: float, merkmale: dict
|
||||
) -> "Kreisel":
|
||||
"""Erstellt ein Kreisel-Objekt aus einem merkmale-Dictionary."""
|
||||
hoehe_m = merkmale.get("Höhe in m", "0").replace(",", ".")
|
||||
try:
|
||||
hoehe = float(hoehe_m) * 1000
|
||||
except (ValueError, TypeError):
|
||||
hoehe = 0.0
|
||||
|
||||
abstand_m = merkmale.get("Abstand (Kreiselachse A - Kreiselachse) in Meter", "20").replace(",", ".")
|
||||
|
||||
abstand_m = merkmale.get(
|
||||
"Abstand (Kreiselachse A - Kreiselachse) in Meter", "20"
|
||||
).replace(",", ".")
|
||||
try:
|
||||
abstand = float(abstand_m) * 1000
|
||||
except (ValueError, TypeError):
|
||||
abstand = 10000.0
|
||||
|
||||
|
||||
try:
|
||||
drehung = float(merkmale.get("Drehung", "0"))
|
||||
except (ValueError, TypeError):
|
||||
drehung = 0.0
|
||||
|
||||
|
||||
try:
|
||||
anzahl_scanner = float(merkmale.get("Anzahl der Scanner", "0"))
|
||||
except (ValueError, TypeError):
|
||||
anzahl_scanner = 0.0
|
||||
|
||||
|
||||
try:
|
||||
anzahl_separatoren = float(merkmale.get("Anzahl der Separatoren", "0"))
|
||||
except (ValueError, TypeError):
|
||||
anzahl_separatoren = 0.0
|
||||
|
||||
|
||||
return cls(
|
||||
teileid=teileid,
|
||||
x=x,
|
||||
@@ -125,9 +136,9 @@ class Kreisel(BaseModel):
|
||||
abstand=abstand,
|
||||
kreiselart=merkmale.get("Kreiselart"),
|
||||
anzahl_scanner=anzahl_scanner,
|
||||
anzahl_separatoren=anzahl_separatoren
|
||||
anzahl_separatoren=anzahl_separatoren,
|
||||
)
|
||||
|
||||
|
||||
def draw_kreisel_lines(msp, pos1, pos2, kreisel):
|
||||
"""Zeichnet tangentiale Linien zwischen zwei Kreiselblöcken, unabhängig vom Winkel."""
|
||||
rotation = kreisel.drehung
|
||||
@@ -145,58 +156,76 @@ class Kreisel(BaseModel):
|
||||
nx = -dy / length * RADIUS
|
||||
ny = dx / length * RADIUS
|
||||
# Tangentialpunkte
|
||||
p1a = (x1 + nx, y1 + ny,z1)
|
||||
p1b = (x1 - nx, y1 - ny,z1)
|
||||
p2a = (x2 + nx, y2 + ny,z1)
|
||||
p2b = (x2 - nx, y2 - ny,z1)
|
||||
p1a = (x1 + nx, y1 + ny, z1)
|
||||
p1b = (x1 - nx, y1 - ny, z1)
|
||||
p2a = (x2 + nx, y2 + ny, z1)
|
||||
p2b = (x2 - nx, y2 - ny, z1)
|
||||
if kreisel.kreiselart == "Pin":
|
||||
if rotation == 0.0:
|
||||
p1a2 = p1a[0] - RADIUS - 50, p1a[1] + 50, z1
|
||||
p1b2 = p1b[0] - RADIUS - 50, p1b[1] - 50, z1
|
||||
p2a2 = p2a[0] + RADIUS + 50, p2a[1] + 50, z1
|
||||
p2b2 = p2b[0] + RADIUS + 50, p2b[1] - 50, z1
|
||||
Line1 = Line.new(dxfattribs={"start": p1a2,"end": p2a2,"layer": "Pinbereich"})
|
||||
Line2 = Line.new(dxfattribs={"start": p1b2,"end": p2b2,"layer": "Pinbereich"})
|
||||
Line1 = Line.new(
|
||||
dxfattribs={"start": p1a2, "end": p2a2, "layer": "Pinbereich"}
|
||||
)
|
||||
Line2 = Line.new(
|
||||
dxfattribs={"start": p1b2, "end": p2b2, "layer": "Pinbereich"}
|
||||
)
|
||||
msp.add_entity(Line1)
|
||||
msp.add_entity(Line2)
|
||||
elif rotation == 180.0:
|
||||
elif rotation == 180.0:
|
||||
p1a2 = p1a[0] + RADIUS + 50, p1a[1] - 50, z1
|
||||
p1b2 = p1b[0] + RADIUS + 50, p1b[1] + 50, z1
|
||||
p2a2 = p2a[0] - RADIUS - 50, p2a[1] - 50, z1
|
||||
p2b2 = p2b[0] - RADIUS - 50, p2b[1] + 50, z1
|
||||
Line1 = Line.new(dxfattribs={"start": p1a2,"end": p2a2,"layer": "Pinbereich"})
|
||||
Line2 = Line.new(dxfattribs={"start": p1b2,"end": p2b2,"layer": "Pinbereich"})
|
||||
Line1 = Line.new(
|
||||
dxfattribs={"start": p1a2, "end": p2a2, "layer": "Pinbereich"}
|
||||
)
|
||||
Line2 = Line.new(
|
||||
dxfattribs={"start": p1b2, "end": p2b2, "layer": "Pinbereich"}
|
||||
)
|
||||
msp.add_entity(Line1)
|
||||
msp.add_entity(Line2)
|
||||
elif rotation == 90.0:
|
||||
p1a2 = p1a[0] + 50, p1a[1] - 50 + RADIUS , z1
|
||||
p1b2 = p1b[0] - 50, p1b[1] - 50 + RADIUS, z1
|
||||
p2a2 = p2a[0] + 50, p2a[1] + 50 - RADIUS, z1
|
||||
p2b2 = p2b[0] - 50, p2b[1] + 50 - RADIUS, z1
|
||||
Line1 = Line.new(dxfattribs={"start": p1a2,"end": p2a2,"layer": "Pinbereich"})
|
||||
Line2 = Line.new(dxfattribs={"start": p1b2,"end": p2b2,"layer": "Pinbereich"})
|
||||
elif rotation == 90.0:
|
||||
p1a2 = p1a[0] + 50, p1a[1] - 50 + RADIUS, z1
|
||||
p1b2 = p1b[0] - 50, p1b[1] - 50 + RADIUS, z1
|
||||
p2a2 = p2a[0] + 50, p2a[1] + 50 - RADIUS, z1
|
||||
p2b2 = p2b[0] - 50, p2b[1] + 50 - RADIUS, z1
|
||||
Line1 = Line.new(
|
||||
dxfattribs={"start": p1a2, "end": p2a2, "layer": "Pinbereich"}
|
||||
)
|
||||
Line2 = Line.new(
|
||||
dxfattribs={"start": p1b2, "end": p2b2, "layer": "Pinbereich"}
|
||||
)
|
||||
msp.add_entity(Line1)
|
||||
msp.add_entity(Line2)
|
||||
elif rotation == 270.0:
|
||||
p1a2 = p1a[0] - 50, p1a[1] + 50 - RADIUS , z1
|
||||
p1b2 = p1b[0] + 50, p1b[1] + 50 - RADIUS, z1
|
||||
p2a2 = p2a[0] - 50, p2a[1] - 50 + RADIUS, z1
|
||||
p2b2 = p2b[0] + 50, p2b[1] - 50 + RADIUS, z1
|
||||
Line1 = Line.new(dxfattribs={"start": p1a2,"end": p2a2,"layer": "Pinbereich"})
|
||||
Line2 = Line.new(dxfattribs={"start": p1b2,"end": p2b2,"layer": "Pinbereich"})
|
||||
elif rotation == 270.0:
|
||||
p1a2 = p1a[0] - 50, p1a[1] + 50 - RADIUS, z1
|
||||
p1b2 = p1b[0] + 50, p1b[1] + 50 - RADIUS, z1
|
||||
p2a2 = p2a[0] - 50, p2a[1] - 50 + RADIUS, z1
|
||||
p2b2 = p2b[0] + 50, p2b[1] - 50 + RADIUS, z1
|
||||
Line1 = Line.new(
|
||||
dxfattribs={"start": p1a2, "end": p2a2, "layer": "Pinbereich"}
|
||||
)
|
||||
Line2 = Line.new(
|
||||
dxfattribs={"start": p1b2, "end": p2b2, "layer": "Pinbereich"}
|
||||
)
|
||||
msp.add_entity(Line1)
|
||||
msp.add_entity(Line2)
|
||||
|
||||
# Linien zeichnen
|
||||
msp.add_line(p1a, p2a)
|
||||
msp.add_line(p1b, p2b)
|
||||
|
||||
def draw_kreisel_drehrichtung_markierung(msp, pos1, pos2, kreisel, lib_doc, doc, verbose):
|
||||
|
||||
def draw_kreisel_drehrichtung_markierung(
|
||||
msp, pos1, pos2, kreisel, lib_doc, doc, verbose
|
||||
):
|
||||
drehrichtung = (kreisel.drehrichtung or "").upper()
|
||||
if drehrichtung not in ("UZS", "GUZS"):
|
||||
return
|
||||
x1, y1,z1= pos1
|
||||
x2, y2,z2 = pos2
|
||||
x1, y1, z1 = pos1
|
||||
x2, y2, z2 = pos2
|
||||
dx = x2 - x1
|
||||
dy = y2 - y1
|
||||
length = math.hypot(dx, dy)
|
||||
@@ -216,24 +245,44 @@ class Kreisel(BaseModel):
|
||||
t = i / 4 # 1/4, 2/4, 3/4
|
||||
px = p1_oben[0] + t * (p2_oben[0] - p1_oben[0])
|
||||
py = p1_oben[1] + t * (p2_oben[1] - p1_oben[1])
|
||||
rotation = math.degrees(math.atan2(p2_oben[1] - p1_oben[1], p2_oben[0] - p1_oben[0]))
|
||||
rotation = math.degrees(
|
||||
math.atan2(p2_oben[1] - p1_oben[1], p2_oben[0] - p1_oben[0])
|
||||
)
|
||||
if drehrichtung == "GUZS":
|
||||
rotation += 180
|
||||
block_methoden.import_block("Richtungspfeil", lib_doc, doc)
|
||||
blockref_layer, color = block_methoden.get_insert_color_layer(lib_doc, "Richtungspfeil")
|
||||
bref = msp.add_blockref("Richtungspfeil", (px, py,z1), dxfattribs={"rotation": rotation,"layer": blockref_layer})
|
||||
blockref_layer, color = block_methoden.get_insert_color_layer(
|
||||
lib_doc, "Richtungspfeil"
|
||||
)
|
||||
bref = msp.add_blockref(
|
||||
"Richtungspfeil",
|
||||
(px, py, z1),
|
||||
dxfattribs={"rotation": rotation, "layer": blockref_layer},
|
||||
)
|
||||
if verbose:
|
||||
print(f"[INFO] Drehrichtung '{drehrichtung}': Richtungspfeil oben bei ({px:.1f}, {py:.1f}), rot={rotation:.1f}")
|
||||
print(
|
||||
f"[INFO] Drehrichtung '{drehrichtung}': Richtungspfeil oben bei ({px:.1f}, {py:.1f}), rot={rotation:.1f}"
|
||||
)
|
||||
# S-LP auf unterer Linie (Drehrichtung invertiert)
|
||||
for i in range(1, 4):
|
||||
t = i / 4
|
||||
px = p1_unten[0] + t * (p2_unten[0] - p1_unten[0])
|
||||
py = p1_unten[1] + t * (p2_unten[1] - p1_unten[1])
|
||||
rotation = math.degrees(math.atan2(p2_unten[1] - p1_unten[1], p2_unten[0] - p1_unten[0]))
|
||||
rotation = math.degrees(
|
||||
math.atan2(p2_unten[1] - p1_unten[1], p2_unten[0] - p1_unten[0])
|
||||
)
|
||||
if drehrichtung == "UZS":
|
||||
rotation += 180
|
||||
block_methoden.import_block("Richtungspfeil", lib_doc, doc)
|
||||
blockref_layer, color = block_methoden.get_insert_color_layer( lib_doc, "Richtungspfeil")
|
||||
bref = msp.add_blockref("Richtungspfeil", (px, py, z1), dxfattribs={"rotation": rotation , "layer": blockref_layer})
|
||||
blockref_layer, color = block_methoden.get_insert_color_layer(
|
||||
lib_doc, "Richtungspfeil"
|
||||
)
|
||||
bref = msp.add_blockref(
|
||||
"Richtungspfeil",
|
||||
(px, py, z1),
|
||||
dxfattribs={"rotation": rotation, "layer": blockref_layer},
|
||||
)
|
||||
if verbose:
|
||||
print(f"[INFO] Drehrichtung '{drehrichtung}':Richtungspfeil unten bei ({px:.1f}, {py:.1f}), rot={rotation:.1f}")
|
||||
print(
|
||||
f"[INFO] Drehrichtung '{drehrichtung}':Richtungspfeil unten bei ({px:.1f}, {py:.1f}), rot={rotation:.1f}"
|
||||
)
|
||||
|
||||
+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}
|
||||
)
|
||||
|
||||
+1299
-438
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user