0e540997f2
- corretta gestione nomi utensili in lavorazione dopo cambio del nome stesso in utensile - migliorata gestione dialogo import file - migliorata visualizzazione angoli dei profili dei lati sui pezzi.
812 lines
35 KiB
VB.net
812 lines
35 KiB
VB.net
Imports EgtUILib
|
|
|
|
Friend Module CamAuto
|
|
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
|
|
Friend Function AddMachinings(nPartId As Integer, bPreview As Boolean, bToolpath As Boolean) As Boolean
|
|
EgtLuaCreateGlobTable("CAM")
|
|
SetLuaStandardCamParams()
|
|
EgtLuaSetGlobIntVar("CAM.PARTID", nPartId)
|
|
EgtLuaSetGlobBoolVar("CAM.PREVIEW", bPreview)
|
|
EgtLuaSetGlobBoolVar("CAM.TOOLPATH", bToolpath)
|
|
Dim nErr As Integer = 999
|
|
Dim bOk As Boolean = EgtLuaExecFile(m_MainWindow.GetCamAutoDir() & "\CamAuto.lua")
|
|
bOk = bOk AndAlso EgtLuaGetGlobIntVar("CAM.ERR", nErr) AndAlso nErr = 0
|
|
bOk = bOk AndAlso EgtLuaCallFunction("CAM.Add")
|
|
EgtLuaGetGlobIntVar("CAM.ERR", nErr)
|
|
EgtLuaResetGlobVar("CAM")
|
|
If nErr <> 0 Then
|
|
bOk = False
|
|
EgtOutLog("Error in CamAuto : " & nErr.ToString())
|
|
End If
|
|
m_MainWindow.m_CurrentProjectPageUC.ResetOrderMachiningFlag()
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function EraseMachinings(nPartId As Integer) As Boolean
|
|
EgtLuaCreateGlobTable("CAM")
|
|
EgtLuaSetGlobIntVar("CAM.PARTID", nPartId)
|
|
Dim nErr As Integer = 999
|
|
Dim bOk As Boolean = EgtLuaExecFile(m_MainWindow.GetCamAutoDir() & "\CamAuto.lua")
|
|
bOk = bOk AndAlso EgtLuaGetGlobIntVar("CAM.ERR", nErr) AndAlso nErr = 0
|
|
bOk = bOk AndAlso EgtLuaCallFunction("CAM.Erase")
|
|
EgtLuaGetGlobIntVar("CAM.ERR", nErr)
|
|
EgtLuaResetGlobVar("CAM")
|
|
If nErr <> 0 Then
|
|
bOk = False
|
|
EgtOutLog("Error in CamAuto : " & nErr.ToString())
|
|
End If
|
|
m_MainWindow.m_CurrentProjectPageUC.ResetOrderMachiningFlag()
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function ResetAllMachinings() As Boolean
|
|
' Cancello tutte le lavorazioni
|
|
EraseMachinings(GDB_ID.NULL)
|
|
' Se progetto con pezzi piani
|
|
Dim nPrjType As Integer = m_MainWindow.m_CurrentProjectPageUC.GetCurrentProjectType()
|
|
If nPrjType = CurrentProjectPageUC.PRJ_TYPE.FLATS Then
|
|
' Reinserisco tutte le lavorazioni piane
|
|
AddMachinings(GDB_ID.NULL, True, False)
|
|
' Se altrimenti progetto con cornici
|
|
ElseIf nPrjType = CurrentProjectPageUC.PRJ_TYPE.FRAMES Then
|
|
' Reinserisco tutte le lavorazioni delle cornici
|
|
AddFrameMachinings(m_MainWindow.m_FrameCutPageUC.m_dStartTrim, m_MainWindow.m_FrameCutPageUC.m_dEndTrim)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function RemoveFinalEmptyPhases() As Boolean
|
|
Dim nOpeId As Integer = EgtGetLastOperation()
|
|
While nOpeId <> GDB_ID.NULL
|
|
Dim nPrevOpeId As Integer = EgtGetPrevOperation(nOpeId)
|
|
If EgtGetOperationType(nOpeId) = MCH_OY.DISP Then
|
|
EgtRemoveLastPhase()
|
|
Else
|
|
Exit While
|
|
End If
|
|
nOpeId = nPrevOpeId
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function UpdateAllMachiningsToolpaths() As Boolean
|
|
EgtLuaCreateGlobTable("CAM")
|
|
SetLuaStandardCamParams()
|
|
Dim nErr As Integer = 999
|
|
Dim bOk As Boolean = EgtLuaExecFile(m_MainWindow.GetCamAutoDir() & "\CamAuto.lua")
|
|
bOk = bOk AndAlso EgtLuaGetGlobIntVar("CAM.ERR", nErr) AndAlso nErr = 0
|
|
bOk = bOk AndAlso EgtLuaCallFunction("CAM.UpdateAllTp")
|
|
EgtLuaGetGlobIntVar("CAM.ERR", nErr)
|
|
EgtLuaResetGlobVar("CAM")
|
|
If nErr <> 0 Then
|
|
bOk = False
|
|
EgtOutLog("Error in CamAuto : " & nErr.ToString())
|
|
End If
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function SortAllMachinings() As Boolean
|
|
EgtLuaCreateGlobTable("CAM")
|
|
SetLuaStandardCamParams()
|
|
Dim nErr As Integer = 999
|
|
Dim bOk As Boolean = EgtLuaExecFile(m_MainWindow.GetCamAutoDir() & "\CamAuto.lua")
|
|
bOk = bOk AndAlso EgtLuaGetGlobIntVar("CAM.ERR", nErr) AndAlso nErr = 0
|
|
bOk = bOk AndAlso EgtLuaCallFunction("CAM.Sort")
|
|
EgtLuaGetGlobIntVar("CAM.ERR", nErr)
|
|
EgtLuaResetGlobVar("CAM")
|
|
If nErr <> 0 Then
|
|
bOk = False
|
|
EgtOutLog("Error in CamAuto : " & nErr.ToString())
|
|
End If
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function SpecialApplyDisposition(nDispId As Integer, bRecalc As Boolean) As Boolean
|
|
EgtLuaCreateGlobTable("CAM")
|
|
EgtLuaSetGlobIntVar("CAM.DISPID", nDispId)
|
|
EgtLuaSetGlobBoolVar("CAM.RECALC", bRecalc)
|
|
Dim nErr As Integer = 999
|
|
Dim bOk As Boolean = EgtLuaExecFile(m_MainWindow.GetCamAutoDir() & "\CamAuto.lua")
|
|
bOk = bOk AndAlso EgtLuaGetGlobIntVar("CAM.ERR", nErr) AndAlso nErr = 0
|
|
bOk = bOk AndAlso EgtLuaCallFunction("CAM.SpecApplyDisp")
|
|
EgtLuaGetGlobIntVar("CAM.ERR", nErr)
|
|
EgtLuaResetGlobVar("CAM")
|
|
If nErr <> 0 Then
|
|
bOk = False
|
|
EgtOutLog("Error in CamAuto : " & nErr.ToString())
|
|
End If
|
|
m_MainWindow.m_CurrentProjectPageUC.ResetOrderMachiningFlag()
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function UpdateVacuumsForDrip() As Boolean
|
|
Dim bOk As Boolean = True
|
|
' Salvo fase attualmente corrente
|
|
Dim nOriPhase As Integer = EgtGetCurrPhase()
|
|
' Carico le ventose
|
|
LoadVacuumCups()
|
|
' Box complessivo dei pezzi con tagli da sotto
|
|
Dim b3Tot As New BBox3d
|
|
' Ciclo su tutti i pezzi presenti nei grezzi dell'ultima fase di lavorazione
|
|
EgtSetCurrPhase(EgtGetPhaseCount())
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
If EgtVerifyRawPartCurrPhase(nRawId) Then
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId)
|
|
While nPartId <> GDB_ID.NULL
|
|
' reset eventuali vecchie informazioni
|
|
RemoveOneMoveInfo(nPartId)
|
|
' se ci sono tagli da sotto nel pezzo si processa
|
|
If EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_DRIPCUT)) > 0 Then
|
|
Dim rmData As New RawMoveData
|
|
Dim b3Part As New BBox3d
|
|
If PutVacuumCupsOnPart(nPartId, rmData, b3Part) Then
|
|
SaveOneMoveInfo(nPartId, rmData)
|
|
b3Tot.Add(b3Part)
|
|
Else
|
|
bOk = False
|
|
EgtOutLog("Error on UpdateVacuumsForDrip in Part " & nPartId.ToString())
|
|
End If
|
|
End If
|
|
nPartId = EgtGetNextPartInRawPart(nPartId)
|
|
End While
|
|
End If
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
' Scarico le ventose
|
|
RemoveVacuumCups()
|
|
' Salvo box complessivo
|
|
Dim nMarkId As Integer = m_MainWindow.m_CurrentProjectPageUC.AddProjectMark()
|
|
If b3Tot.IsEmpty Then
|
|
Return EgtRemoveInfo(nMarkId, INFO_DRIPBBOX)
|
|
Else
|
|
Return EgtSetInfo(nMarkId, INFO_DRIPBBOX, b3Tot)
|
|
End If
|
|
' Ripristino fase corrente originale
|
|
EgtSetCurrPhase(nOriPhase)
|
|
Return bOk
|
|
End Function
|
|
|
|
Friend Function DeactivateAllMachinings() As Boolean
|
|
Return EgtSetAllOperationsMode(False)
|
|
End Function
|
|
|
|
Friend Function ActivateAllMachinings() As Boolean
|
|
Return EgtSetAllOperationsMode(True)
|
|
End Function
|
|
|
|
Friend Function HideAllMachinings() As Boolean
|
|
Dim nId As Integer = EgtGetFirstOperation()
|
|
While nId <> GDB_ID.NULL
|
|
If EgtGetOperationType(nId) <> MCH_OY.DISP Then
|
|
EgtSetOperationStatus(nId, False)
|
|
End If
|
|
nId = EgtGetNextOperation(nId)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ShowAllCurrPhaseMachinings() As Boolean
|
|
' Parto dalla prima lavorazione successiva alla disposizione di fase
|
|
Dim nId As Integer = EgtGetPhaseDisposition(EgtGetCurrPhase())
|
|
nId = EgtGetNextOperation(nId)
|
|
' Finchè c'è una lavorazione
|
|
While nId <> GDB_ID.NULL
|
|
' Se disposizione sono alla fase successiva
|
|
If EgtGetOperationType(nId) = MCH_OY.DISP Then Exit While
|
|
' Se abilitata
|
|
If EgtGetOperationMode(nId) Then
|
|
EgtSetOperationStatus(nId, True)
|
|
End If
|
|
' Passo alla successiva
|
|
nId = EgtGetNextOperation(nId)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function RemoveFinalHome() As Boolean
|
|
Dim nId As Integer = EgtGetLastActiveOperation()
|
|
Return EgtRemoveOperationHome(nId)
|
|
End Function
|
|
|
|
Friend Function VerifySetup(ByRef sMissingTools As String) As Boolean
|
|
Dim bOk As Boolean = True
|
|
Dim bIsMultiCut = (EgtGetHeadId("H101") <> GDB_ID.NULL)
|
|
sMissingTools = String.Empty
|
|
Dim nId As Integer = EgtGetFirstOperation()
|
|
While nId <> GDB_ID.NULL
|
|
If IsValidMachining(nId) Then
|
|
Dim nType As Integer = MCH_OY.NONE
|
|
EgtGetMachiningParam(MCH_MP.TYPE, nType)
|
|
Dim sTuuid As String = String.Empty
|
|
Dim sTool As String = String.Empty
|
|
EgtGetMachiningParam(MCH_MP.TUUID, sTuuid)
|
|
EgtTdbGetToolFromUUID(sTuuid, sTool)
|
|
If nType = MCH_OY.SAWING Or nType = MCH_OY.SAWROUGHING Or nType = MCH_OY.SAWFINISHING Then
|
|
If bIsMultiCut Then
|
|
' L'utensile sulla seconda testa ha lo stesso nome di quello sulla prima con suffisso "-2"
|
|
If sTool.Substring(sTool.Length() - 2) = "-2" Then
|
|
sTool = sTool.Remove(sTool.Length() - 2)
|
|
End If
|
|
End If
|
|
If String.Compare(sTool, m_MainWindow.m_CurrentMachine.sCurrSaw) <> 0 And
|
|
String.Compare(sTool, m_MainWindow.m_CurrentMachine.sCurrDripSaw) <> 0 Then
|
|
bOk = False
|
|
If sMissingTools.IndexOf(sTool) = -1 Then
|
|
sMissingTools = sMissingTools & sTool & ", "
|
|
End If
|
|
End If
|
|
ElseIf nType = MCH_OY.DRILLING Then
|
|
If String.Compare(sTool, m_MainWindow.m_CurrentMachine.sCurrDrill) <> 0 And
|
|
Not FindToolOnChanger(sTool) Then
|
|
bOk = False
|
|
If sMissingTools.IndexOf(sTool) = -1 Then
|
|
sMissingTools = sMissingTools & sTool & ", "
|
|
End If
|
|
End If
|
|
ElseIf nType = MCH_OY.MILLING Then
|
|
If String.Compare(sTool, m_MainWindow.m_CurrentMachine.sCurrMill) <> 0 And
|
|
Not FindToolOnChanger(sTool) Then
|
|
bOk = False
|
|
If sMissingTools.IndexOf(sTool) = -1 Then
|
|
sMissingTools = sMissingTools & sTool & ", "
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
nId = EgtGetNextOperation(nId)
|
|
End While
|
|
Return bOk
|
|
End Function
|
|
|
|
Private Function FindToolOnChanger(sTool As String) As Boolean
|
|
' Ricerca nel cambia utensili automatico
|
|
For i As Integer = 0 To m_MainWindow.m_CurrentMachine.ToolChangerNbr() - 1
|
|
If String.Compare(sTool, m_MainWindow.m_CurrentMachine.ToolChanger(i).sTool) = 0 Then
|
|
Return True
|
|
End If
|
|
Next
|
|
' Ricerca nel cambia utensili manuale
|
|
For i As Integer = 0 To m_MainWindow.m_CurrentMachine.ManualToolChangerNbr() - 1
|
|
If String.Compare(sTool, m_MainWindow.m_CurrentMachine.ManualToolChanger(i).sTool) = 0 Then
|
|
Return True
|
|
End If
|
|
Next
|
|
' Non trovato
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function TestAllMachiningsForStrict() As Boolean
|
|
Dim bModified As Boolean = False
|
|
' Affondamento ridotto
|
|
Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, m_MainWindow.GetMachIniFile())
|
|
' Ciclo sulle lavorazioni
|
|
Dim nOperId As Integer = EgtGetFirstOperation()
|
|
While nOperId <> GDB_ID.NULL
|
|
' verifico sia una lavorazione valida
|
|
If IsValidMachining(nOperId) Then
|
|
' verifica interferenza
|
|
Dim nFlag As Integer = FMI_TYPE.NONE
|
|
If Not VerifyComposedMachining(nOperId, nFlag) Then
|
|
nFlag = FMI_TYPE.LI Or FMI_TYPE.RM Or FMI_TYPE.LO
|
|
End If
|
|
' sistemazione lavorazione, se necessario
|
|
If AdjustMachining(nOperId, nFlag, dReducedDepth) Then
|
|
bModified = True
|
|
End If
|
|
End If
|
|
nOperId = EgtGetNextOperation(nOperId)
|
|
End While
|
|
Return bModified
|
|
End Function
|
|
|
|
Friend Function VerifyComposedMachining(nOperId As Integer, ByRef nFlag As Integer) As Boolean
|
|
' verifico sia una lavorazione
|
|
If Not EgtSetCurrMachining(nOperId) Then Return False
|
|
' determino eventuali lavorazioni inglobate
|
|
Dim vOthId As New List(Of Integer)
|
|
Dim sInfo As String = String.Empty
|
|
If EgtGetInfo(nOperId, INFO_MCH_OTHMID, sInfo) Then
|
|
Dim sItems() As String = sInfo.Split(",".ToCharArray)
|
|
For Each sId In sItems
|
|
Dim nId As Integer = 0
|
|
StringToInt(sId, nId)
|
|
If nId > 0 Then vOthId.Add(nId)
|
|
Next
|
|
End If
|
|
' layer di origine
|
|
Dim sLay As String = String.Empty
|
|
EgtGetInfo(nOperId, INFO_MCH_LAYER, sLay)
|
|
' verifica interferenza
|
|
nFlag = FMI_TYPE.NONE
|
|
If sLay = NAME_OUTLOOP Then
|
|
Dim nRes As Integer = FMI_TYPE.LI Or FMI_TYPE.RM Or FMI_TYPE.LO
|
|
If Not EgtVerifyMachining(nOperId, nRes) Then Return False
|
|
nFlag = nFlag Or nRes
|
|
For Each nId As Integer In vOthId
|
|
nRes = FMI_TYPE.LI Or FMI_TYPE.RM Or FMI_TYPE.LO
|
|
If Not EgtVerifyMachining(nId, nRes) Then Return False
|
|
nFlag = nFlag Or nRes
|
|
Next
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function AdjustMachining(nOperId As Integer, nFlag As Integer, dReducedDepth As Double) As Boolean
|
|
Dim bModified As Boolean = False
|
|
' abilitazione
|
|
Dim bEnabled As Boolean = Not EgtExistsInfo(nOperId, INFO_MCH_USER_OFF)
|
|
' restringo lavorazione abilitata ma con interferenza
|
|
If bEnabled And nFlag <> FMI_TYPE.NONE Then
|
|
Dim bStart As Boolean = ((nFlag And FMI_TYPE.LI) <> 0)
|
|
Dim bEnd As Boolean = ((nFlag And FMI_TYPE.LO) <> 0)
|
|
SetCutStrict(nOperId, bStart, bEnd)
|
|
' se risulta lavorazione vuota, provo a diminuire l'affondamento
|
|
If EgtIsMachiningEmpty() Then
|
|
ResetCutStrict(nOperId, bStart, bEnd)
|
|
SetCutDepth(nOperId, dReducedDepth)
|
|
' ripeto verifica
|
|
nFlag = FMI_TYPE.NONE
|
|
If Not VerifyComposedMachining(nOperId, nFlag) Then
|
|
nFlag = FMI_TYPE.LI Or FMI_TYPE.RM Or FMI_TYPE.LO
|
|
End If
|
|
' se non superata la stringo
|
|
If nFlag <> FMI_TYPE.NONE Then
|
|
bStart = ((nFlag And FMI_TYPE.LI) <> 0)
|
|
bEnd = ((nFlag And FMI_TYPE.LO) <> 0)
|
|
SetCutStrict(nOperId, bStart, bEnd)
|
|
End If
|
|
End If
|
|
bModified = True
|
|
End If
|
|
Return bModified
|
|
End Function
|
|
|
|
Friend Function SetCutDepth(nMchId As Integer, dDepth As Double) As Boolean
|
|
' Imposto la lavorazione corrente
|
|
If Not EgtSetCurrMachining(nMchId) Then Return False
|
|
' Imposto l'affondamento
|
|
EgtSetMachiningParam(MCH_MP.DEPTH, dDepth)
|
|
' Ricalcolo il preview
|
|
UpdateMachiningPreview(nMchId, True)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SetCutStrict(nMchId As Integer, bStart As Boolean, bEnd As Boolean) As Boolean
|
|
' Recupero sicurezza su tagli
|
|
Dim dSafeLen As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_CUT, 0, m_MainWindow.GetMachIniFile())
|
|
' Imposto la lavorazione corrente
|
|
If Not EgtSetCurrMachining(nMchId) Then Return False
|
|
Dim bModif As Boolean = False
|
|
' Se richiesto, restringo l'attacco
|
|
If bStart Then
|
|
' Recupero tipo attacco originale e lo salvo se non già fatto
|
|
Dim nOriLeadIn As Integer = MCH_SAW_LI.CENT
|
|
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nOriLeadIn)
|
|
If Not EgtExistsInfo(nMchId, INFO_MCH_ORILEADIN) Then
|
|
EgtSetInfo(nMchId, INFO_MCH_ORILEADIN, nOriLeadIn)
|
|
End If
|
|
' Se attacco cambiato, aggiorno e accorcio della sicurezza sui tagli
|
|
If nOriLeadIn <> MCH_SAW_LI.STRICT Then
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.STRICT)
|
|
Dim dAddLen As Double = 0
|
|
EgtGetMachiningParam(MCH_MP.STARTADDLEN, dAddLen)
|
|
EgtSetMachiningParam(MCH_MP.STARTADDLEN, dAddLen - dSafeLen)
|
|
bModif = True
|
|
End If
|
|
End If
|
|
' Se richiesto, restringo l'uscita
|
|
If bEnd Then
|
|
' Recupero tipo uscita originale e lo salvo se non già fatto
|
|
Dim nOriLeadOut As Integer = MCH_SAW_LO.CENT
|
|
EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nOriLeadOut)
|
|
If Not EgtExistsInfo(nMchId, INFO_MCH_ORILEADOUT) Then
|
|
EgtSetInfo(nMchId, INFO_MCH_ORILEADOUT, nOriLeadOut)
|
|
End If
|
|
' Se uscita cambiata, aggiorno e accorcio della sicurezza sui tagli
|
|
If nOriLeadOut <> MCH_SAW_LO.STRICT Then
|
|
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.STRICT)
|
|
Dim dAddLen As Double = 0
|
|
EgtGetMachiningParam(MCH_MP.ENDADDLEN, dAddLen)
|
|
EgtSetMachiningParam(MCH_MP.ENDADDLEN, dAddLen - dSafeLen)
|
|
bModif = True
|
|
End If
|
|
End If
|
|
' Se modificato, ricalcolo il preview
|
|
If bModif Then
|
|
UpdateMachiningPreview(nMchId, True)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ResetCutStrict(nMchId As Integer, bStart As Boolean, bEnd As Boolean) As Boolean
|
|
' Recupero sicurezza su tagli
|
|
Dim dSafeLen As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_CUT, 0, m_MainWindow.GetMachIniFile())
|
|
' Imposto la lavorazione corrente
|
|
If Not EgtSetCurrMachining(nMchId) Then Return False
|
|
Dim bModif As Boolean = False
|
|
' Se richiesto, ripristino l'attacco
|
|
If bStart Then
|
|
' Recupero tipo attacco originale
|
|
Dim nOriLeadIn As Integer = MCH_SAW_LI.CENT
|
|
EgtGetInfo(nMchId, INFO_MCH_ORILEADIN, nOriLeadIn)
|
|
Dim nCurrLeadIn As Integer = MCH_SAW_LI.CENT
|
|
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nCurrLeadIn)
|
|
' Se attacco cambiato, aggiorno e allungo della sicurezza sui tagli
|
|
If nOriLeadIn <> nCurrLeadIn Then
|
|
EgtSetMachiningParam(MCH_MP.LEADINTYPE, nOriLeadIn)
|
|
Dim dAddLen As Double = 0
|
|
EgtGetMachiningParam(MCH_MP.STARTADDLEN, dAddLen)
|
|
EgtSetMachiningParam(MCH_MP.STARTADDLEN, dAddLen + dSafeLen)
|
|
bModif = True
|
|
End If
|
|
End If
|
|
' Se richiesto, ripristino l'uscita
|
|
If bEnd Then
|
|
' Recupero tipo uscita originale
|
|
Dim nOriLeadOut As Integer = MCH_SAW_LO.CENT
|
|
EgtGetInfo(nMchId, INFO_MCH_ORILEADOUT, nOriLeadOut)
|
|
Dim nCurrLeadOut As Integer = MCH_SAW_LO.CENT
|
|
EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nCurrLeadOut)
|
|
' Se uscita cambiata, aggiorno
|
|
If nOriLeadOut <> nCurrLeadOut Then
|
|
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, nOriLeadOut)
|
|
Dim dAddLen As Double = 0
|
|
EgtGetMachiningParam(MCH_MP.ENDADDLEN, dAddLen)
|
|
EgtSetMachiningParam(MCH_MP.ENDADDLEN, dAddLen + dSafeLen)
|
|
bModif = True
|
|
End If
|
|
End If
|
|
' Se modificato, ricalcolo il preview
|
|
If bModif Then
|
|
UpdateMachiningPreview(nMchId, True)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function UpdateMachiningPreview(nMchId As Integer, bMoveOnPart As Boolean) As Boolean
|
|
' Imposto la lavorazione corrente
|
|
If Not EgtSetCurrMachining(nMchId) Then Return False
|
|
' Ricalcolo il preview
|
|
EgtPreviewMachining(True)
|
|
' Se non devo spostarlo nel pezzo, esco
|
|
If Not bMoveOnPart Then
|
|
Return True
|
|
End If
|
|
' Indice gruppo di preview nella lavorazione
|
|
Dim nMchPvId As Integer = EgtGetFirstNameInGroup(nMchId, NAME_PREVIEW)
|
|
' Indice gruppo di preview nel pezzo
|
|
Dim nPartPvId As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nMchPvId, INFO_PV_ONPART_ID, nPartPvId)
|
|
' Svuoto il preview nel pezzo
|
|
EgtEmptyGroup(nPartPvId)
|
|
' Rimuovo anche il preview di lavorazioni inglobate
|
|
Dim sInfo As String = String.Empty
|
|
If EgtGetInfo(nMchId, INFO_MCH_OTHMID, sInfo) Then
|
|
Dim sItems() As String = sInfo.Split(",".ToCharArray)
|
|
For Each sId2 In sItems
|
|
' Indice gruppo di preview nella lavorazione
|
|
Dim nId2 As Integer = GDB_ID.NULL
|
|
StringToInt(sId2, nId2)
|
|
Dim nMchPvId2 As Integer = EgtGetFirstNameInGroup(nId2, NAME_PREVIEW)
|
|
' Indice gruppo di preview nel pezzo
|
|
Dim nPartPvId2 As Integer = GDB_ID.NULL
|
|
EgtGetInfo(nMchPvId2, INFO_PV_ONPART_ID, nPartPvId2)
|
|
' Svuoto il preview nel pezzo
|
|
EgtEmptyGroup(nPartPvId2)
|
|
Next
|
|
End If
|
|
' Lo sposto dalla lavorazione al pezzo
|
|
Dim nId As Integer = EgtGetFirstInGroup(nMchPvId)
|
|
While nId <> GDB_ID.NULL
|
|
EgtRelocateGlob(nId, nPartPvId)
|
|
nId = EgtGetFirstInGroup(nMchPvId)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function RemoveMachiningPreview(nMchId As Integer) As Boolean
|
|
' Indice gruppo di preview nella lavorazione
|
|
Dim nMchPvId As Integer = EgtGetFirstNameInGroup(nMchId, NAME_PREVIEW)
|
|
' Lo svuoto
|
|
Return EgtEmptyGroup(nMchPvId)
|
|
End Function
|
|
|
|
Friend Function IsValidMachining(nOperId As Integer) As Boolean
|
|
' Deve essere una lavorazione
|
|
If Not EgtSetCurrMachining(nOperId) Then Return False
|
|
' Deve contenere qualcosa
|
|
If EgtIsMachiningEmpty() Then Return False
|
|
' Deve essere abilitata oppure disabilitata direttamente dall'utente
|
|
If Not (EgtGetOperationMode(nOperId) Or EgtExistsInfo(nOperId, INFO_MCH_USER_OFF)) Then Return False
|
|
' E' valida
|
|
Return True
|
|
End Function
|
|
|
|
Private Function SetLuaStandardCamParams() As Boolean
|
|
Dim sSawMch As String = m_MainWindow.m_CurrentMachine.sCurrSawing
|
|
Dim sMillMch As String = m_MainWindow.m_CurrentMachine.sCurrMilling
|
|
Dim sDrillMch As String = m_MainWindow.m_CurrentMachine.sCurrDrilling
|
|
Dim sDripSawMch As String = m_MainWindow.m_CurrentMachine.sCurrDripSawing
|
|
Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, m_MainWindow.GetMachIniFile())
|
|
Dim dHolesOffset As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OFFSET, 0, m_MainWindow.GetMachIniFile())
|
|
Dim dHolesOverlap As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OVERLAP, 0, m_MainWindow.GetMachIniFile())
|
|
Dim dCornerSafety As Double = Math.Max(GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_INTCORNER, 1, m_MainWindow.GetMachIniFile()), 10 * EPS_SMALL)
|
|
Dim bOneHoleIntCorner As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_ONEHOLE_INTCORNER, 0, m_MainWindow.GetMachIniFile()) <> 0)
|
|
Dim bMillingOnCorners As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_MILLING_ON_CORNERS, 1, m_MainWindow.GetMachIniFile()) <> 0)
|
|
Dim bMillingOnSinks As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_MILLING_ON_SINKS, 0, m_MainWindow.GetMachIniFile()) <> 0)
|
|
EgtLuaSetGlobStringVar("CAM.SAWMCH", sSawMch)
|
|
EgtLuaSetGlobStringVar("CAM.MILLMCH", sMillMch)
|
|
EgtLuaSetGlobStringVar("CAM.DRILLMCH", sDrillMch)
|
|
EgtLuaSetGlobStringVar("CAM.DRIPSAWMCH", sDripSawMch)
|
|
EgtLuaSetGlobNumVar("CAM.REDUCEDDEPTH", dReducedDepth)
|
|
EgtLuaSetGlobNumVar("CAM.HOLESOFFSET", dHolesOffset)
|
|
EgtLuaSetGlobNumVar("CAM.HOLESOVERLAP", dHolesOverlap)
|
|
EgtLuaSetGlobBoolVar("CAM.ONEHOLEINTCORNER", bOneHoleIntCorner)
|
|
EgtLuaSetGlobNumVar("CAM.CORNERSAFETY", dCornerSafety)
|
|
EgtLuaSetGlobBoolVar("CAM.MILLINGONCORNERS", bMillingOnCorners)
|
|
EgtLuaSetGlobBoolVar("CAM.MILLINGONSINKS", bMillingOnSinks)
|
|
EgtLuaSetGlobNumVar("CAM.RAWHEIGHT", GetRawHeight())
|
|
EgtLuaSetGlobNumVar("CAM.REGROT", GetRegistrationRotation())
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function GetTableCount() As Integer
|
|
If EgtGetTableId(MAIN_TAB) = GDB_ID.NULL Then Return 0
|
|
If EgtGetTableId(SECOND_TAB) = GDB_ID.NULL Then Return 1
|
|
If EgtGetTableId(THIRD_TAB) = GDB_ID.NULL Then Return 2
|
|
Return 3
|
|
End Function
|
|
|
|
Friend Function GetTableName(nInd As Integer) As String
|
|
If nInd = 1 Then Return MAIN_TAB
|
|
If nInd = 2 Then Return SECOND_TAB
|
|
If nInd = 3 Then Return THIRD_TAB
|
|
Return ""
|
|
End Function
|
|
|
|
Friend Function GetCurrentTable() As Integer
|
|
Dim sTabName As String = MAIN_TAB
|
|
EgtGetTableName(sTabName)
|
|
If sTabName = THIRD_TAB Then
|
|
Return 3
|
|
ElseIf sTabName = SECOND_TAB Then
|
|
Return 2
|
|
Else
|
|
Return 1
|
|
End If
|
|
End Function
|
|
|
|
Friend Function GetCurrentRaw() As Integer
|
|
' Recupero il grezzo (primo con fase 1)
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL And Not EgtVerifyRawPartPhase(nRawId, 1)
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
Return nRawId
|
|
End Function
|
|
|
|
Friend Function GetRawBox(ByRef ptRawMin As Point3d, ByRef ptRawMax As Point3d) As Boolean
|
|
Return EgtGetRawPartBBox(GetCurrentRaw(), ptRawMin, ptRawMax)
|
|
End Function
|
|
|
|
Friend Function GetRawBox(ByRef b3RawBox As BBox3d) As Boolean
|
|
Return EgtGetRawPartBBox(GetCurrentRaw(), b3RawBox)
|
|
End Function
|
|
|
|
Friend Function GetRawCenter(ByRef ptCent As Point3d) As Boolean
|
|
Return EgtGetRawPartCenter(GetCurrentRaw(), ptCent)
|
|
End Function
|
|
|
|
Friend Function GetRawHeight() As Double
|
|
Dim ptRawMin, ptRawMax As Point3d
|
|
If GetRawBox(ptRawMin, ptRawMax) Then
|
|
Return (ptRawMax.z - ptRawMin.z)
|
|
Else
|
|
Return 0
|
|
End If
|
|
End Function
|
|
|
|
Friend Function SetRegistrationRotation(dRegRot As Double) As Boolean
|
|
Return EgtSetInfo(GetCurrentRaw(), INFO_REGROT, dRegRot)
|
|
End Function
|
|
|
|
Friend Function ResetRegistrationRotation() As Boolean
|
|
Return EgtRemoveInfo(GetCurrentRaw(), INFO_REGROT)
|
|
End Function
|
|
|
|
Friend Function GetRegistrationRotation() As Double
|
|
Dim dRegRot As Double = 0
|
|
EgtGetInfo(GetCurrentRaw(), INFO_REGROT, dRegRot)
|
|
Return dRegRot
|
|
End Function
|
|
|
|
Friend Function UpdateAllRawsZ(dDeltaZ As Double) As Boolean
|
|
For i As Integer = 1 To EgtGetPhaseCount()
|
|
EgtSetCurrPhase(i)
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
If EgtVerifyRawPartCurrPhase(nRawId) Then
|
|
EgtMoveRawPart(nRawId, New Vector3d(0, 0, dDeltaZ))
|
|
End If
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
Next
|
|
EgtSetCurrPhase(1)
|
|
HideAllMachinings()
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function IsMachiningInActiveRaw(nMchId As Integer) As Boolean
|
|
EgtSetCurrMachining(nMchId)
|
|
' Recupero la prima entità geometrica della lavorazione
|
|
Dim nId, nSub As Integer
|
|
If Not EgtGetMachiningGeometry(0, nId, nSub) Then Return False
|
|
' Recupero il pezzo di appartenenza
|
|
Dim nPartId = EgtGetParent(EgtGetParent(nId))
|
|
If nPartId = GDB_ID.NULL Then Return False
|
|
' Recupero la fase di appartenenza della lavorazione
|
|
Dim nPhase As Integer = EgtGetOperationPhase(nMchId)
|
|
' Verifico se il pezzo è nei grezzi della fase indicata
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
If EgtVerifyRawPartPhase(nRawId, nPhase) Then
|
|
Dim nPirId As Integer = EgtGetFirstPartInRawPart(nRawId)
|
|
While nPirId <> GDB_ID.NULL
|
|
If nPartId = nPirId Then Return True
|
|
nPirId = EgtGetNextPartInRawPart(nPirId)
|
|
End While
|
|
End If
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function AddFrameMachinings(dTrimStart As Double, dTrimEnd As Double) As Boolean
|
|
' Cancello tutte le lavorazioni
|
|
EgtRemoveAllOperations()
|
|
' Recupero il grezzo corrente
|
|
Dim nRawId As Integer = GetCurrentRaw()
|
|
If nRawId = GDB_ID.NULL Then Return False
|
|
' Se non ci sono pezzi, esco
|
|
If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True
|
|
' Aggiungo sgrossatura
|
|
If Not AddFrameSawRoughing(dTrimStart, dTrimEnd) Then Return False
|
|
' Aggiungo finitura
|
|
If Not AddFrameSawFinishing(dTrimStart, dTrimEnd) Then Return False
|
|
' Aggiungo spatolatura
|
|
If Not AddFrameSawSideFinishing(dTrimStart, dTrimEnd) Then Return False
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function AddFrameSawRoughing(dTrimStart As Double, dTrimEnd As Double) As Boolean
|
|
' Cancello la lavorazione di sgrossatura
|
|
Dim nId As Integer = EgtGetOperationId(NAME_FRAME_SAWROU)
|
|
EgtRemoveOperation(nId)
|
|
' Recupero il grezzo corrente
|
|
Dim nRawId As Integer = GetCurrentRaw()
|
|
If nRawId = GDB_ID.NULL Then Return False
|
|
' Se non ci sono pezzi, esco
|
|
If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True
|
|
' Recupero la lavorazione corrente di sgrossatura con lama
|
|
Dim sCurrSawRoughing = m_MainWindow.m_CurrentMachine.sCurrSawRoughing
|
|
If String.IsNullOrEmpty(sCurrSawRoughing) Then Return True
|
|
' Inserisco la lavorazione corrente
|
|
Dim nMchId As Integer = EgtAddMachining(NAME_FRAME_SAWROU, sCurrSawRoughing)
|
|
If nMchId = GDB_ID.NULL Then Return False
|
|
' La sposto all'inizio delle lavorazioni (subito dopo la disposizione)
|
|
Dim nDispId As Integer = EgtGetPhaseDisposition(1)
|
|
If Not EgtRelocate(nMchId, nDispId, GDB_POS.AFTER) Then
|
|
EgtErase(nMchId)
|
|
Return False
|
|
End If
|
|
' Recupero sezioni e prima guida dei pezzi nel grezzo
|
|
Dim nCount As Integer = EgtGetPartInRawPartCount(nRawId)
|
|
Dim vId(nCount) As Integer
|
|
Dim nInd As Integer = 0
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId)
|
|
vId(nCount) = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_GUIDE))
|
|
While nPartId <> GDB_ID.NULL
|
|
vId(nInd) = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_SECT))
|
|
nInd += 1
|
|
nPartId = EgtGetNextPartInRawPart(nPartId)
|
|
End While
|
|
' Imposto la geometria
|
|
EgtSetMachiningGeometry(vId)
|
|
' Imposto trim iniziale e finale
|
|
EgtSetMachiningParam(MCH_MP.STARTADDLEN, -dTrimStart)
|
|
EgtSetMachiningParam(MCH_MP.ENDADDLEN, -dTrimEnd)
|
|
' Applico la lavorazione
|
|
Return EgtApplyMachining(False)
|
|
End Function
|
|
|
|
Friend Function AddFrameSawFinishing(dTrimStart As Double, dTrimEnd As Double) As Boolean
|
|
' Cancello la lavorazione di finitura
|
|
Dim nId As Integer = EgtGetOperationId(NAME_FRAME_SAWFIN)
|
|
EgtRemoveOperation(nId)
|
|
' Recupero il grezzo corrente
|
|
Dim nRawId As Integer = GetCurrentRaw()
|
|
If nRawId = GDB_ID.NULL Then Return False
|
|
' Se non ci sono pezzi, esco
|
|
If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True
|
|
' Recupero la lavorazione corrente di finitura con lama
|
|
Dim sCurrSawFinishing = m_MainWindow.m_CurrentMachine.sCurrSawFinishing
|
|
If String.IsNullOrEmpty(sCurrSawFinishing) Then Return True
|
|
' Inserisco la lavorazione corrente
|
|
Dim nMchId As Integer = EgtAddMachining(NAME_FRAME_SAWFIN, sCurrSawFinishing)
|
|
If nMchId = GDB_ID.NULL Then Return False
|
|
' La sposto prima di una eventuale spatolatura
|
|
Dim nSideFinId As Integer = EgtGetFirstOperation()
|
|
While nSideFinId <> GDB_ID.NULL
|
|
Dim sName As String = String.Empty
|
|
If EgtGetOperationName(nSideFinId, sName) AndAlso
|
|
String.Compare(sName, NAME_FRAME_SAWSIDEFIN, True) = 0 Then
|
|
Exit While
|
|
End If
|
|
nSideFinId = EgtGetNextOperation(nSideFinId)
|
|
End While
|
|
If nSideFinId <> GDB_ID.NULL Then
|
|
If Not EgtRelocate(nMchId, nSideFinId, GDB_POS.BEFORE) Then
|
|
EgtErase(nMchId)
|
|
Return False
|
|
End If
|
|
End If
|
|
' Recupero sezioni e prima guida dei pezzi nel grezzo
|
|
Dim nCount As Integer = EgtGetPartInRawPartCount(nRawId)
|
|
Dim vId(nCount) As Integer
|
|
Dim nInd As Integer = 0
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId)
|
|
vId(nCount) = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_GUIDE))
|
|
While nPartId <> GDB_ID.NULL
|
|
vId(nInd) = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_SECT))
|
|
nInd += 1
|
|
nPartId = EgtGetNextPartInRawPart(nPartId)
|
|
End While
|
|
' Imposto la geometria
|
|
EgtSetMachiningGeometry(vId)
|
|
' Imposto trim iniziale e finale
|
|
EgtSetMachiningParam(MCH_MP.STARTADDLEN, -dTrimStart)
|
|
EgtSetMachiningParam(MCH_MP.ENDADDLEN, -dTrimEnd)
|
|
' Applico la lavorazione
|
|
Return EgtApplyMachining(False)
|
|
End Function
|
|
|
|
Friend Function AddFrameSawSideFinishing(dTrimStart As Double, dTrimEnd As Double) As Boolean
|
|
' Cancello la lavorazione di spatolatura
|
|
Dim nId As Integer = EgtGetOperationId(NAME_FRAME_SAWSIDEFIN)
|
|
EgtRemoveOperation(nId)
|
|
' Recupero il grezzo corrente
|
|
Dim nRawId As Integer = GetCurrentRaw()
|
|
If nRawId = GDB_ID.NULL Then Return False
|
|
' Se non ci sono pezzi, esco
|
|
If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True
|
|
' Recupero la lavorazione corrente di spatolatura con lama
|
|
Dim sCurrSawSideFinishing = m_MainWindow.m_CurrentMachine.sCurrSawSideFinishing
|
|
If String.IsNullOrEmpty(sCurrSawSideFinishing) Then Return True
|
|
' Inserisco la lavorazione corrente
|
|
Dim nMchId As Integer = EgtAddMachining(NAME_FRAME_SAWSIDEFIN, sCurrSawSideFinishing)
|
|
If nMchId = GDB_ID.NULL Then Return False
|
|
' Recupero sezioni e prima guida dei pezzi nel grezzo
|
|
Dim nCount As Integer = EgtGetPartInRawPartCount(nRawId)
|
|
Dim vId(nCount) As Integer
|
|
Dim nInd As Integer = 0
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId)
|
|
vId(nCount) = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_GUIDE))
|
|
While nPartId <> GDB_ID.NULL
|
|
vId(nInd) = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_SECT))
|
|
nInd += 1
|
|
nPartId = EgtGetNextPartInRawPart(nPartId)
|
|
End While
|
|
' Imposto la geometria
|
|
EgtSetMachiningGeometry(vId)
|
|
' Imposto trim iniziale e finale
|
|
EgtSetMachiningParam(MCH_MP.STARTADDLEN, -dTrimStart)
|
|
EgtSetMachiningParam(MCH_MP.ENDADDLEN, -dTrimEnd)
|
|
' Applico la lavorazione
|
|
Return EgtApplyMachining(False)
|
|
End Function
|
|
|
|
End Module
|