diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index a75316b..43eba05 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -335,6 +335,7 @@ Module ConstIni Public Const K_DC_FLATT_HEADSIDE As String = "FlattHeadSide" Public Const K_DC_FLATT_MACHTYPE As String = "FlattMachType" Public Const K_DC_FLATT_ROTLOCK As String = "FlattRotLock" + Public Const K_DC_FLAT_CHAINEDPATH As String = "ChainedPath" Public Const K_DC_FLATT_POSX As String = "FlattPosX" Public Const K_DC_FLATT_POSY As String = "FlattPosY" Public Const K_DC_POLISH_NAME As String = "PolishName" diff --git a/Constants/ConstMachIni.vb b/Constants/ConstMachIni.vb index 6d13942..fa48417 100644 --- a/Constants/ConstMachIni.vb +++ b/Constants/ConstMachIni.vb @@ -230,6 +230,7 @@ Public Const K_MACH_MILLING_ON_SINKS As String = "MillingOnSinks" Public Const K_MACH_MILLING_SHORTENING As String = "MillingShortening" Public Const K_MACH_ENGRAVING_WITHMILL As String = "EngravingWithMill" + Public Const K_MACH_STARTCENERTOOLPATH As String = "StartCenterToolPath" Public Const K_MACH_ENGRAVING_DEPTH As String = "EngravingDepth" Public Const K_MACH_ENGRAVING_WIDTH As String = "EngravingWidth" Public Const K_MACH_NEST_ALIGNED As String = "Aligned" diff --git a/DirectCuts/FlatteningCut.xaml b/DirectCuts/FlatteningCut.xaml index fa76b8c..081cd1f 100644 --- a/DirectCuts/FlatteningCut.xaml +++ b/DirectCuts/FlatteningCut.xaml @@ -7,142 +7,185 @@ mc:Ignorable="d" d:DesignHeight="597.3" d:DesignWidth="256"> - - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - + + - - - + + - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + diff --git a/DirectCuts/FlatteningCut.xaml.vb b/DirectCuts/FlatteningCut.xaml.vb index b6350df..acbf87b 100644 --- a/DirectCuts/FlatteningCut.xaml.vb +++ b/DirectCuts/FlatteningCut.xaml.vb @@ -37,6 +37,8 @@ Public Class FlatteningCut Private m_bHeadSide As Boolean = False Private m_nMachType As Integer = 1 Private m_bRotLock As Boolean = False + Private m_bChainedPath As Boolean = True + Private m_nTool As Integer = 0 ' Array delle modalità di acquisizione dei punti Private m_PointsModeArray(2) As String ' Array delle tipologia di lavorazione della spianatura @@ -45,6 +47,8 @@ Public Class FlatteningCut Private m_ptPrev As Point3d ' Layer per crocette temporanee Private m_nTempLay As Integer = GDB_ID.NULL + ' Array degliutensili disponibili (lama e fresa) + Private m_ToolsArray(1) As String ' Costanti Private Const MAX_TAB_DEPTH As Double = 10.0 @@ -69,6 +73,11 @@ Public Class FlatteningCut Right End Enum + Private Enum TOOL As Integer + SAW = 0 + MILL = 1 + End Enum + ' Per abilitare la spianatura con la FRESA deve essere imposatato a TRUE il flag "Usa Fresa" nella pagina MACCHINA (campo INCISIONI) Private Sub FlatteningCut_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized ' Creo lista modalità di acquisizione punto @@ -94,8 +103,13 @@ Public Class FlatteningCut ZReleasedTxBl.Text = "Z Svincolo" SideTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 23) RotLockTxBl.Text = EgtMsg(MSG_DIRECTCUTPAGEUC + 29) + ChainedPathTxBl.Text = "Chained path" SimulBtn.ToolTip = EgtMsg(MSG_CADCUTPAGEUC + 1) OkBtn.ToolTip = EgtMsg(MSG_DIRECTCUTPAGEUC + 30) + ' tipo di utensile in uso per la lavorazione + m_ToolsArray(TOOL.SAW) = EgtMsg(MSG_DIRECTCUTPAGEUC + 24) + m_ToolsArray(TOOL.MILL) = "Mill" + SelToolCmBx.ItemsSource = m_ToolsArray ' Carico i dati dell'ultimo taglio m_dDepth = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_FLATT_DEPTH, m_dDepth, m_MainWindow.GetIniFile()) m_dAngO = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_FLATT_ANGH, m_dAngO, m_MainWindow.GetIniFile()) @@ -106,6 +120,8 @@ Public Class FlatteningCut m_bHeadSide = (GetPrivateProfileInt(S_DIRECTCUTS, K_DC_FLATT_HEADSIDE, 0, m_MainWindow.GetIniFile()) <> 0) m_nMachType = GetPrivateProfileInt(S_DIRECTCUTS, K_DC_FLATT_MACHTYPE, m_nMachType, m_MainWindow.GetIniFile()) m_bRotLock = (GetPrivateProfileInt(S_DIRECTCUTS, K_DC_FLATT_ROTLOCK, 0, m_MainWindow.GetIniFile()) <> 0) + m_bChainedPath = (GetPrivateProfileInt(S_DIRECTCUTS, K_DC_FLAT_CHAINEDPATH, 0, m_MainWindow.GetIniFile()) <> 0) + m_nTool = GetPrivateProfileInt(S_MACH_NEST, K_MACH_ENGRAVING_WITHMILL, 1, m_MainWindow.GetMachIniFile()) m_ptTipP1.x = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_FLATT_POSX, m_ptTipP1.x, m_MainWindow.GetIniFile()) m_ptTipP1.y = GetPrivateProfileDouble(S_DIRECTCUTS, K_DC_FLATT_POSY, m_ptTipP1.y, m_MainWindow.GetIniFile()) End Sub @@ -167,6 +183,9 @@ Public Class FlatteningCut SideChBx.IsChecked = m_bHeadSide TypeCmBx.SelectedIndex = m_nMachType RotLockChBx.IsChecked = m_bRotLock + ChainedPathChBx.IsChecked = m_bChainedPath + ' Assegno l'utensile in definito in macchina per la fresatura + SelToolCmBx.SelectedIndex = m_nTool ' Reset taglio e disabilito bottone esecuzione m_bCutOk = False UpdateSimulOkBtn() @@ -550,6 +569,16 @@ Public Class FlatteningCut EgtDraw() End Sub + Private Sub SelToolCmBx_SelectionChanged(sender As Object, e As EventArgs) Handles SelToolCmBx.SelectionChanged + m_nTool = SelToolCmBx.SelectedIndex + ' Disabilito il concatenamento + ChainedPathChBx.IsEnabled = (m_nTool = TOOL.MILL) + ' Disegno il taglio + CreateFlatteningCut() + SetMachineInCurrPos() + EgtDraw() + End Sub + Private Sub RotLockChBx_Click(sender As Object, e As EventArgs) Handles RotLockChBx.Click m_bRotLock = RotLockChBx.IsChecked ' Disegno il taglio @@ -558,6 +587,14 @@ Public Class FlatteningCut EgtDraw() End Sub + Private Sub ChainedPathChBx_Click(sender As Object, e As EventArgs) Handles ChainedPathChBx.Click + m_bChainedPath = ChainedPathChBx.IsChecked + ' Disegno il taglio + CreateFlatteningCut() + SetMachineInCurrPos() + EgtDraw() + End Sub + Private Sub XcoordTxBx_EgtClosed(sender As Object, e As EventArgs) Handles XcoordTxBx.EgtClosed ' Recupero il valore della coordinata (in 0 Tab) Dim dXcoord As Double = 0 @@ -648,10 +685,12 @@ Public Class FlatteningCut ' ricavo l'ingombro di lavorazione in funzione dell'utensile selezionato Private Function GetFootPrintTool() As Double ' vedere nella pagina Allarm il capito "Incisioni" - Dim bForceUseMill As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_ENGRAVING_WITHMILL, 1, m_MainWindow.GetMachIniFile()) <> 0) + Dim bForceUseMill As Boolean = (m_nTool = TOOL.MILL) Dim dFootPrint As Double = 0 ' verifico quale lavorazione è attiva If Not String.IsNullOrEmpty(m_MainWindow.m_CurrentMachine.sCurrSawing) AndAlso Not bForceUseMill Then + Dim bSetTool As Boolean = EgtTdbSetCurrTool(m_MainWindow.m_CurrentMachine.sCurrSaw) + If Not bSetTool Then EgtOutLog("Erro nel settaggio utensile lama " & m_MainWindow.m_CurrentMachine.sCurrSaw) EgtTdbGetCurrToolParam(MCH_TP.THICK, dFootPrint) ElseIf Not String.IsNullOrEmpty(m_MainWindow.m_CurrentMachine.sCurrMilling) Then Dim sCurrMill = m_MainWindow.m_CurrentMachine.sCurrMill @@ -689,12 +728,16 @@ Public Class FlatteningCut EgtSetInfo(nCutId, INFO_DIRECTCUT, 1) ' Imposto affondamento e angolo di fianco sul taglio EgtSetInfo(nCutId, INFO_DEPTH, m_dDepth) - If (GetPrivateProfileInt(S_MACH_NEST, K_MACH_ENGRAVING_WITHMILL, 1, m_MainWindow.GetMachIniFile()) <> 0) Then + If (m_nTool = TOOL.MILL) Then EgtSetInfo(nCutId, INFO_WIDTH, GetFootPrintTool) End If EgtSetInfo(nCutId, INFO_SIDE_ANGLE, 0) ' Imposto prima direzione EgtSetInfo(nCutId, INFO_DIR, 1) + ' Imposto se iniziare la fresatura dal punto indicato + Dim bReducePath As Boolean = Not GetPrivateProfileInt(S_MACH_NEST, K_MACH_STARTCENERTOOLPATH, 0, m_MainWindow.GetMachIniFile()) <> 0 + If Not bReducePath Then EgtSetInfo(nCutId, INFO_STRICT, 0) + ' Eventuale bloccaggio rotazione asse C tra le passate If RotLockChBx.IsChecked Then EgtSetInfo(nCutId, INFO_ENABLE_INVERT, False) @@ -732,17 +775,17 @@ Public Class FlatteningCut End Function Private Function MultiplyCut(nLayerId As Integer, nCutId As Integer) As Boolean - 'If (GetPrivateProfileInt(S_MACH_NEST, K_MACH_ENGRAVING_WITHMILL, 1, m_MainWindow.GetMachIniFile()) <> 0) Then - ' EgtSetInfo(nCutId, INFO_WIDTH, GetFootPrintTool) - 'End If - - Dim CutsList As New List(Of Integer) - CutsList.Add(nCutId) + Dim bEngWithMill As Boolean = (m_nTool = TOOL.MILL) + Dim bReducePath As Boolean = Not GetPrivateProfileInt(S_MACH_NEST, K_MACH_STARTCENERTOOLPATH, 0, m_MainWindow.GetMachIniFile()) <> 0 ' Recupero spessore della lama (utensile) correntemente attiva Dim dThick As Double = GetFootPrintTool() If dThick = 0 Then Return False + ' Salvo la prima curva nella lista dei percorsi da concatenare + Dim CutsList As New List(Of Integer) + CutsList.Add(nCutId) + ' Imposto angolo di rotazione a seconda del lato dei tagli Dim dRotAngO As Double = If(SideChBx.IsChecked(), -90, 90) ' Definisco vettore di spostamento @@ -760,7 +803,10 @@ Public Class FlatteningCut If nStepNum > 1 Then dDelta = dWidth / (nStepNum - 1) End If + ' definisco la larghezza dell'utensile (solo per la fresa) EgtSetInfo(nCutId, INFO_WIDTH, dThick) + ' definisco il tipo di utensile da utilizzare + EgtSetInfo(nCutId, "EngravingWithMill", m_nTool) ' Creo vettore delta vtDelta *= dDelta ' Creo indice per impostare info che indica tipologia di spianatura @@ -770,6 +816,7 @@ Public Class FlatteningCut ' Creo copie Dim nCut2Id = EgtCopyGlob(nCutId, nLayerId) EgtSetInfo(nCut2Id, INFO_WIDTH, dThick) + EgtSetInfo(nCutId, "EngravingWithMill", m_nTool) ' Assegno info direzione a seconda del tipo di spianatura If TypeCmBx.SelectedIndex = MACH_TYPE.ZIGZAG Then If nTypeIndex = 1 Then @@ -784,38 +831,76 @@ Public Class FlatteningCut End If EgtMove(nCut2Id, vtPerpMove, GDB_RT.GLOB) - ' ----------------------- CONACTENO CURVE ----------------------- - CutsList.Add(nCut2Id) - ' ----------------------- CONACTENO CURVE ----------------------- + ' ----------------------- CREO SEGMENTI PER CONCATENAMENTO CURVE ----------------------- + If m_bChainedPath And bEngWithMill Then + If bReducePath Then + If Index < nStepNum - 1 Then + ExtendLenghtMillPath(nCut2Id, -dThick / 2) + ElseIf Index = nStepNum - 1 Then + If nStepNum Mod 2 = 0 Then + ExtendLenghtMillPath(nCut2Id, -dThick / 2, False, True) + Else + ExtendLenghtMillPath(nCut2Id, -dThick / 2, True, False) + End If + End If + End If + CutsList.Add(nCut2Id) + End If + ' ----------------------- CREO SEGMENTI PER CONCATENAMENTO CURVE ----------------------- Next - ' Decidere se accorciare i tagli del valore del raggio utensile! - For Index As Integer = 0 To CutsList.Count - 2 - If Index Mod 2 = 0 Then - ' Costruisco la linea di collegamento tra due curve adiacenti - Dim PtStart_1 As Point3d - EgtStartPoint(CutsList(Index), GDB_RT.GLOB, PtStart_1) - Dim PtStart_2 As Point3d - EgtStartPoint(CutsList(Index + 1), GDB_RT.GLOB, PtStart_2) - CutsList.Add(EgtCreateLine(nLayerId, PtStart_1, PtStart_2)) - Else - ' Costruisco la linea di collegamento tra due curve adiacenti - Dim PtStart_1 As Point3d - EgtEndPoint(CutsList(Index), GDB_RT.GLOB, PtStart_1) - Dim PtStart_2 As Point3d - EgtEndPoint(CutsList(Index + 1), GDB_RT.GLOB, PtStart_2) - CutsList.Add(EgtCreateLine(nLayerId, PtStart_1, PtStart_2)) + ' ----------------------- CREO UN UNICO PERCORSO CONCATENATO ----------------------- + If m_bChainedPath And bEngWithMill Then + ' Decidere se accorciare i tagli del valore del raggio utensile! + If bReducePath Then + ExtendLenghtMillPath(CutsList(0), -dThick / 2, False, True) End If - Next - Dim ptNear As Point3d - EgtStartPoint(CutsList(0), ptNear) - Dim x As Integer = EgtCreateCurveCompoByChain(nLayerId, CutsList.ToArray, ptNear, True) - EgtSetInfo(x, INFO_WIDTH, dThick) + For Index As Integer = 0 To CutsList.Count - 2 + If Index Mod 2 <> 0 Then + ' Costruisco la linea di collegamento tra due curve adiacenti + Dim PtStart_1 As Point3d + EgtStartPoint(CutsList(Index), GDB_RT.GLOB, PtStart_1) + Dim PtStart_2 As Point3d + EgtStartPoint(CutsList(Index + 1), GDB_RT.GLOB, PtStart_2) + CutsList.Add(EgtCreateLine(nLayerId, PtStart_1, PtStart_2)) + Else + ' Costruisco la linea di collegamento tra due curve adiacenti + Dim PtStart_1 As Point3d + EgtEndPoint(CutsList(Index), GDB_RT.GLOB, PtStart_1) + Dim PtStart_2 As Point3d + EgtEndPoint(CutsList(Index + 1), GDB_RT.GLOB, PtStart_2) + CutsList.Add(EgtCreateLine(nLayerId, PtStart_1, PtStart_2)) + End If + Next + Dim ptNear As Point3d + EgtStartPoint(CutsList(0), ptNear) + Dim IdJointCurv As Integer = EgtCreateCurveCompoByChain(nLayerId, CutsList.ToArray, ptNear, True) + EgtSetInfo(IdJointCurv, INFO_DIRECTCUT, 1) + EgtSetInfo(IdJointCurv, INFO_STEP_TYPE, m_nMachType) + EgtSetInfo(IdJointCurv, INFO_WIDTH, dThick) + ' Se unisco il percorso devo per forza usare la fresa! + EgtSetInfo(IdJointCurv, "EngravingWithMill", 1) + If Not bReducePath Then EgtSetInfo(IdJointCurv, INFO_STRICT, 0) + End If + ' ----------------------- CREO UN UNICO PERCORSO CONCATENATO ----------------------- Return True End Function + Private Sub ExtendLenghtMillPath(ByVal IdCurv As Integer, ByVal ReduceVal As Double, + ByVal Optional bStart As Boolean = True, ByVal Optional bEnd As Boolean = True) + Dim PtStart As Point3d + EgtStartPoint(IdCurv, GDB_RT.GLOB, PtStart) + Dim PtEnd As Point3d + EgtEndPoint(IdCurv, GDB_RT.GLOB, PtEnd) + If bStart Then EgtTrimExtendCurveByLen(IdCurv, ReduceVal, PtStart, GDB_RT.GLOB) + If bEnd Then EgtTrimExtendCurveByLen(IdCurv, ReduceVal, PtEnd, GDB_RT.GLOB) + Dim dLenLine As Double + EgtCurveLength(IdCurv, dLenLine) + EgtOutLog("Lunghezza segmento ridotto: " & dLenLine.ToString) + End Sub + Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean ' Aggiungo crocette Dim vtCrossX As New Vector3d(20, 0, 0)