Gebogenes Objekt auf gerade Linie abrollen ( Oder "Mathe für Runaways" )

  • Hi...

    Ich habe heute mal ein etwas spezielleres Problem.

    Ich habe jetzt seit mehreren Tagen versucht eine gebogene Kontur in AutoCAD wieder gerade zu biegen.
    Gesucht habe ich schon in allem wo ich was zum eintippen finden konnte ;)

    Annähernd habe ich dazu etwas unter "abrollen" in AutoCAD gefunden aber auch nicht wirklich passend wegen dem gebogenem.
    Jetzt zu dem was ich genau möchte:

    autoit.de/wcf/attachment/15379/

    Ich habe eine gebogene Polykontur "grün" mit einem Biegepfad "rot" und eine Gerade "pink".
    Das ganze würde ich jetzt gerne gerade gebogen haben, so das die "rote" genau auf der "pinken" liegt
    und die "grünen" auch mitgewandert sind..also das ganze Objekt gerade ist... dadurch wirde es natürlich länger und grün wird verzerrt.

    Aber im Endeffekt soll das Ergebnis alles per Umrechnung funzen.
    Also, da wir es in der Fima öfters brauchen werden will ich
    es in AutoIT umrechnen lassen. Nur dafür muss ich erst
    einmal einen Lösungsansatz bzw. die Lösung finden.
    Wie man so etwas überhaupt umrechnen...

    Ich wäre für jeden Ansatz dankbar!!

    Ich habe noch die dwg (nur mit ACAD) und eine dxf (lesbar ohne ACAD) angehangen.
    Werde jetzt noch schnell ne DXF UDF schreiben, da es die anscheinend auch nicht gibt.
    Damit man an die Daten ran kommt.

    MFG chris


  • Kannst du auch ein Bild des Ergebnisses zeigen? Ich bin mir gerade nicht ganz sicher, wie die Verzerrung am Ende aussehen soll.

  • Hmm, am Ende hast du sozusagen ein Rechteck mit den Abmessungen Biegepfadlänge * Bausteinhöhe korrekt?

  • Guten morgen

    also ich versuche es kurz zu erklären...ich hatte es oben etwas vereinfacht...
    Ich bin Holztechniker also Schreiner....
    Wenn Schreiner gebogene Sachen bauen sollen müssen sie Pressformen bauen...
    das kostet Zeit und Geld für die Formen... und die wirft man dann nachher wieder weg...
    man braucht ja nur die gebogene Platte...

    Ich bin vor kurzem im Netz über was gestolpert was mir absolutes Kopfzerbrechen bereitet hat...
    und das ist das biegen von Platten ohne Pressform.. mit Verzahnungen..
    manche Schreinereien haben das schon drauf ... aber es ist halt echt aufwendig zu berechnen wie ihr merkt..

    kurze Beschreibung...
    durch die unterschiedlich langen Abstände der Zacken und Plattenlängen biegen die
    Platten sich um die kurve und das beim zusammenpressen...

    geile Sache das ganze ;)

    In Bild 2 ist zu sehen das sich die Abstände erweitern/veringern je größer/kleiner der biege Radius ist.
    Was ich nicht bemaßt habte ist das sich auch die schäge der Flanken ändern...
    Das brauche ich alles...

    MFG chris :D

  • hiho

    wie gsagt... ich schreibe gerade die UDF für DXF damit man aus ner Zeichnung raus den pfad exportieren kann...
    Damit kann man dann alles andere ausrechenen und in die Zeichnung rein schreiben/zeichnen...
    und auch die wichtigen Parameter für die CNC auslesen und in eine mpr ( CNC Datei ) schreiben...
    Wäre echt cool wenn das geht...

    werde es dann sofort in der Firma testen ob das Ergebnis so ist wie erwartet...

    MFG chris

  • Du musst die Verformung übrigens zwei mal durchführen. Einmal für die obere und einmal für die untere Hälfte der Verzahnung.

  • Das ist mal der erste Test:

    Ich biege keine AutoCad-Kurve gerade, sondern berechne die Verzahnung gleich selber!

    Das Script liest eine Kurve aus einer Datei (hier noch InkScape-SVG)
    und berechnet dann die Verzahnungen.
    Dann wird die Verzahnung 2 Mal gradegebogen und zwar einmal auf der Unterseite und einmal auf der Oberseite
    Die fertige Verzahnung wird zu Testzwecken als EMF abgespeichert.

    Ein großer Teil des Codes dient nur zum Visualisieren. Ein "fertiger" Code sollte dann viel kleiner und schöner sein :D
    Deshalb auch das Durcheinander...

    Script:

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    ;#include "GDIp.au3"
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $iOffSetX = -1
    Global $iOffSetY = -1

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $PI = ATan(1) * 4
    Global Const $2PI = $PI * 2
    Global Const $PI2 = $PI / 2
    Global Const $Deg2Rad = $PI / 180
    Global Const $Rad2Deg = 180 / $PI
    Global $_ME_hMSVCRT = DllOpen('msvcrt.dll')

    [/autoit] [autoit][/autoit] [autoit]

    Global $tPath = _Load(@ScriptDir & "\Bogen2.svg")

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 1200
    Global $iHeight = 600

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Test", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPen = _GDIPlus_PenCreate(0xFF00FF00, 1)
    Global $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 1)
    Global $hPen3 = _GDIPlus_PenCreate(0xFF0000FF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _Draw()
    Global $tGears = _CalcGears($tPath, 10, 40, 18)
    ;#cs
    Global $tFlat_Up = _Flatten($tGears, 1)
    Global $tFlat_Lo = _Flatten($tGears, 0)
    _Show($tPath, $tFlat_Up, 0.8, 10, 100)
    _Show($tPath, $tFlat_Lo, 0.8, 10, 200)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    ;MsgBox(0, "", "")

    [/autoit] [autoit][/autoit] [autoit]

    _Save($tFlat_Lo, @ScriptDir & "\Unten.emf")
    _Save($tFlat_Up, @ScriptDir & "\Oben.emf")
    ;#ce

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Save($tFlat, $sFileName)
    Local $iCnt = DllStructGetData($tFlat, "Cnt")
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPath = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    ;DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPath, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt)
    DllCall($ghGDIPDll, "uint", "GdipAddPathCurve3", "hwnd", $hPath, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt, "int", 0, "int", $iCnt-1, "float", 0)
    ;DllCall($ghGDIPDll, "uint", "GdipClosePathFigure", "hwnd", $hPath)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tRectF = DllStructCreate("float X; float Y; float Width; float Height;")
    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tRectF, "X"), -DllStructGetData($tRectF, "Y"))
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)
    DllStructSetData($tRectF, "X", 0)
    DllStructSetData($tRectF, "Y", 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hPen = _GDIPlus_PenCreate(0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hDC = _WinAPI_GetDC($hGui)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipRecordMetafileFileName", "wstr", $sFileName, "hwnd", $hDC, "int", 5, "ptr", DllStructGetPtr($tRectF), "int", 6, "wstr", "Platte Unten", "int*", 0)
    Local $hImage = $aResult[7]
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hImage) ;GraphicContext vom Metafile bekommen (um darauf zu zeichnen)
    DllCall($ghGDIPDll, "uint", "GdipSetPageUnit", "hwnd", $hContext, "int", 6) ; Einheit auf mm setzen

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hContext, "hwnd", $hPen, "hwnd", $hPath)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hContext) ; Metafile abschliesen und speichern
    _GDIPlus_ImageDispose($hImage) ; Metafile aus Speicher löschen

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_ReleaseDC($hGui, $hDC)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
    _GDIPlus_PenDispose($hPen)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CalcGears($tPath, $fW = 10, $fH = 20, $fR = 8)
    Local $fGA = $fR * $Deg2Rad
    Local $fGA_Plus
    Local $fGR = $fH / Tan($PI2 - $fGA) ; X-Offset der Schräge
    Local $fGH = $fH / Cos($fGA) ; Länge der Höhe
    Local $fGW = $fW + $fGR

    [/autoit] [autoit][/autoit] [autoit]

    Local $iCnt = DllStructGetData($tPath, "Cnt")
    Local $tGears = DllStructCreate("int Cnt; float Pnt[" & $iCnt * 2 & "];")
    _GearAddPoint($tGears, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iStep = 0, $fX1, $fY1, $fX2 = 0, $fY2 = 0, $fD, $fA, $iIdx

    [/autoit] [autoit][/autoit] [autoit]

    Local $aLast, $iDir = 0
    Local $fATmp = _MathEx_Atan2(DllStructGetData($tPath, "Pnt", 4), DllStructGetData($tPath, "Pnt", 3))
    While $iStep < $iCnt
    $iStep += 1
    $fX1 = DllStructGetData($tPath, "Pnt", ($iStep - 1) * 2 + 1)
    $fY1 = DllStructGetData($tPath, "Pnt", ($iStep - 1) * 2 + 2)
    $fD = Sqrt(($fX1 - $fX2) ^ 2 + ($fY1 - $fY2) ^ 2)
    If $fD >= $fGW * 2 Then ; Suche nächten Winkelpunkt
    ;ConsoleWrite("! " & $fD & @CRLF)
    ;_GDIPlus_GraphicsDrawLine($hGfxBuffer, $fX1+$iOffSetX, $fY1+$iOffSetY, $fX2+$iOffSetX, $fY2+$iOffSetY, $hPen2)
    ;_GDIPlus_GraphicsDrawLine($hGfxBuffer, $fX1+$iOffSetX, $fY1+$iOffSetY, $fX1+Cos($fA)*$fD*10+$iOffSetX, $fY1+Sin($fA)*$fD*10+$iOffSetY, $hPen2)
    Do
    $fA = _MathEx_Atan2($fY1 - $fY2, $fX1 - $fX2)

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case ($fA - $fATmp) < 0
    If $iDir = 1 Then
    $iIdx = DllStructGetData($tGears, "Cnt")
    DllStructSetData($tGears, "Cnt", $iIdx - 1)
    $fGA_Plus = ($fATmp - $fA) / 2
    ConsoleWrite("! Plus: " & $fGA_Plus * $Rad2Deg & " A: " & $fA * $Rad2Deg & " ATmp: " & $fATmp * $Rad2Deg & @CRLF)
    _GearAddPoint($tGears, $fGH, $fA + $PI2 - $fGA + $fGA_Plus)
    _ShowDrawLastPnt($tGears)
    $iDir = 2
    EndIf
    _GearAddPoint($tGears, $fW, $fA)
    ;_ShowDrawLastPnt($tGears)
    _GearAddPoint($tGears, $fGH, $fA - $PI2 + $fGA)
    ;_ShowDrawLastPnt($tGears)
    $fGA_Plus = ($fATmp - $fA) / 3
    ConsoleWrite("> Plus: " & $fGA_Plus * $Rad2Deg & " A: " & $fA * $Rad2Deg & " ATmp: " & $fATmp * $Rad2Deg & @CRLF)
    _GearAddPoint($tGears, $fW, $fA - $fGA_Plus * 1)
    ;_ShowDrawLastPnt($tGears)
    _GearAddPoint($tGears, $fGH, $fA + $PI2 - $fGA - $fGA_Plus * 2)
    ;_ShowDrawLastPnt($tGears)
    ;MsgBox(0,"","")
    ;ContinueCase
    Case Else
    $fGA_Plus = ($fATmp - $fA) / 2
    ConsoleWrite("+ Plus: " & $fGA_Plus * $Rad2Deg & " A: " & $fA * $Rad2Deg & " ATmp: " & $fATmp * $Rad2Deg & @CRLF)
    _GearAddPoint($tGears, $fW, $fA + $fGA_Plus)
    _GearAddPoint($tGears, $fGH, $fA - $PI2 + $fGA)
    _GearAddPoint($tGears, $fW, $fA)
    _GearAddPoint($tGears, $fGH, $fA + $PI2 - $fGA)
    $iDir = 1
    EndSelect
    $fATmp = $fA

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $iIdx = DllStructGetData($tGears, "Cnt")
    $fX2 = DllStructGetData($tGears, "Pnt", ($iIdx - 1) * 2 + 1)
    $fY2 = DllStructGetData($tGears, "Pnt", ($iIdx - 1) * 2 + 2)

    [/autoit] [autoit][/autoit] [autoit]

    Until Sqrt(($fX1 - $fX2) ^ 2 + ($fY1 - $fY2) ^ 2) < $fGW
    ;ExitLoop
    EndIf
    WEnd
    ;_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
    _Show($tPath, $tGears)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    MsgBox(0, "", "")
    ;_Exit()
    Return $tGears
    EndFunc ;==>_CalcGears

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ShowDrawLastPnt($tGears)
    Local $iCnt = DllStructGetData($tGears, "Cnt")
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen2, "float", _
    DllStructGetData($tGears, "Pnt", ($iCnt - 2) * 2 + 1) + $iOffSetX, "float", DllStructGetData($tGears, "Pnt", ($iCnt - 2) * 2 + 2) + $iOffSetY, "float", _
    DllStructGetData($tGears, "Pnt", ($iCnt - 1) * 2 + 1) + $iOffSetX, "float", DllStructGetData($tGears, "Pnt", ($iCnt - 1) * 2 + 2) + $iOffSetY)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_ShowDrawLastPnt

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GearAddPoint($tGears, $fD, $fA)
    Local $iCnt = DllStructGetData($tGears, "Cnt")
    Local $fX = DllStructGetData($tGears, "Pnt", ($iCnt - 1) * 2 + 1)
    Local $fY = DllStructGetData($tGears, "Pnt", ($iCnt - 1) * 2 + 2)
    Local $aReturn[2]
    $aReturn[0] = $fX + Cos($fA) * $fD
    $aReturn[1] = $fY + Sin($fA) * $fD
    DllStructSetData($tGears, "Pnt", $aReturn[0], $iCnt * 2 + 1)
    DllStructSetData($tGears, "Pnt", $aReturn[1], $iCnt * 2 + 2)
    DllStructSetData($tGears, "Cnt", $iCnt + 1)
    Return $aReturn
    EndFunc ;==>_GearAddPoint

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    _Show($tPath, 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Show($tPath, $tGears, $fScale = 1, $iOffX = 100, $iOffY = 100)
    Local $iPathCnt = DllStructGetData($tPath, "Cnt")
    Local $iGearCnt = DllStructGetData($tGears, "Cnt")
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPathPath = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPathGear = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipAddPathCurve", "hwnd", $hPathPath, "ptr", DllStructGetPtr($tPath, "Pnt"), "int", $iPathCnt)
    ;DllCall($ghGDIPDll, "uint", "GdipAddPathCurve3", "hwnd", $hPathGear, "ptr", DllStructGetPtr($tGears, "Pnt"), "int", $iGearCnt, "int", 0, "int", $iGearCnt-1, "float", 0)
    DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPathGear, "ptr", DllStructGetPtr($tGears, "Pnt"), "int", $iGearCnt)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tRectF = DllStructCreate("float X; float Y; float Width; float Height;")
    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPathPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    Local $hMatrix = _GDIPlus_MatrixCreate()

    [/autoit] [autoit][/autoit] [autoit]

    If $iOffSetX = -1 Then
    $iOffSetX = -DllStructGetData($tRectF, "X") + $iOffX
    $iOffSetY = -DllStructGetData($tRectF, "Y") + $iOffY
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tRectF, "X"), -DllStructGetData($tRectF, "Y"))
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathPath, "hwnd", $hMatrix)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathGear, "hwnd", $hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathPath, "hwnd", $hMatrix)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathGear, "hwnd", $hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixTranslate($hMatrix, $iOffX, $iOffY)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathPath, "hwnd", $hMatrix)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathGear, "hwnd", $hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen, "hwnd", $hPathPath)
    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen3, "hwnd", $hPathGear)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;#cs
    ; Bemassung
    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetPointCount", "hwnd", $hPathGear, "int*", 0)
    Local $iCnt = $aResult[2]
    Local $tPoints = DllStructCreate("float[" & $iCnt * 2 & "]")
    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPathGear, "ptr", DllStructGetPtr($tPoints), "int", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    Local $fX1 = 0, $fY1 = 0, $fX2, $fY2, $fD, $fA1, $fA2, $fADiff, $fATmp
    For $i = 1 To $iCnt
    $fX2 = DllStructGetData($tPoints, 1, ($i - 1) * 2 + 1)
    $fY2 = DllStructGetData($tPoints, 1, ($i - 1) * 2 + 2)
    $fD = Sqrt(Abs(($fX2 - $fX1) ^ 2 + ($fY2 - $fY1) ^ 2))
    $fA2 = 180 + _MathEx_Atan2($fY2 - $fY1, $fX2 - $fX1) * $Rad2Deg
    ;If $fA2 > 180 Then $fA2 = 180 + _MathEx_Atan2($fY1 - $fY2, $fX1 - $fX2) * $Rad2Deg
    $fADiff = Mod(180 + $fA1 - $fA2, 360)
    $fATmp = 1
    If $fADiff > 180 Then
    $fADiff = 360 - $fADiff
    $fATmp = 0
    EndIf
    If $fADiff < 0 Then $fADiff += 360

    [/autoit] [autoit][/autoit] [autoit]

    If $i > 1 Then
    If $fATmp = 1 Then
    ;_GDIPlus_GraphicsDrawPie($hGfxBuffer, $fX1 - 10, $fY1 - 10, 20, 20, $fA2 + 180, $fADiff, $hPen)
    ConsoleWrite("! " & $fX1 - 10 & " " & $fY1 - 10 & @CRLF)
    Else
    ;_GDIPlus_GraphicsDrawPie($hGfxBuffer, $fX1 - 10, $fY1 - 10, 20, 20, $fA1, $fADiff, $hPen)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;_GDIPlus_GraphicsDrawString_C($hGfxBuffer, Round($fA2, 2), $fX1 + (($fX2 - $fX1) / 2), $fY1 + (($fY2 - $fY1) / 2), "Arial", 6.5, 0, 0xFFFF0000)
    ;_GDIPlus_GraphicsDrawString_C($hGfxBuffer, Round($fADiff, 2), $fX1, $fY1, "Arial", 6.5, 0, 0xFF0000FF)
    ;_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    ;MsgBox(0,"","")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $fX1 = $fX2
    $fY1 = $fY2
    $fA1 = $fA2
    Next
    ; Bemassung
    ;#ce

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPathPath)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPathGear)
    EndFunc ;==>_Show

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __Flatten($tFlat, $iI1, $iI2)
    Local $iCnt = DllStructGetData($tFlat, "Cnt")
    Local $fX1, $fY1, $fX2, $fY2, $fA

    [/autoit] [autoit][/autoit] [autoit]

    $fX1 = DllStructGetData($tFlat, "Pnt", $iI1 * 2 + 1)
    $fY1 = DllStructGetData($tFlat, "Pnt", $iI1 * 2 + 2)
    $fX2 = DllStructGetData($tFlat, "Pnt", $iI2 * 2 + 1)
    $fY2 = DllStructGetData($tFlat, "Pnt", $iI2 * 2 + 2)
    $fA = _MathEx_Atan2($fY2 - $fY1, $fX2 - $fX1)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$fX1, -$fY1)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixRotate($hMatrix, -$fA * $Rad2Deg)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", DllStructGetPtr($tFlat, "Pnt") + $iI1 * 8, "int", $iCnt - $iI1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixDispose($hMatrix)
    EndFunc ;==>__Flatten

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Flatten($tGears, $iFlag = 1)
    Local $iCnt = DllStructGetData($tGears, "Cnt")
    Local $tFlat = DllStructCreate("int Cnt; float Pnt[" & $iCnt * 2 & "];")

    [/autoit] [autoit][/autoit] [autoit]

    If $iFlag Then
    $iCnt -=3
    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", DllStructGetPtr($tFlat, "Pnt"), "ptr", DllStructGetPtr($tGears, "Pnt") + 2 * 8, "ulong_ptr", $iCnt * 8)
    Else
    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", DllStructGetPtr($tFlat, "Pnt"), "ptr", DllStructGetPtr($tGears, "Pnt"), "ulong_ptr", $iCnt * 8)
    EndIf
    DllStructSetData($tFlat, "Cnt", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPath = $aResult[2]
    Local $tRectF = DllStructCreate("float X; float Y; float Width; float Height;")

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix = _GDIPlus_MatrixCreate()

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To $iCnt - 3 Step 4

    [/autoit] [autoit][/autoit] [autoit]

    __Flatten($tFlat, $i, $i + 1)
    If $i < $iCnt - 3 Then __Flatten($tFlat, $i + 1, $i + 4)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipResetPath", "hwnd", $hPath)
    DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPath, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    ConsoleWrite("- " & DllStructGetData($tRectF, "X") & " " & DllStructGetData($tRectF, "Y") & " " & DllStructGetData($tRectF, "Width") & " " & DllStructGetData($tRectF, "Height") & @CRLF)
    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tRectF, "X"), -DllStructGetData($tRectF, "Y"))
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen3, "hwnd", $hPath)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    ;MsgBox(0,"","")
    Next
    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tRectF, "X"), -DllStructGetData($tRectF, "Y"))
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    Return $tFlat
    EndFunc ;==>_Flatten

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Load($sPath, $fScale = 1)
    Local $sFile = FileRead($sPath)
    Local $aRegExp = StringRegExp($sFile, "(?s)\<path(.*)\/\>", 3)
    $aRegExp = StringRegExp($aRegExp[0], 'd="([^"]+)', 3)
    Local $aSplit = StringSplit($aRegExp[0], " ")
    Local $tPath = DllStructCreate("int Cnt; float Pnt[" & $aSplit[0] * 2 & "];")
    Local $iCnt = 0, $fX = 0, $fY = 0
    For $i = 1 To $aSplit[0]
    $aRegExp = StringRegExp($aSplit[$i], "[\d.-]+", 3)
    If UBound($aRegExp) <> 2 Then ContinueLoop
    $iCnt += 1
    If $iCnt = 1 Then
    $aRegExp[0] = 0
    $aRegExp[1] = 0
    EndIf
    DllStructSetData($tPath, "Pnt", $fX + $aRegExp[0], ($iCnt - 1) * 2 + 1)
    DllStructSetData($tPath, "Pnt", $fY + $aRegExp[1], ($iCnt - 1) * 2 + 2)
    $fX += $aRegExp[0]
    $fY += $aRegExp[1]
    Next

    [/autoit] [autoit][/autoit] [autoit]

    If $fScale <> 1 Then
    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", DllStructGetPtr($tPath, "Pnt"), "int", $iCnt)
    _GDIPlus_MatrixDispose($hMatrix)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($tPath, "Cnt", $iCnt)
    Return $tPath
    EndFunc ;==>_Load

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_PenDispose($hPen3)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit] [autoit][/autoit] [autoit]

    Func _MathEx_Atan2($fY, $fX)
    Local $aResult = DllCall($_ME_hMSVCRT, "double:cdecl", "atan2", "double", $fY, "double", $fX)
    If @error Then Return SetError(1, 1, False)
    Return $aResult[0]
    EndFunc ;==>_MathEx_Atan2

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_GraphicsDrawString_C($hGraphics, $sString, $nX, $nY, $sFont = "Arial", $nSize = 10, $iFormat = 0, $iColor = 0xFF000000)
    Local $hBrush = _GDIPlus_BrushCreateSolid($iColor)
    Local $hFormat = _GDIPlus_StringFormatCreate($iFormat)
    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $nSize)
    Local $tLayout = _GDIPlus_RectFCreate($nX, $nY, 0, 0)
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)
    Local $aResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    Local $iError = @error
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    Return SetError($iError, 0, $aResult)
    EndFunc ;==>_GDIPlus_GraphicsDrawString_C

    [/autoit]

    Bogen2.svg:

    Spoiler anzeigen

    Die fertigen EMF´s hab ich in einem Grafikprogramm zerschnitten und Kante an Kante zusammengebaut - Das Ergebnis reicht fast an die original-Kurve heran:
    autoit.de/wcf/attachment/15396/


    Das Ergebnis dann noch in MPR umzuwandeln, sollte das geringste Problem sein...


    Wie gedenkst du denn eigentlich die Verzahnung zu fräsen?
    Kann deine CNC den Fräskopf bzw. Sägeblatt neigen?


    Ach ja: In Zeile 46 kannst mit den Parametern Breite, Höhe und Steigungswinkel einstellen!

    E

  • hi...

    also sorry aber ich muss das jetzt echt mal sagen... "Man bist du Fertig!!" sorry nur positiv gemeint ;)
    Geilo... das geht schon sehr in die Richtung wie ich es mir vorgestellt habe.
    Mein größtes Problem wird nur sein das ganze zu verstehen...

    Aber mit etwas Zeit wird das wohl...

    Aber auf jeden fall Hammer...
    MPR erstellung bekomme ich auf jeden Fall hin...

    nun zum fräsen... wir haben leider keine 5Achs CNC dann würde das viel schneller gehen..
    Aber wir haben eine 4 1/2 Achs mit nem Zusatzmodul
    damit geht das... schaust du hier... http://www.youtube.com/watch?v=KkJfTf8aX7s&feature=related

    Aber supi echt!!
    Werde dann weitere Fortschritte mal hier posten..

    MFG chris :D

  • War mir schon klar, dass es Eukalyptus richtig heiß gemacht hat, dafür was zu coden. :D


    Well done! :thumbup:


    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Das war wie gesagt nur der erste Test.
    Die Zähne sind nicht wirklich symmetrisch.
    Aber ich glaub ich weiß schon, wie das besser und einfacher geht...
    Das kann ich aber erst nächste Woche probieren.

    Für mich ist das deshalb so interessant, weil ich selber gelernter Schreiner bin und auch etwa 4 Jahre mit einer CNC Fräse gearbeitet hab.
    Das war allerdings vor fast 10 Jahren.
    Damals hatten wir zwar ein verstellbares Sägemodul, aber die Neigung musste manuell verstellt werden - also hierfür nicht geeignet!

    Und JA - bitte schreib eine DXF-UDF! sowas hätte ich schon ein paar mal gebraucht :thumbup:

    E