From fa083039bf22decfe9aa13baa90b3ffec1727687 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 8 Oct 2019 18:24:42 +0000 Subject: [PATCH] =?UTF-8?q?EgtCAM5=202.1j4=20:=20-=20aggiunta=20possibilit?= =?UTF-8?q?=C3=A0=20di=20visualizzare=20il=20partprogram=20generato=20(Shi?= =?UTF-8?q?ft+Genera).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- My Project/AssemblyInfo.vb | 4 +- .../SimulationExpanderViewModel.vb | 117 +++++++++++------- 2 files changed, 74 insertions(+), 47 deletions(-) diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index a136395..0d29bf4 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -70,5 +70,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb index 36fc5e2..7a94e8d 100644 --- a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb +++ b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb @@ -574,58 +574,46 @@ Public Class SimulationExpanderVM ''' Creata the new tool. This method is invoked by the NewCommand. ''' Public Sub Generate(ByVal param As Object) - ' Recupero la fase corrente - Dim nPhase As Integer = EgtGetCurrPhase() - ' Aggiorno le lavorazioni - If Not UpdateAllMachinings() Then - EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True) - Return - End If - ' Eseguo - Dim sCurrFilePath As String = String.Empty - EgtGetCurrFilePath(sCurrFilePath) - If String.IsNullOrEmpty(sCurrFilePath) OrElse EgtGetModified() Then - ' Il progetto deve essere salvato prima di poter essere generato. Vuoi farlo ? - If MessageBox.Show(EgtMsg(MSG_SIMULATION + 31), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then - ' Abbandono + ' Normalmente, Genero + If (Keyboard.Modifiers And ModifierKeys.Shift) <> ModifierKeys.Shift Then + ' Recupero la fase corrente + Dim nPhase As Integer = EgtGetCurrPhase() + ' Aggiorno le lavorazioni + If Not UpdateAllMachinings() Then + EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True) Return - Else - ' Lancio salvataggio - Application.Msn.NotifyColleagues(Application.SAVEPROJECT) - ' Se non salvato, abbandono - If EgtGetModified() Then Return - ' Aggiorno path - EgtGetCurrFilePath(sCurrFilePath) End If - End If - Dim sCncFile As String = "" - Dim sInfo As String = "EgtCAM5 - " & sCurrFilePath - If EgtGetInfo( EgtGetCurrMachGroup(), KEY_MCHGRP_NCNAME, sCncFile) AndAlso Not String.IsNullOrWhiteSpace( sCncFile) then - sCncFile = Path.GetDirectoryName (sCurrFilePath) & "\" & sCncFile - else - sCncFile = Path.ChangeExtension(sCurrFilePath, Nothing) - If IniFile.m_bMachiningGroup Then - Dim sMGrpName As String = String.Empty - If EgtGetMachGroupName(EgtGetCurrMachGroup(), sMGrpName) Then - sCncFile &= "_" & sMGrpName & ".cnc" - sInfo &= "-" & sMGrpName + ' Recupero nome file CN (dopo aver verificato salvataggio progetto) + Dim sCncFile As String = "" + Dim sInfo As String = "" + If Not GetCncFileName( True, sCncFile, sInfo) Then Return + ' Eseguo + If Not EgtGenerate(sCncFile, sInfo) Then + If EgtGetLastMachMgrErrorId() <> 0 Then + Dim sErr As String = EgtGetLastMachMgrErrorString() + MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation) + Else + MessageBox.Show(EgtMsg(MSG_SIMULATION + 6), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error) End If Else - sCncFile &= ".cnc" - End If - End if - If Not EgtGenerate(sCncFile, sInfo) Then - If EgtGetLastMachMgrErrorId() <> 0 Then - Dim sErr As String = EgtGetLastMachMgrErrorString() - MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation) - Else - MessageBox.Show(EgtMsg(MSG_SIMULATION + 6), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error) + Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_SIMULATION + 32) & " (" & sCncFile & ")") End If + ' Torno alla fase originale (o alla prima se non definita) + EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True) + ' Altrimenti premuto shift, Visualizzo CN corrente Else - Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_SIMULATION + 32) & " (" & sCncFile & ")") + ' Recupero nome file CN + Dim sCncFile As String = "" + Dim sInfo As String = "" + If Not GetCncFileName( False, sCncFile, sInfo) Then Return + ' Se esiste ne lancio l'editing + If File.Exists( sCncFile) Then + Process.Start( "Notepad.exe", sCncFile) + ' altrimenti lo segnalo + Else + Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, "Edit failed, missing part program file" & " (" & sCncFile & ")") + End If End If - ' Torno alla fase originale (o alla prima se non definita) - EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True) End Sub #End Region ' GenerateCommand @@ -932,6 +920,45 @@ Public Class SimulationExpanderVM End If End Sub + Private Function GetCncFileName( bAskSave As Boolean, ByRef sCncFile As String, ByRef sInfo As String) As Boolean + ' Recupero e verifico la path del progetto corrente + Dim sCurrFilePath As String = String.Empty + EgtGetCurrFilePath(sCurrFilePath) + If bAskSave Then + If String.IsNullOrEmpty(sCurrFilePath) OrElse EgtGetModified() Then + ' Il progetto deve essere salvato prima di poter essere generato. Vuoi farlo ? + If MessageBox.Show(EgtMsg(MSG_SIMULATION + 31), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then + ' Abbandono + Return False + Else + ' Lancio salvataggio + Application.Msn.NotifyColleagues(Application.SAVEPROJECT) + ' Se non salvato, abbandono + If EgtGetModified() Then Return False + ' Aggiorno path + EgtGetCurrFilePath(sCurrFilePath) + End If + End If + End If + sCncFile = "" + sInfo = "EgtCAM5 - " & sCurrFilePath + If EgtGetInfo( EgtGetCurrMachGroup(), KEY_MCHGRP_NCNAME, sCncFile) AndAlso Not String.IsNullOrWhiteSpace( sCncFile) then + sCncFile = Path.GetDirectoryName (sCurrFilePath) & "\" & sCncFile + else + sCncFile = Path.ChangeExtension(sCurrFilePath, Nothing) + If IniFile.m_bMachiningGroup Then + Dim sMGrpName As String = String.Empty + If EgtGetMachGroupName(EgtGetCurrMachGroup(), sMGrpName) Then + sCncFile &= "_" & sMGrpName & ".cnc" + sInfo &= "-" & sMGrpName + End If + Else + sCncFile &= ".cnc" + End If + End if + Return True + End Function + Private Function GetEstimationFileName(bAskSave As Boolean, ByRef sEstFile As String, ByRef sInfo As String) As Boolean Dim bOk As Boolean = True ' Recupero e verifico la path del progetto corrente