So Habs noch mal getestet und mit der original.nc die ich angepast habe funktioniert es nicht, der unterschied ist das die Z Koordinaten nicht z.B. Z 63.572 sondern Z-63.572.
Ist eine txt da ich keine nc hochladen kann
original.txt
So Habs noch mal getestet und mit der original.nc die ich angepast habe funktioniert es nicht, der unterschied ist das die Z Koordinaten nicht z.B. Z 63.572 sondern Z-63.572.
Ist eine txt da ich keine nc hochladen kann
original.txt
So hab mein Problem gelöst bekommen statt $data = StringRegExp($arFile[$i], "Z(\d*(?:\.)?\d*)", 3) eben $data = StringRegExp($arFile[$i], "Z(\-*(?:\.)?\d*)", 3) das d gegen -
hier noch mal das Ganze Script eventuelle könnte da jemand drüberschauen inbezug übersichtlichkeit oder etwas kompakter machen usw.
#include <ButtonConstants.au3>
#include <WinAPIFiles.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
FileInstall("original.nc", @ScriptDir & "\original.nc", 1) ; <- original.nc muss beim kompilieren im @ScriptDir liegen
$Form1_1 = GUICreate("NC Code Anpassung", 894, 533, 192, 124)
$Graphic1 = GUICtrlCreateGraphic(80, 8, 400, 400)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0x3366FF)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, 400, 400)
$WertY1 = GUICtrlCreateInput("0", 544, 248, 121, 21)
$WertX1 = GUICtrlCreateInput("0", 544, 304, 121, 21)
$Label1 = GUICtrlCreateLabel("Mass in Y -", 544, 224, 56, 17, $SS_CENTER)
$Label2 = GUICtrlCreateLabel("Mass in X -", 544, 280, 56, 17, $SS_CENTER)
$WertZ1 = GUICtrlCreateInput("0", 544, 360, 121, 21)
$Label3 = GUICtrlCreateLabel("Mass in Z -", 544, 336, 56, 17, $SS_CENTER)
$Label4 = GUICtrlCreateLabel("X undY 0", 8, 456, 72, 25, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Grundmass in mm X100 Y 100 Z10", 0, 488, 204, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Erstellen = GUICtrlCreateButton("Erstellen", 544, 440, 123, 25)
$Beenden = GUICtrlCreateButton("Beenden", 544, 472, 123, 25)
$WertY2 = GUICtrlCreateInput("0", 688, 248, 121, 21)
$WertX2 = GUICtrlCreateInput("0", 688, 304, 121, 21)
$Label7 = GUICtrlCreateLabel("Mass in Y +", 688, 224, 59, 17, $SS_CENTER)
$Label8 = GUICtrlCreateLabel("Mass in X +", 688, 280, 59, 17, $SS_CENTER)
$WertZ2 = GUICtrlCreateInput("0", 688, 360, 121, 21)
$Label9 = GUICtrlCreateLabel("Mass in Z +", 688, 336, 59, 17, $SS_CENTER)
$Input1 = GUICtrlCreateInput("NC", 544, 200, 121, 21)
$Label6 = GUICtrlCreateLabel("Name der NC Datei ", 544, 176, 99, 17, $SS_CENTER)
$Graphic2 = GUICtrlCreateGraphic(32, 408, 51, 52)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 6, 47)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 46, 7)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 46, 7)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 46, 24)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 31, 7)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 46, 7)
$Label10 = GUICtrlCreateLabel("Istmass in mm X 100 Y 100 Z 10", 224, 488, 294, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label11 = GUICtrlCreateLabel("X in +", 96, 416, 44, 32)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Graphic3 = GUICtrlCreateGraphic(144, 416, 51, 36)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 6, 14)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 46, 14)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 32, 5)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 47, 14)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 31, 22)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 46, 15)
$Label12 = GUICtrlCreateLabel("Y in +", 32, 376, 44, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Graphic4 = GUICtrlCreateGraphic(32, 320, 51, 51)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 19, 4)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 19, 46)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 11, 22)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 19, 4)
GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 27, 21)
GUICtrlSetGraphic(-1, $GUI_GR_LINE, 19, 6)
$Input2 = GUICtrlCreateInput("4000", 544, 104, 121, 21)
$Label15 = GUICtrlCreateLabel("Spindel Drehzahl", 544, 80, 99, 17)
$Input3 = GUICtrlCreateInput("500", 544, 152, 121, 21)
$Label16 = GUICtrlCreateLabel("Forschub", 544, 128, 99, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
FileDelete(@ScriptDir & "\original.nc")
Exit
Case $Form1_1
Case $Label1
Case $Label2
Case $Label3
Case $Label7
Case $Label8
Case $Label9
Case $Beenden
FileDelete(@ScriptDir & "\original.nc")
Exit
Case $Erstellen
$WertX3 = GUICtrlRead($WertX1)
$WertY3 = GUICtrlRead($WertY1)
$WertZ3 = GUICtrlRead($WertZ1)
$WertX4 = GUICtrlRead($WertX2)
$WertY4 = GUICtrlRead($WertY2)
$WertZ4 = GUICtrlRead($WertZ2)
$drehzahl = GUICtrlRead($Input2)
$vorschub = GUICtrlRead($Input3)
$ncfilename = GUICtrlRead($Input1)
$ergebnisx = (100 - $WertX3 + $WertX4)
$ergebnisY = (100 - $WertY3 + $WertY4)
$ergebnisZ = (10 - $WertZ3 + $WertZ4)
$ergebnis = " X " & $ergebnisx & " Y " & $ergebnisY & " Z " & $ergebnisZ
$Label10 = GUICtrlCreateLabel("Istmass in mm" & $ergebnis, 224, 488, 294, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$arFile = FileReadToArray(@ScriptDir & "\original.nc")
Local $arX = [18, 86], $arY = [22, 22], $arZ = [22, 152], $arF = [21, 21], $arS = [17, 17]
;Änder X
For $i = $arX[0] - 1 To $arX[1] - 1 Step 1
$data = StringRegExp($arFile[$i], "X(\d*(?:\.)?\d*)", 3)
If UBound($data) > 0 Then
$data = Number($data[0]) ;Calculate X with data
$data = ($data - $WertX3 + $WertX4)
$arFile[$i] = StringRegExpReplace($arFile[$i], "X(\d*(?:\.)?\d*)", "X" & $data)
EndIf
Next
;Änder Z
For $i = $arZ[0] - 1 To $arZ[1] - 1 Step 1
$data = StringRegExp($arFile[$i], "Z(\-*(?:\.)?\d*)", 3)
If UBound($data) > 0 Then
$data = Number($data[0])
$data = ($data - $WertZ3 + $WertZ4) ;Calculate Z with data
$arFile[$i] = StringRegExpReplace($arFile[$i], "Z(\-*(?:\.)?\d*)", "Z" & $data)
EndIf
Next
;Änder Y
For $i = $arY[0] - 1 To $arY[1] - 1 Step 1
$data = StringRegExp($arFile[$i], "Y(\d*(?:\.)?\d*)", 3)
If UBound($data) > 0 Then
$data = Number($data[0])
$data = ($data - $WertY3 + $WertY4) ;Calculate Y with data
$arFile[$i] = StringRegExpReplace($arFile[$i], "Y(\d*(?:\.)?\d*)", "Y" & $data)
EndIf
Next
For $i = $arF[0] - 1 To $arF[1] - 1 Step 1
$data = StringRegExp($arFile[$i], "F(\d*(?:\.)?\d*)", 3)
If UBound($data) > 0 Then
$data = Number($data[0])
$data = ($vorschub) ;Calculate Vorschub with data
$arFile[$i] = StringRegExpReplace($arFile[$i], "F(\d*(?:\.)?\d*)", "F" & $data)
EndIf
Next
For $i = $arS[0] - 1 To $arS[1] - 1 Step 1
$data = StringRegExp($arFile[$i], "S(\d*(?:\.)?\d*)", 3)
If UBound($data) > 0 Then
$data = Number($data[0])
$data = ($drehzahl) ;Calculate Drehzahl with data
$arFile[$i] = StringRegExpReplace($arFile[$i], "S(\d*(?:\.)?\d*)", "S" & $data)
EndIf
Next
If FileExists("C:\NC Programm\Erstellte Dateinen\") Then
$sFilePath = ("C:\NC Programm\Erstellte Dateinen\" & $ncfilename & ".nc")
Else
DirCreate("C:\NC Programm\Erstellte Dateinen\")
$sFilePath = ("C:\NC Programm\Erstellte Dateinen\" & $ncfilename & ".nc")
EndIf
_FileWriteFromArray($sFilePath, $arFile)
;_ArrayDisplay($arFile)
EndSwitch
WEnd
Alles anzeigen
Wenn dein Problem gelöst ist, dann setz doch bitte den grünen Haken indem du den 1. Beitrag in diesem Thread bearbeitest und den Threadstatus veränderst.