daeaec3b6b
- correzioni a spianature con fresa (tagli diretti) - migliorie a foro singolo (tagli diretti).
514 lines
21 KiB
VB.net
514 lines
21 KiB
VB.net
Imports EgtUILib
|
|
Imports OmagCUT.MainWindow
|
|
|
|
Public Class SingleDrillUC
|
|
' Riferimenti a pagine
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
Private WithEvents m_CurrProjPage As CurrentProjectPageUC
|
|
' Flag di pagina attiva
|
|
Private m_bActive As Boolean = False
|
|
' Flag di simulazione in corso
|
|
Private m_bSimul As Boolean = False
|
|
|
|
' riferimento alla macchina corrente
|
|
Private m_CurrentMachine As CurrentMachine
|
|
|
|
' --------------------- VARIABILI PRESENTI NEL TAGLIO SINGOLO ---------------------
|
|
' Origine tavola e dati grezzo
|
|
Private m_bRawOk As Boolean = False
|
|
Private m_ptTabOri As Point3d
|
|
Private m_ptRawMin As Point3d
|
|
Private m_ptRawMax As Point3d
|
|
' Parametri P1 acquisito
|
|
Private m_bPointP1Ok As Boolean = False
|
|
Private m_ptTipP1 As Point3d
|
|
Private m_vtToolP1 As Vector3d
|
|
' Parametri P2 acquisito
|
|
Private m_bPointP2Ok As Boolean = False
|
|
Private m_ptTipP2 As Point3d
|
|
Private m_vtToolP2 As Vector3d
|
|
' Parametri della lavorazione
|
|
Private m_bCutOk As Boolean = False
|
|
|
|
' Array delle modalità di acquisizione dei punti
|
|
Private m_PointsModeArray(2) As String
|
|
' Punto selezionato nel disegno
|
|
Private m_ptPrev As Point3d
|
|
' Layer per crocette temporanee
|
|
Private m_nTempLay As Integer = GDB_ID.NULL
|
|
|
|
Private m_dDiameter As Double = 0
|
|
|
|
Private m_sCurrDrill As String = String.Empty
|
|
|
|
' Costanti
|
|
Private Const MAX_TAB_DEPTH As Double = 10.0
|
|
Private Const MIN_CUT_LEN As Double = 10.0
|
|
Private Const MAX_SIDE_ANG As Double = 60.0
|
|
' Costanti che indicano la modalità di acquisizione dei punti
|
|
Private Enum PT_MODE As Integer
|
|
DRILL = 0
|
|
LASER = 1
|
|
DRAW = 2
|
|
End Enum
|
|
|
|
Private Sub SingleCut_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
|
|
' Variabile che accorcia il riferimento alla macchina corrente
|
|
m_CurrentMachine = m_MainWindow.m_CurrentMachine
|
|
|
|
' Creo lista modalità di acquisizione punto
|
|
m_PointsModeArray(PT_MODE.DRILL) = EgtMsg(90752) ' Foretto
|
|
m_PointsModeArray(PT_MODE.LASER) = EgtMsg(90212) ' Laser
|
|
m_PointsModeArray(PT_MODE.DRAW) = EgtMsg(90225) ' Disegno
|
|
' la associo alla combobox
|
|
PointModeCmBx.ItemsSource = m_PointsModeArray
|
|
|
|
' Assegno messaggi
|
|
Point1Btn.ToolTip = EgtMsg(90210) ' Acquisici P1
|
|
SimulBtn.ToolTip = EgtMsg(90301) ' Simula
|
|
OkBtn.ToolTip = EgtMsg(90230) ' Esegui
|
|
End Sub
|
|
|
|
Private Sub SingleDrill_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
m_sCurrDrill = m_CurrentMachine.sCurrDrill
|
|
If String.IsNullOrWhiteSpace(m_sCurrDrill) Then m_sCurrDrill = GetDrillFromDrilling(m_CurrentMachine.sCurrDrilling)
|
|
' rimuovo utensile su uscite 1
|
|
EgtSetCalcTool("", "H1", 1)
|
|
' imposto utensile su uscita 2
|
|
EgtSetCalcTool(m_sCurrDrill, "H1", 2)
|
|
' recupero informazioni del foretto usato
|
|
EgtTdbSetCurrTool(m_sCurrDrill)
|
|
m_dDiameter = 0
|
|
EgtTdbGetCurrToolParam(MCH_TP.DIAM, m_dDiameter)
|
|
|
|
' Attivo la pagina
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
m_bActive = True
|
|
' Se rientro da simulazione
|
|
If m_bSimul Then
|
|
m_bSimul = False
|
|
' Disabilito registrazione progetto modificato
|
|
EgtDisableModified()
|
|
' Aggiorno visualizzazione
|
|
SetMachineInCurrPos()
|
|
m_MainWindow.m_DirectCutPageUC.m_bShowMachine = True
|
|
EgtSetMachineLook(m_MainWindow.m_DirectCutPageUC.m_nMachLook)
|
|
EgtDraw()
|
|
Return
|
|
End If
|
|
' Disabilito registrazione progetto modificato
|
|
EgtDisableModified()
|
|
' Creo layer temporaneo per crocette
|
|
m_nTempLay = EgtCreateGroup(GDB_ID.ROOT)
|
|
EgtSetLevel(m_nTempLay, GDB_LV.TEMP)
|
|
' Origine tavola
|
|
m_bRawOk = True
|
|
If Not EgtGetTableRef(1, m_ptTabOri) Then
|
|
m_bRawOk = False
|
|
EgtOutLog("Error on TableRef1")
|
|
End If
|
|
' Dati del grezzo
|
|
If Not GetRawBox(m_ptRawMin, m_ptRawMax) Then
|
|
m_bRawOk = False
|
|
EgtOutLog("Error on RawBox")
|
|
End If
|
|
' Reset punto acquisito
|
|
m_bPointP1Ok = False
|
|
m_bPointP2Ok = False
|
|
' Inizializzo primo punto acquisito dal disegno
|
|
m_ptPrev = m_ptTipP1 + (m_ptTabOri - Point3d.ORIG())
|
|
m_ptPrev.z = m_ptRawMax.z
|
|
' Disegno crocetta che indica il punto acquisito
|
|
CreateCross(m_nTempLay, m_ptPrev)
|
|
' Imposto modalità di acquisizione punti
|
|
PointModeCmBx.SelectedIndex = PT_MODE.DRAW
|
|
SetCoordVisibility(True)
|
|
ShowCoord()
|
|
' Reset taglio e disabilito bottone esecuzione
|
|
m_bCutOk = False
|
|
UpdateSimulOkBtn()
|
|
' Deseleziono bottone primo punto
|
|
Point1Btn.IsChecked = False
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
' esco dalla pagina di foro diretto
|
|
Friend Sub SingleCut_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded
|
|
WritePrivateProfileString(S_DIRECTCUTS, K_DC_SING_POSX, DoubleToString(m_ptTipP1.x, 2), m_MainWindow.GetIniFile())
|
|
WritePrivateProfileString(S_DIRECTCUTS, K_DC_SING_POSY, DoubleToString(m_ptTipP1.y, 2), m_MainWindow.GetIniFile())
|
|
' Se non vado in simulazione
|
|
If Not m_bSimul Then
|
|
' Dichiaro sottopagina da non riattivare
|
|
m_MainWindow.m_DirectCutPageUC.m_ControlsDirectCutUC.m_ActiveDirectCutPage = ControlsDirectCutUC.DirectCutPages.DirectCut
|
|
' Rimuovo layer temporaneo per crocette
|
|
EgtErase(m_nTempLay)
|
|
' Rimuovo eventuale pezzo per taglio diretto
|
|
EraseDirectCutPart()
|
|
' Riattivo eventuali lavorazioni presenti
|
|
ActivateAllMachinings()
|
|
' Abilito registrazione progetto modificato
|
|
EgtEnableModified()
|
|
' Nascondo la macchina
|
|
m_MainWindow.m_DirectCutPageUC.m_bShowMachine = False
|
|
EgtSetMachineLook(MCH_LOOK.TAB)
|
|
EgtDraw()
|
|
End If
|
|
' Dichiaro pagina non attiva
|
|
m_bActive = False
|
|
End Sub
|
|
|
|
Private Sub UpdateSimulOkBtn()
|
|
If m_bCutOk Then
|
|
SimulBtn.IsEnabled = True
|
|
SimulBtn.Foreground = Brushes.Black
|
|
OkBtn.IsEnabled = True
|
|
OkBtn.Foreground = Brushes.Black
|
|
Else
|
|
SimulBtn.IsEnabled = False
|
|
SimulBtn.Foreground = Brushes.DarkGray
|
|
OkBtn.IsEnabled = False
|
|
OkBtn.Foreground = Brushes.DarkGray
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles m_CurrProjPage.OnMouseDownScene
|
|
' deselezione il bottone per acquisizione
|
|
Point1Btn.IsChecked = False
|
|
' Verifico di essere il gestore attivo
|
|
If Not m_bActive Then Return
|
|
' Si può selezionare solo con il tasto sinistro e se stato NULL
|
|
If e.Button <> Windows.Forms.MouseButtons.Left Or
|
|
Not m_CurrProjPage.CurrentProjectScene.IsStatusNull() Then
|
|
Return
|
|
End If
|
|
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
|
|
EgtEmptyGroup(m_nTempLay)
|
|
' Acquisisco punto da disegno
|
|
EgtUnProjectPoint(e.Location, m_ptPrev)
|
|
' Aggiusto Z punto acquisito (è in globale)
|
|
Dim dPtPrevZ As Double = m_ptPrev.z
|
|
m_ptPrev.z = m_ptRawMax.z
|
|
' Se direzione di vista calcolabile e da sopra posso aggiustare anche XY
|
|
Dim dAngVertDeg, dAngHorizDeg As Double
|
|
If EgtGetGenericView(dAngVertDeg, dAngHorizDeg) Then
|
|
Dim vtDir As Vector3d = Vector3d.FromSpherical(1, dAngVertDeg, dAngHorizDeg)
|
|
If vtDir.z > EPS_SMALL Then
|
|
m_ptPrev.z = dPtPrevZ
|
|
m_ptPrev += vtDir * (m_ptRawMax.z - m_ptPrev.z) / vtDir.z
|
|
End If
|
|
End If
|
|
' Visualizzo coordinate (rispetto a 0 tavola)
|
|
ShowCoord()
|
|
' Disegno crocetta che indica il punto acquisito
|
|
CreateCross(m_nTempLay, m_ptPrev)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub PointModeCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles PointModeCmBx.SelectionChanged
|
|
SetCoordVisibility(PointModeCmBx.SelectedIndex = PT_MODE.DRAW)
|
|
End Sub
|
|
|
|
Private Sub Point1Btn_Click(sender As Object, e As RoutedEventArgs) Handles Point1Btn.Click
|
|
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
|
|
EgtEmptyGroup(m_nTempLay)
|
|
' Reset punto non acquisito
|
|
m_bPointP1Ok = False
|
|
' Verifico configurazione tavola e grezzo
|
|
If Not m_bRawOk Then Return
|
|
|
|
' forzo utilizzo testa H1 solo per macchina con 2 teste
|
|
Dim bIsMultiCut As Boolean = (EgtGetHeadId("H101") <> GDB_ID.NULL)
|
|
' Ricavo dati lama corrente
|
|
Dim sDrill As String = m_sCurrDrill
|
|
If bIsMultiCut Then
|
|
EgtSetCalcTool(sDrill, "H1", 2)
|
|
End If
|
|
|
|
' Se acquisizione lama o laser
|
|
If PointModeCmBx.SelectedIndex = PT_MODE.DRILL Or PointModeCmBx.SelectedIndex = PT_MODE.LASER Then
|
|
|
|
' Recupero la posizione macchina
|
|
Dim dL1, dL2, dL3, dR1, dR2 As Double
|
|
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then Return
|
|
' Se macchina multicut il primo asse rotante restituito è quello della tavola
|
|
Dim vAng() As Double = {dR1, dR2, 0}
|
|
If bIsMultiCut Then
|
|
vAng(0) = 0
|
|
vAng(1) = dR1
|
|
vAng(2) = dR2
|
|
End If
|
|
' Se punto da laser
|
|
If PointModeCmBx.SelectedIndex = PT_MODE.LASER Then
|
|
' Imposto come testa corrente il laser (senza utensile ovviamente)
|
|
If Not EgtSetCalcTool("", "H3", 1) Then Return
|
|
' Trasformo in posizione punta utensile in basso
|
|
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, vAng, True, m_ptTipP1) Then Return
|
|
' Ora imposto la lama corrente
|
|
If Not EgtSetCalcTool(sDrill, "H1", 2) Then Return
|
|
' Altrimenti da lama
|
|
Else
|
|
' Imposto la lama corrente
|
|
If Not EgtSetCalcTool(sDrill, "H1", 2) Then Return
|
|
' Trasformo in posizione punta utensile in basso
|
|
If Not EgtGetCalcTipFromPositions(dL1, dL2, dL3, vAng, True, m_ptTipP1) Then Return
|
|
End If
|
|
' Calcolo direzione asse lama
|
|
If Not EgtGetCalcToolDirFromAngles(vAng, m_vtToolP1) Then Return
|
|
' Porto il tip nell'origine tavola
|
|
m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri))
|
|
m_bPointP1Ok = True
|
|
|
|
' Altrimenti punto da click di mouse
|
|
Else
|
|
' Assegno punto selezionato nel disegno a m_ptTipP1
|
|
m_ptTipP1 = m_ptPrev
|
|
' Porto il tip nell'origine tavola
|
|
m_ptTipP1.ToLoc(New Frame3d(m_ptTabOri))
|
|
m_bPointP1Ok = True
|
|
' Imposto la lama corrente
|
|
If Not EgtSetCalcTool(sDrill, "H1", 2) Then Return
|
|
End If
|
|
|
|
' Disegno il taglio
|
|
CreateSingleDrill()
|
|
' Disegno la macchina nella sua posizione reale
|
|
SetMachineInCurrPos()
|
|
m_MainWindow.m_DirectCutPageUC.m_bShowMachine = True
|
|
EgtSetMachineLook(m_MainWindow.m_DirectCutPageUC.m_nMachLook)
|
|
EgtDraw()
|
|
' Seleziono il bottone per indicare che il primo punto è stato acquisito
|
|
Point1Btn.IsChecked = True
|
|
End Sub
|
|
|
|
'Private Sub GetDrillFromDrilling(ByRef sCurrDrill As String)
|
|
' If String.IsNullOrEmpty(sCurrDrill) Or String.IsNullOrWhiteSpace(sCurrDrill) Then
|
|
' ' creo l'elenco degli utensili di foratura
|
|
' Dim sToolName As String = String.Empty
|
|
' Dim nType As Integer = MCH_TY.NONE
|
|
' Dim DrillToolList As New ObservableCollection(Of String)
|
|
' DrillToolList.Clear()
|
|
' If EgtTdbGetFirstTool(MCH_TF.DRILLBIT, sToolName, nType) Then
|
|
' DrillToolList.Add(sToolName)
|
|
' While EgtTdbGetNextTool(MCH_TF.DRILLBIT, sToolName, nType)
|
|
' DrillToolList.Add(sToolName)
|
|
' End While
|
|
' End If
|
|
' ' recupero l'utensile associato alla lavorazione
|
|
' Dim sCurrDrilling As String = m_MainWindow.m_CurrentMachine.sCurrDrilling
|
|
' Dim ToolString As String = String.Empty
|
|
' EgtMdbSetCurrMachining(sCurrDrilling)
|
|
' ' Recupero nome utensile tramite TUUID
|
|
' Dim sTuuid As String = String.Empty
|
|
' EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTuuid)
|
|
' EgtTdbGetToolFromUUID(sTuuid, ToolString)
|
|
' Dim bToolExist As Boolean = False
|
|
' For Each CurrTool As IEnumerable In DrillToolList
|
|
' If CurrTool.ToString() = ToolString Then
|
|
' bToolExist = True
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
' If bToolExist Then
|
|
' sCurrDrill = ToolString
|
|
' Else
|
|
' sCurrDrill = String.Empty
|
|
' End If
|
|
' End If
|
|
'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
|
|
StringToLen(XcoordTxBx.Text, dXcoord)
|
|
XcoordTxBx.Text = LenToString(dXcoord, 2)
|
|
' lo assegno al punto corrente (in 0 Macc)
|
|
m_ptPrev.x = dXcoord + m_ptTabOri.x
|
|
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
|
|
EgtEmptyGroup(m_nTempLay)
|
|
' Disegno crocetta che indica il punto acquisito
|
|
CreateCross(m_nTempLay, m_ptPrev)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub YcoordTxBx_EgtClosed(sender As Object, e As EventArgs) Handles YcoordTxBx.EgtClosed
|
|
' Recupero il valore della coordinata (in 0 Tab)
|
|
Dim dYcoord As Double = 0
|
|
StringToLen(YcoordTxBx.Text, dYcoord)
|
|
YcoordTxBx.Text = LenToString(dYcoord, 2)
|
|
' lo assegno al punto corrente (in 0 Macc)
|
|
m_ptPrev.y = dYcoord + m_ptTabOri.y
|
|
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
|
|
EgtEmptyGroup(m_nTempLay)
|
|
' Disegno crocetta che indica il punto acquisito
|
|
CreateCross(m_nTempLay, m_ptPrev)
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub SimulBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulBtn.Click
|
|
' Verifico ci sia un taglio valido
|
|
If Not m_bCutOk Then Return
|
|
' Salvo il progetto con le lavorazioni
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge"
|
|
m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False)
|
|
' Predispongo passaggio a simulazione
|
|
m_bSimul = True
|
|
m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_DirectCutPageUC.m_ControlsDirectCutUC.LeftButtonGrid.Children.Remove(Me)
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_DirectCutPageUC)
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.DirectCut
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation
|
|
End Sub
|
|
|
|
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
|
|
#If TRIAL Then
|
|
m_CurrProjPage.SetWarningMessage( "Trial Version")
|
|
#Else
|
|
' Verifico non sia versione Ufficio
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.OFFICE_TYPE) Then
|
|
m_CurrProjPage.SetWarningMessage("Office Version")
|
|
Return
|
|
End If
|
|
' Verifico ci sia un taglio valido
|
|
If Not m_bCutOk Then Return
|
|
' Salvo il progetto con le lavorazioni
|
|
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\" & "DirectProj.nge"
|
|
m_MainWindow.m_CurrentProjectPageUC.SaveFile(sMchPath, False)
|
|
' Genero file CNC (lancio anche se errore in precedenza)
|
|
Dim sCncPath As String = m_MainWindow.GetCncDir() & "\DirectCut" & m_MainWindow.m_CurrentMachine.sIsoFileExt
|
|
Dim bOk As Boolean = EgtGenerate(sCncPath, "OmagCut ver." & m_MainWindow.GetVersion())
|
|
' Se errore in generazione, segnalo l'errore ed esco
|
|
If Not bOk Then
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90314)) 'Errore nella generazione del programma CN
|
|
Return
|
|
End If
|
|
Dim sNameProg As Integer = 900
|
|
sNameProg = GetPrivateProfileInt(S_PARTPROGRAM, "NameProg", sNameProg, m_MainWindow.GetMachIniFile)
|
|
' Download programma (eventuali errori sono segnalati dalla funzione)
|
|
If m_MainWindow.m_CNCommunication.SendProgram(sCncPath, sNameProg) Then
|
|
' copio il progetto corrente come progetto in lavorazione
|
|
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj.nge"
|
|
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
|
|
' lancio eventuale lua post-trasmissione
|
|
m_MainWindow.ExecSentProgScript(True)
|
|
End If
|
|
#End If
|
|
End Sub
|
|
|
|
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
|
|
m_MainWindow.m_DirectCutPageUC.m_ControlsDirectCutUC.LeftButtonGrid.Children.Remove(Me)
|
|
End Sub
|
|
|
|
Private Function CreateSingleDrill() As Boolean
|
|
' Verifico sia definito il punto iniziale e il grezzo
|
|
If Not m_bPointP1Ok Or Not m_bRawOk Then
|
|
m_bCutOk = False
|
|
Return False
|
|
End If
|
|
' Rimuovo eventuali crocette create acquisendo i punti nel disegno
|
|
EgtEmptyGroup(m_nTempLay)
|
|
' Spessore grezzo
|
|
Dim dRawHeight As Double = m_ptRawMax.z - m_ptRawMin.z
|
|
' Recupero diametro foretto corrente
|
|
Dim sDrill As String = m_sCurrDrill
|
|
If String.IsNullOrWhiteSpace( sDrill) Then sDrill = GetDrillFromDrilling(m_MainWindow.m_CurrentMachine.sCurrDrilling)
|
|
EgtTdbSetCurrTool(sDrill)
|
|
m_dDiameter = 0
|
|
EgtTdbGetCurrToolParam(MCH_TP.DIAM, m_dDiameter)
|
|
' Rimuovo eventuale vecchio pezzo per taglio diretto
|
|
EraseDirectCutPart()
|
|
' Disattivo eventuali lavorazioni presenti
|
|
DeactivateAllMachinings()
|
|
|
|
' Creo nuovo pezzo per il taglio diretto
|
|
Dim nPartId As Integer = CreateDirectCutPart()
|
|
Dim nLayerId As Integer = EgtCreateGroup(nPartId)
|
|
EgtSetName(nLayerId, NAME_INLOOP)
|
|
' Creo il Drill
|
|
Dim ptStart As Point3d = m_ptTipP1
|
|
ptStart.z = 0
|
|
|
|
' Creo layer per crocetta di riferimento
|
|
Dim nCrossLayerId As Integer = EgtCreateGroup(nPartId)
|
|
' Aggiungo crocetta/e
|
|
If m_bPointP1Ok Then
|
|
CreateCross(nCrossLayerId, ptStart)
|
|
End If
|
|
|
|
Dim nCutId = EgtCreateCircle(nLayerId, ptStart, m_dDiameter / 2)
|
|
' Indico che è un taglio Diretto di tipo SingleDrill
|
|
EgtSetInfo(nCutId, INFO_DIRECTCUT, FlagDirectCuts.SingleDrill)
|
|
' Calcolo punto di inserimento nel grezzo
|
|
Dim ptMin, ptMax As Point3d
|
|
EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, ptMin, ptMax)
|
|
Dim ptIns As Point3d = ptMin + (m_ptTabOri - m_ptRawMin)
|
|
ptIns.z = dRawHeight
|
|
' Inserisco il pezzo nel grezzo
|
|
EgtAddPartToRawPart(nPartId, ptIns, m_MainWindow.m_CurrentProjectPageUC.m_nRawId)
|
|
EgtSetCurrPhase(1)
|
|
' Inserisco la lavorazione
|
|
m_bCutOk = AddMachinings(nPartId) AndAlso UpdateAllMachiningsToolpaths()
|
|
' Eventuale eliminazione Home finale
|
|
If Not m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome Then
|
|
RemoveFinalHome()
|
|
End If
|
|
UpdateSimulOkBtn()
|
|
Return m_bCutOk
|
|
End Function
|
|
|
|
' crea una croce nel punto indicato e rappresenta il diametro dell'utensile corrente
|
|
Private Function CreateCross(nLayerId As Integer, ptP As Point3d) As Boolean
|
|
' Aggiungo crocette
|
|
ptP += New Vector3d(0, 0, 0.15)
|
|
Dim vtCrossX As New Vector3d(20, 0, 0)
|
|
Dim vtCrossY As New Vector3d(0, 20, 0)
|
|
Dim nCrossId1 = EgtCreateLine(nLayerId, ptP + (-vtCrossX), ptP + vtCrossX)
|
|
EgtSetColor(nCrossId1, New Color3d(255, 0, 0))
|
|
Dim nCrossId2 = EgtCreateLine(nLayerId, ptP + (-vtCrossY), ptP + vtCrossY)
|
|
EgtSetColor(nCrossId2, New Color3d(255, 0, 0))
|
|
Dim nPntId = EgtCreateGeoPoint(nLayerId, ptP)
|
|
EgtSetColor(nPntId, New Color3d(255, 0, 0))
|
|
Dim nCirleId = EgtCreateCircle(nLayerId, ptP, m_dDiameter / 2)
|
|
EgtSetColor(nCirleId, New Color3d(0, 255, 0))
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub SetCoordVisibility(bShow As Boolean)
|
|
XcoordTxBl.Visibility = If(bShow, Windows.Visibility.Visible, Windows.Visibility.Hidden)
|
|
XcoordTxBx.Visibility = If(bShow, Windows.Visibility.Visible, Windows.Visibility.Hidden)
|
|
YcoordTxBl.Visibility = If(bShow, Windows.Visibility.Visible, Windows.Visibility.Hidden)
|
|
YcoordTxBx.Visibility = If(bShow, Windows.Visibility.Visible, Windows.Visibility.Hidden)
|
|
End Sub
|
|
|
|
Private Sub ShowCoord()
|
|
Dim ptText As Point3d = m_ptPrev
|
|
ptText.ToLoc(New Frame3d(m_ptTabOri))
|
|
XcoordTxBx.Text = LenToString(ptText.x, 2)
|
|
YcoordTxBx.Text = LenToString(ptText.y, 2)
|
|
End Sub
|
|
|
|
Private Function SetMachineInCurrPos() As Boolean
|
|
' Recupero la posizione macchina
|
|
Dim dL1, dL2, dL3, dR1, dR2 As Double
|
|
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then Return False
|
|
' Recupero il nome degli assi macchina
|
|
Dim sL1 As String = String.Empty
|
|
Dim sL2 As String = String.Empty
|
|
Dim sL3 As String = String.Empty
|
|
Dim sR1 As String = String.Empty
|
|
Dim sR2 As String = String.Empty
|
|
If Not m_MainWindow.m_CNCommunication.GetAxesNames(sL1, sL2, sL3, sR1, sR2) Then Return False
|
|
' Visualizzo macchina in posizione
|
|
EgtSetAxisPos(sL1, dL1)
|
|
EgtSetAxisPos(sL2, dL2)
|
|
EgtSetAxisPos(sL3, dL3)
|
|
EgtSetAxisPos(sR1, dR1)
|
|
EgtSetAxisPos(sR2, dR2)
|
|
Return True
|
|
End Function
|
|
|
|
End Class |