From d950fc106029c937a31c025f297548757c93048e Mon Sep 17 00:00:00 2001 From: Nicola Pievani Date: Fri, 9 Oct 2020 08:13:48 +0000 Subject: [PATCH] OmagVIEWPlus 2.2j1: -> nuova definizione dei pezzi (classe Part) -> nuova gestione dei magazzini -> aggiunta pagina per la selezione dei pezzi manuali -> nuova configurazione delle variabili. --- Constants/ConstGen.vb | 39 + Constants/ConstIni.vb | 29 + EgtStoneLib/CamAuto.vb | 1404 +++++++++++++++++++++++ EgtStoneLib/ConstMach.vb | 319 ++++++ EgtStoneLib/ConstMachIni.vb | 263 +++++ EgtStoneLib/CsvM.vb | 528 +++++++++ EgtStoneLib/CurrentMachine.vb | 1444 ++++++++++++++++++++++++ EgtStoneLib/EstCalc.vb | 789 +++++++++++++ EgtStoneLib/EstPhoto.vb | 521 +++++++++ EgtStoneLib/EstProject.vb | 44 + EgtStoneLib/GeomCalc.vb | 115 ++ EgtStoneLib/SplitAuto.vb | 810 +++++++++++++ EgtStoneLib/VacuumCups.vb | 766 +++++++++++++ EgtStoneLib/VeinMatchingWindow.xaml | 32 + EgtStoneLib/VeinMatchingWindow.xaml.vb | 1171 +++++++++++++++++++ GridBox/GridBoxesV.xaml | 42 + GridBox/GridBoxesV.xaml.vb | 11 + GridBox/GridBoxesVM.vb | 105 ++ GridStorage/WarehouseV.xaml | 57 + GridStorage/WarehouseV.xaml.vb | 3 + MainWindow/MainWindowM.vb | 341 +++++- MainWindow/MainWindowV.xaml | 28 +- MainWindow/MainWindowVM.vb | 101 +- MainWindow/Part.vb | 500 ++++++++ My Project/AssemblyInfo.vb | 6 +- MySceneHost/MySceneHostVM.vb | 567 ++++++++++ MySceneHost/SceneWindowV.xaml | 23 + MySceneHost/SceneWindowV.xaml.vb | 3 + MySceneHost/SceneWindowVM.vb | 7 + NCCommunication/NCCommunication.vb | 635 ++++++++--- NCCommunication/Nc_Siemens.vb | 5 + OmagVIEWPlus.vbproj | 59 +- Resources/Nastro.png | Bin 3987 -> 3312 bytes Resources/RedArrow.png | Bin 0 -> 1335 bytes Resources/Tavola1.png | Bin 4117 -> 3867 bytes Resources/WhiteArrow.png | Bin 0 -> 1310 bytes SceneHost/SceneHostV.xaml | 25 + SceneHost/SceneHostV.xaml.vb | 22 + UnloadingArea/UnloadingAreaV.xaml | 132 ++- UnloadingArea/UnloadingAreaV.xaml.vb | 18 +- UnloadingArea/UnloadingAreaVM.vb | 714 +++++++++++- Utility/Dictionary.xaml | 48 +- Utility/Dictionary.xaml.vb | 4 +- Utility/Enums.vb | 60 + Utility/Map.vb | 25 +- Utility/Utility.vb | 194 ++++ Warehouse/Box.vb | 242 +++- Warehouse/BoxV.xaml | 29 + Warehouse/BoxV.xaml.vb | 12 + Warehouse/WarehouseV.xaml | 48 - Warehouse/WarehouseVM.vb | 327 ++++-- 51 files changed, 12255 insertions(+), 412 deletions(-) create mode 100644 EgtStoneLib/CamAuto.vb create mode 100644 EgtStoneLib/ConstMach.vb create mode 100644 EgtStoneLib/ConstMachIni.vb create mode 100644 EgtStoneLib/CsvM.vb create mode 100644 EgtStoneLib/CurrentMachine.vb create mode 100644 EgtStoneLib/EstCalc.vb create mode 100644 EgtStoneLib/EstPhoto.vb create mode 100644 EgtStoneLib/EstProject.vb create mode 100644 EgtStoneLib/GeomCalc.vb create mode 100644 EgtStoneLib/SplitAuto.vb create mode 100644 EgtStoneLib/VacuumCups.vb create mode 100644 EgtStoneLib/VeinMatchingWindow.xaml create mode 100644 EgtStoneLib/VeinMatchingWindow.xaml.vb create mode 100644 GridBox/GridBoxesV.xaml create mode 100644 GridBox/GridBoxesV.xaml.vb create mode 100644 GridBox/GridBoxesVM.vb create mode 100644 GridStorage/WarehouseV.xaml create mode 100644 GridStorage/WarehouseV.xaml.vb create mode 100644 MainWindow/Part.vb create mode 100644 MySceneHost/MySceneHostVM.vb create mode 100644 MySceneHost/SceneWindowV.xaml create mode 100644 MySceneHost/SceneWindowV.xaml.vb create mode 100644 MySceneHost/SceneWindowVM.vb create mode 100644 Resources/RedArrow.png create mode 100644 Resources/WhiteArrow.png create mode 100644 SceneHost/SceneHostV.xaml create mode 100644 SceneHost/SceneHostV.xaml.vb create mode 100644 Utility/Utility.vb create mode 100644 Warehouse/BoxV.xaml create mode 100644 Warehouse/BoxV.xaml.vb delete mode 100644 Warehouse/WarehouseV.xaml diff --git a/Constants/ConstGen.vb b/Constants/ConstGen.vb index f594859..1eb696f 100644 --- a/Constants/ConstGen.vb +++ b/Constants/ConstGen.vb @@ -50,5 +50,44 @@ Module ConstGen Public Const TEMP_DIR As String = "Temp" ' Sottodirettorio backup Public Const LOG_DIR As String = "Log" + ' Sottodirettorio di default per le macchine + Public Const MACHINES_DFL_DIR As String = "Machines" + ' Sottodirettorio di default per toolmakers + Public Const TOOLMAKERS_DFL_DIR As String = "ToolMakers" + + ' Nome file corrente + Public Const CURR_PROJ_NAME As String = "CurrProj.nge" + Public Const CURR_PROJ_NEW As String = "CurrProj.new" + Public Const CURR_PROJ_LOCK As String = "CurrProj.lck" + Public Const CURR_PROJ_EPL As String = "CurrProj.epl" + Public Const CURR_PROJ_PPL As String = "CurrProj.ppl" + Public Const CURR_PROJ_CHANGE As String = "CurrProj.chg" + + ' Nome della superficie del grezzo + Public Const NAME_RAW_SOLID As String = "RawSolid" + ' Nome della regione fuori kerf nel grezzo + Public Const NAME_OUTKERF_REG As String = "SheetOut" + ' Nome della regione di riferimento nel grezzo + Public Const NAME_REF_REG As String = "RefReg" + + ' Contrassegno di progetto OmagCut + Public Const NAME_PROJMARK As String = "OmagCut" + ' Info per indice progetto + Public Const INFO_PROJINDEX As String = "ProjIndex" + ' Info per materiale progetto + Public Const INFO_PROJMAT As String = "ProjMat" + ' Info con path carico progetto + Public Const INFO_LOADPATH As String = "LoadPath" + ' Info per stato scarico progetto salvato + Public Const INFO_UNLOADSAVED As String = "UnloadSaved" + + ' Nome layer delle regioni + Public Const NAME_REGION As String = "Region" + ' Nome layer preview + Public Const NAME_PREVIEW As String = "PV" + ' Info per stato pezzo + Public Const INFO_PARTOK As String = "POK" + ' Info in pezzo con suo nome in Csv + Public Const INFO_CSV_PART As String = "CsvPart" End Module diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index acddb29..f3baaac 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -26,6 +26,7 @@ Module ConstIni Public Const K_MESSAGES As String = "Messages" Public Const K_WINPLACE As String = "WinPlace" Public Const K_SUPPORT As String = "Support" + Public Const K_PROJDIR As String = "ProjDir" Public Const S_LANGUAGES As String = "Languages" Public Const K_LANGUAGE As String = "Language" @@ -37,8 +38,36 @@ Module ConstIni Public Const K_SLOT As String = "Slot" Public Const K_TIMERINTERVAL As String = "TimerInterval" + Public Const S_OFFSET As String = "Offset" + Public Const K_PALLETX As String = "PalletX" + Public Const K_PALLETY As String = "PalletY" + Public Const K_PALLETZ As String = "PalletZ" + Public Const K_RACKX As String = "RackX" + Public Const K_RACKZ As String = "RackZ" + Public Const K_RACKY As String = "RackY" + Public Const K_ANGRACK As String = "AngRack" + Public Const K_RULLERX As String = "RullerX" + Public Const K_RULLERY As String = "RullerY" + + Public Const S_BOX As String = "Box" + Public Const K_MAX_HEIGHT As String = "MaxHeightPallet" + Public Const K_MAX_LENGTH As String = "MaxLengthPallet" + Public Const K_MAX_WIDTH As String = "MaxWidthPallet" + Public Const K_MAX_TILE As String = "MaxTileRack" + + Public Const S_WAREHOUSE As String = "Warehouse" + Public Const K_ACTIVESTORAGE As String = "ActiveStorage" + Public Const K_STORAGE As String = "Storage" + Public Const K_BOX As String = "Box" + Public Const S_VARIABLES As String = "Variables" Public Const K_ACTIVEWAREHOUSE As String = "ActiveWarehouse" + Public Const S_PART As String = "Part" + Public Const K_IDPART As String = "IdPart" + Public Const K_IDPROJ As String = "IdProj" + Public Const K_STATUS As String = "Status" + Public Const K_PLACE As String = "Place" + Public Const K_UNLOADING As String = "Unloading" End Module diff --git a/EgtStoneLib/CamAuto.vb b/EgtStoneLib/CamAuto.vb new file mode 100644 index 0000000..915f13e --- /dev/null +++ b/EgtStoneLib/CamAuto.vb @@ -0,0 +1,1404 @@ +Imports EgtUILib +Imports System.Collections.ObjectModel + +Friend Module CamAuto + + Private m_sCamAutoDir As String = String.Empty + Friend Sub SetCamAutoDir(sCamAutoDir As String) + m_sCamAutoDir = sCamAutoDir + End Sub + + Private m_RawPartList As New List(Of InfoRawPart) + + Public Class InfoRawPart + + Public ptOrig As Point3d + Public m_IdRaw As Integer + Public m_Lenght As Double + Public m_Width As Double + Public m_Height As Double + Public m_Color3d As Color3d + Public m_InfoPartList As New List(Of InfoPart) + + Sub New(nIdRaw As Integer, Orig As Point3d, dLenght As Double, dWidth As Double, dHeight As Double, cColor3d As Color3d, InfoPartList As List(Of InfoPart)) + m_IdRaw = nIdRaw + ptOrig = Orig + m_Lenght = dLenght + m_Width = dWidth + m_Height = dHeight + m_Color3d = cColor3d + m_InfoPartList = InfoPartList + End Sub + + End Class + + Public Class InfoPart + + Public ptOrig As Point3d + Public m_IdPart As Integer + Public m_DegC As Double + + Sub New(Orig As Point3d, IdPart As Integer, DegC As Double) + ptOrig = Orig + m_IdPart = IdPart + m_DegC = DegC + End Sub + + End Class + + 'Friend Function AddMachinings(nPartId As Integer) As Boolean + ' Dim nWarn As Integer = 0 + ' Return AddMachinings(nPartId, nWarn) + 'End Function + + 'Friend Function AddMachinings(nPartId As Integer, ByRef nWarn As Integer) As Boolean + ' Dim bDripOk As Boolean = VerifyVacuumsForDrip(nPartId) + ' If Not bDripOk Then nWarn = 1 + ' EgtLuaCreateGlobTable("CAM") + ' SetLuaStandardCamParams(bDripOk) + ' EgtLuaSetGlobIntVar("CAM.PARTID", nPartId) + ' Dim nErr As Integer = 999 + ' Dim bOk As Boolean = EgtLuaExecFile(m_sCamAutoDir & "\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 + ' ResetOrderMachiningFlag() + ' Return bOk + 'End Function + + 'Friend Function AddWaterJetMachining( nOperId As Integer, ByRef nWarn As Integer) As Boolean + ' EgtLuaCreateGlobTable("CAM") + ' SetLuaStandardCamParams() + ' EgtLuaSetGlobIntVar("CAM.OPERID", nOperId) + ' Dim nErr As Integer = 999 + ' Dim bOk As Boolean = EgtLuaExecFile(m_sCamAutoDir & "\CamAuto.lua") + ' bOk = bOk AndAlso EgtLuaGetGlobIntVar("CAM.ERR", nErr) AndAlso nErr = 0 + ' bOk = bOk AndAlso EgtLuaCallFunction("CAM.AddWaterJet") + ' 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 EraseMachinings(nPartId As Integer) As Boolean + ' EgtLuaCreateGlobTable("CAM") + ' EgtLuaSetGlobIntVar("CAM.PARTID", nPartId) + ' Dim nErr As Integer = 999 + ' Dim bOk As Boolean = EgtLuaExecFile(m_sCamAutoDir & "\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 + ' ResetOrderMachiningFlag() + ' Return bOk + 'End Function + + 'Friend Function ResetAllMachinings() As Boolean + ' Dim nWarn As Integer = 0 + ' Return ResetAllMachinings(nWarn) + 'End Function + + 'Friend Function ResetAllMachinings(ByRef nWarn As Integer) As Boolean + ' ' Cancello tutte le lavorazioni + ' EraseMachinings(GDB_ID.NULL) + ' ' Reinserisco tutte le lavorazioni piane (non sono previste le lavorazioni delle cornici) + ' AddMachinings(GDB_ID.NULL, nWarn) + ' 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 AndAlso EgtIsOperationEmpty(nOpeId) Then + EgtRemoveLastPhase() + Else + Exit While + End If + nOpeId = nPrevOpeId + End While + Return True + End Function + + Friend Function RemoveLastPhase() As Boolean + ' Non posso eliminare la prima fase + Dim nLastPhase As Integer = EgtGetPhaseCount() + If nLastPhase = 1 Then Return False + ' Sposto le lavorazioni in coda a quelle della fase precedente + Dim nDispId As Integer = EgtGetPhaseDisposition(nLastPhase) + Dim nMachId As Integer = EgtGetNextOperation(nDispId) + While nMachId <> GDB_ID.NULL + EgtChangeOperationPhase(nMachId, nLastPhase - 1) + nMachId = EgtGetNextOperation(nDispId) + End While + ' Rimuovo l'ultima fase + Return EgtRemoveLastPhase() + End Function + + 'Friend Function UpdateAllMachiningsToolpaths() As Boolean + ' EgtLuaCreateGlobTable("CAM") + ' SetLuaStandardCamParams() + ' Dim nErr As Integer = 999 + ' Dim bOk As Boolean = EgtLuaExecFile(m_sCamAutoDir & "\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_sCamAutoDir & "\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_sCamAutoDir & "\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 + ' ResetOrderMachiningFlag() + ' Return bOk + 'End Function + + 'Friend Function VerifyVacuumsForDrip(nPartId As Integer) As Boolean + ' ' Se un pezzo + ' If nPartId <> GDB_ID.NULL Then + ' ' Verifico contenga layer per lavorazioni da sotto con entità + ' If EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_DRIPCUT)) = 0 And + ' EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_UNDERDRILL)) = 0 Then + ' Return True + ' End If + ' ' Se tutti i pezzi + ' Else + ' ' Salvo fase attualmente corrente + ' Dim nOriPhase As Integer = EgtGetCurrPhase() + ' ' Ciclo su tutti i pezzi presenti nei grezzi dell'ultima fase di lavorazione + ' EgtSetCurrPhase(EgtGetPhaseCount()) + ' Dim bFound As Boolean = False + ' Dim nRawId As Integer = EgtGetFirstRawPart() + ' While nRawId <> GDB_ID.NULL + ' If EgtVerifyRawPartCurrPhase(nRawId) Then + ' Dim nMyPartId As Integer = EgtGetFirstPartInRawPart(nRawId) + ' While nMyPartId <> GDB_ID.NULL + ' ' se ci sono lavorazioni da sotto + ' If EgtGetGroupObjs(EgtGetFirstNameInGroup(nMyPartId, NAME_DRIPCUT)) > 0 Or + ' EgtGetGroupObjs(EgtGetFirstNameInGroup(nMyPartId, NAME_UNDERDRILL)) > 0 Then + ' bFound = True + ' End If + ' nMyPartId = EgtGetNextPartInRawPart(nPartId) + ' End While + ' End If + ' nRawId = EgtGetNextRawPart(nRawId) + ' End While + ' ' Ripristino fase corrente originale + ' EgtSetCurrPhase(nOriPhase) + ' ' Se non trovate lavorazioni da sotto, esco + ' If Not bFound Then Return True + ' End If + ' ' Verifico che il diametro della lama installata permetta l'utilizzo della ventosa + ' Dim dSawDiam As Double + ' If EgtTdbSetCurrTool(CurrentMachine.sCurrSaw) AndAlso + ' EgtTdbGetCurrToolParam(MCH_TP.DIAM, dSawDiam) Then + ' Return (dSawDiam <= CurrentMachine.dMaxSawDiamForVac) + ' End If + ' Return False + '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 lavorazioni da sotto nel pezzo si processa + If EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_DRIPCUT)) > 0 Or + EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_UNDERDRILL)) > 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 nMGrpId As Integer = EgtGetCurrMachGroup() + If b3Tot.IsEmpty Then + Return EgtRemoveInfo(nMGrpId, INFO_DRIPBBOX) + Else + Return EgtSetInfo(nMGrpId, INFO_DRIPBBOX, b3Tot) + End If + ' Ripristino fase corrente originale + EgtSetCurrPhase(nOriPhase) + Return bOk + End Function + + ' posizionamento vetnotose TavoloScarico-Tappeto + Friend Function MyUpdateVacuumsForUnloading() As Boolean + Map.refMainWindowVM.MainWindowM.ProjIndList(Map.refMainWindowVM.MainWindowM.ProjIndList.Count - 1).enStatus = StatusProj.LOADING + Dim PartsList As New List(Of Part) + Dim PartsListManual As New List(Of Part) + Dim bOk As Boolean = True + Dim nIndex As Integer = 1 + + ' Salvo fase attualmente corrente + Dim nOriPhase As Integer = EgtGetCurrPhase() + ' Carico le ventose + LoadVacuumCups() + ' Ciclo su tutti i pezzi presenti nei grezzi dell'ultima fase di lavorazione + EgtSetCurrPhase(EgtGetPhaseCount()) + ' recupero l'Id del porgetto in lattura + Dim nProjId As Integer = Map.refMainWindowVM.MainWindowM.nProjInd + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + ' ottengo il grezzo (per il calcolo dell'altezza) + Dim b3RawPart As New BBox3d + EgtGetRawPartBBox(nRawId, b3RawPart) + Dim InfoPartList As New List(Of InfoPart) + If EgtVerifyRawPartCurrPhase(nRawId) Then + Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId) + While nPartId <> GDB_ID.NULL + ' reset eventuali vecchie informazioni + RemoveOneMoveInfo(nPartId) + ' creo le variabili per il posizionamento delle ventose sul tavolo 1 + Dim rmData As New RawMoveData + Dim b3Part As New BBox3d + ' verifico di posizionare le ventose correttamente + If MyPutVacuumCupsOnPart(nPartId, rmData, b3Part) Then + SaveOneMoveInfo(nPartId, rmData) + Dim TmpPart As New Part(nPartId, nProjId) + ' recupero le dimensioni del minimo rettangolo -> dal vettore che unisce il centro pezzo con il vertice in alto a sinistra + TmpPart.MinRectY = rmData.m_vtRect.y * 2 + TmpPart.MinRectX = rmData.m_vtRect.x * 2 + + Dim ptCenT As New Point3d + If EgtGetPartCenter(nPartId, ptCenT) Then + ' salvo le posizioni delle ventose + TmpPart.SetInfoTable1(rmData, b3RawPart.DimZ) + ' salvo il punto ptCent del pezzo + TmpPart.SetCenterPartTable(ptCenT) + + '--------------------------- CONTROLLARE LA POSIZIONE DEL BARICENTRO ------------------------------------- + ' ruoto il pezzo e lo posziono in alto a sinistra + EgtRotate(nPartId, rmData.m_ptCenMinRect, Vector3d.Z_AX, TmpPart.DegAngOnTable, GDB_RT.GLOB) + ' ruoto il versore Y del rettangolo + rmData.m_vtOrtoDirX.Rotate(Vector3d.Z_AX, TmpPart.DegAngOnTable) + + Dim vtMove As New Vector3d + ' calcolo l'offset in alto a sinistra del rettangolo di riferimento + Dim vtRectTopLeft As New Vector3d(rmData.m_vtRect) + vtRectTopLeft.Rotate(rmData.m_vtOrtoDirX, 180) + Dim vtRuller As Vector3d = New Vector3d(Map.refUnloadingAreaVM.OffsetRullerX, Map.refUnloadingAreaVM.OffsetRullerY, 0) + ' definisco il centro del rettangolo sul pezzo + vtMove = vtRuller - (TmpPart.GetPointOnTable1(rmData.m_ptCenMinRect) - Point3d.ORIG + vtRectTopLeft) + vtMove.z = 0 + EgtMove(nPartId, vtMove) + + ' reset eventuali vecchie informazioni + RemoveOneMoveInfo(nPartId) + ' creo le variabili per il posizionamento delle ventose sul tavolo 2 + Dim rmData2 As New RawMoveData + Dim b3Part2 As New BBox3d + If MyPutVacuumCupsOnPart(nPartId, rmData2, b3Part2) Then + TmpPart.SetInfoTable2(rmData2) + Else + EgtOutLog("Error on UpdateVacuums in Part Table2" & nPartId.ToString()) + End If + + ' riposiziono tutto come all'inizio (per avere la disposizione corretta) + EgtMove(nPartId, -vtMove) + EgtRotate(nPartId, rmData.m_ptCenMinRect, Vector3d.Z_AX, -TmpPart.DegAngOnTable, GDB_RT.GLOB) + + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nPartId, nStat) + ' aggiorno la lista dei pezzi dal più grande al più piccolo + If nStat = GDB_ST.SEL Then + TmpPart.enUnloading = Unloading.MANUAL + ' pezzi manuli + If PartsListManual.Count = 0 Then + PartsListManual.Add(TmpPart) + Else + Dim bIsInsert As Boolean = False + For i = 0 To PartsListManual.Count - 1 + If TmpPart.MinRectY > PartsListManual(i).MinRectY Then + PartsListManual.Insert(i, TmpPart) + bIsInsert = True + Exit For + End If + Next + If Not bIsInsert Then + PartsListManual.Add(TmpPart) + End If + End If + Else + ' pezzi automatici + If PartsList.Count = 0 Then + PartsList.Add(TmpPart) + Else + Dim bIsInsert As Boolean = False + For i = 0 To PartsList.Count - 1 + If TmpPart.MinRectY > PartsList(i).MinRectY Then + PartsList.Insert(i, TmpPart) + bIsInsert = True + Exit For + End If + Next + If Not bIsInsert Then + PartsList.Add(TmpPart) + End If + End If + End If + + Dim b3Part3 As New BBox3d + EgtGetBBoxGlob(nPartId, 1, b3Part3) + ' salvo le informazioni per creare la nuova lavorazione + InfoPartList.Add(New InfoPart(b3Part3.Min, nPartId, rmData.m_dAngRotDeg)) + TmpPart.SavePart(nIndex) + nIndex = nIndex + 1 + End If + + Else + bOk = False + EgtOutLog("Error on UpdateVacuums in Part Table1" & nPartId.ToString()) + End If + nPartId = EgtGetNextPartInRawPart(nPartId) + End While + MyCopyRawParts(nRawId, InfoPartList) + End If + nRawId = EgtGetNextRawPart(nRawId) + End While + + '------------------ + 'MyNewMachGroup() + '------------------ + + ' Scarico le ventose + RemoveVacuumCups() + ' Ripristino fase corrente originale + EgtSetCurrPhase(nOriPhase) + ' restituisco l'elenco dei pezzi (prima gli automatici e poi quelli manuali) + If Not IsNothing(Map.refUnloadingAreaVM) Then + For Each ItemPart In PartsList + Map.refUnloadingAreaVM.ListPart.Add(ItemPart) + Next + For Each ItemPartManual In PartsListManual + Map.refUnloadingAreaVM.ListPart.Add(ItemPartManual) + Next + ' notifico l'ultimo pezzo + Map.refUnloadingAreaVM.ListPart(Map.refUnloadingAreaVM.ListPart.Count - 1).SetIsLast(True) + End If + + Return bOk + End Function + + Public Sub MyCopyRawParts(nRawId As Integer, InfoPartList As List(Of InfoPart)) + ' aggiungo un nuovo RawPart + Dim ptCenterRawPart As New Point3d + Dim b3RawPart As New BBox3d + EgtGetRawPartCenter(nRawId, ptCenterRawPart) + EgtGetRawPartBBox(nRawId, b3RawPart) + m_RawPartList.Add(New InfoRawPart(nRawId, b3RawPart.Min, b3RawPart.DimX, b3RawPart.DimY, b3RawPart.DimZ, New Color3d(0, 255, 255, 80), InfoPartList)) + 'EgtAddRawPart( Point3d ptOrig, num dLength, num dWidth, num dHeight, Color3d Col) + End Sub + + Public Sub MyNewMachGroup() + EgtAddMachGroup("Nome_Macchinata", "Omag-MultiCutNC-S") + For Each ItemRaw In m_RawPartList + Dim nRawId As Integer = EgtAddRawPart(ItemRaw.ptOrig, ItemRaw.m_Lenght, ItemRaw.m_Width, ItemRaw.m_Height, ItemRaw.m_Color3d) + For Each ItemPart In ItemRaw.m_InfoPartList + EgtAddPartToRawPart(ItemPart.m_IdPart, Point3d.ORIG + (ItemPart.ptOrig - ItemRaw.ptOrig), nRawId) + Next + Next + End Sub + + 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 + ' Dim sTool2 As String = String.Empty + ' EgtGetMachiningParam(MCH_MP.TUUID, sTuuid) + ' EgtTdbGetToolFromUUID(sTuuid, sTool) + ' If String.IsNullOrWhiteSpace( sTool) Then + ' Dim sMchTool As String = "" + ' EgtGetMachiningParam( MCH_MP.TOOL, sMchTool) + ' bOk = False + ' If sMissingTools.IndexOf(sMchTool) = -1 Then + ' sMissingTools = sMissingTools & sMchTool & ", " + ' End If + ' ElseIf 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 + ' sTool2 = sTool & "-2" + ' End If + ' If String.Compare(sTool, CurrentMachine.sCurrSaw) <> 0 AndAlso + ' ( String.IsNullOrWhiteSpace( sTool2) OrElse String.Compare(sTool2, CurrentMachine.sCurrSaw) <> 0) AndAlso + ' String.Compare(sTool, 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, CurrentMachine.sCurrDrill) <> 0 And + ' String.Compare(sTool, CurrentMachine.sCurrDripDrill) <> 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 + ' ' Verifico anche le lame come in OmagCUT anche se qui non gestisco cornici + ' If String.Compare(sTool, CurrentMachine.sCurrMill) <> 0 And + ' Not FindToolOnChanger(sTool) And + ' String.Compare(sTool, CurrentMachine.sCurrSaw) <> 0 Then + ' bOk = False + ' If sMissingTools.IndexOf(sTool) = -1 Then + ' sMissingTools = sMissingTools & sTool & ", " + ' End If + ' End If + ' ElseIf nType = MCH_OY.WATERJETTING Then + ' If String.Compare(sTool, CurrentMachine.sCurrWaterJet) <> 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 CurrentMachine.ToolChangerNbr() - 1 + ' If String.Compare(sTool, CurrentMachine.ToolChanger(i).sTool) = 0 Then + ' Return True + ' End If + ' Next + ' ' Ricerca nel cambia utensili manuale + ' For i As Integer = 0 To CurrentMachine.ManualToolChangerNbr() - 1 + ' If String.Compare(sTool, 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, CurrentMachine.sMachIniFile) + ' ' Ciclo sulle lavorazioni + ' Dim nOperId As Integer = EgtGetFirstOperation() + ' While nOperId <> GDB_ID.NULL + ' ' verifico sia una lavorazione valida di taglio con lama + ' If IsValidMachining( nOperId) And EgtGetOperationType( nOperId) = MCH_OY.SAWING 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 + ' ' se abilitato e attivo waterjet, lo aggiungo per completare il taglio + ' If CurrentMachine.WaterJettingActive Then + ' Dim nWarn As Integer = 0 + ' AddWaterJetMachining(nOperId, nWarn) + ' End If + ' 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, CurrentMachine.sMachIniFile) + ' ' 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 dUserAddLen As Double = 0 + ' EgtGetInfo( nMchId, INFO_MCH_USER_SAL, dUserAddLen) + ' EgtRemoveInfo( nMchId, INFO_MCH_USER_SAL) + ' Dim dAddLen As Double = 0 + ' EgtGetMachiningParam(MCH_MP.STARTADDLEN, dAddLen) + ' EgtSetMachiningParam(MCH_MP.STARTADDLEN, dAddLen - dUserAddLen - 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 dUserAddLen As Double = 0 + ' EgtGetInfo( nMchId, INFO_MCH_USER_EAL, dUserAddLen) + ' EgtRemoveInfo( nMchId, INFO_MCH_USER_EAL) + ' Dim dAddLen As Double = 0 + ' EgtGetMachiningParam(MCH_MP.ENDADDLEN, dAddLen) + ' EgtSetMachiningParam(MCH_MP.ENDADDLEN, dAddLen - dUserAddLen - 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, CurrentMachine.sMachIniFile) + ' ' 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 SetPause(nMchId As Integer) As Boolean + Return EgtSetInfo(nMchId, INFO_MCH_PAUSE, True) + End Function + + Friend Function GetPause(nMchId As Integer) As Boolean + Dim bPause As Boolean = False + EgtGetInfo(nMchId, INFO_MCH_PAUSE, bPause) + Return bPause + End Function + + Friend Function ResetPause(nMchId As Integer) As Boolean + Return EgtRemoveInfo(nMchId, INFO_MCH_PAUSE) + 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 + ' Indice gruppo di preview nella lavorazione + Dim nMchPvId As Integer = EgtGetFirstNameInGroup(nMchId, ConstMach.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, ConstMach.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, ConstMach.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(Optional bDripOk As Boolean = True) As Boolean + ' Dim sSawMch As String = CurrentMachine.sCurrSawing + ' Dim sMillMch As String = CurrentMachine.sCurrMilling + ' Dim sDrillMch As String = CurrentMachine.sCurrDrilling + ' Dim sWaterJetMch As String = CurrentMachine.sCurrWaterJetting + ' Dim sDripSawMch As String = If(bDripOk, CurrentMachine.sCurrDripSawing, "") + ' Dim sDripDrillMch As String = If(bDripOk, CurrentMachine.sCurrDripDrilling, "") + ' Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, CurrentMachine.sMachIniFile) + ' Dim dHolesOffset As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OFFSET, 0, CurrentMachine.sMachIniFile) + ' Dim dHolesOverlap As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OVERLAP, 0, CurrentMachine.sMachIniFile) + ' Dim dCutSafety As Double = Math.Max(GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_CUT, 1, CurrentMachine.sMachIniFile), 10 * EPS_SMALL) + ' Dim dCornerSafety As Double = Math.Max(GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_INTCORNER, 1, CurrentMachine.sMachIniFile), 10 * EPS_SMALL) + ' Dim bOneHoleIntCorner As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_ONEHOLE_INTCORNER, 0, CurrentMachine.sMachIniFile) <> 0) + ' Dim bMillingOnCorners As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_MILLING_ON_CORNERS, 1, CurrentMachine.sMachIniFile) <> 0) + ' Dim bMillingOnSinks As Boolean = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_MILLING_ON_SINKS, 0, CurrentMachine.sMachIniFile) <> 0) + ' Dim dMillingShort As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_MILLING_SHORTENING, 0, CurrentMachine.sMachIniFile) + ' EgtLuaSetGlobStringVar("CAM.SAWMCH", sSawMch) + ' EgtLuaSetGlobStringVar("CAM.MILLMCH", sMillMch) + ' EgtLuaSetGlobStringVar("CAM.DRILLMCH", sDrillMch) + ' EgtLuaSetGlobStringVar("CAM.WATERJETMCH", sWaterJetMch) + ' EgtLuaSetGlobStringVar("CAM.DRIPSAWMCH", sDripSawMch) + ' EgtLuaSetGlobStringVar("CAM.DRIPDRILLMCH", sDripDrillMch) + ' EgtLuaSetGlobNumVar("CAM.REDUCEDDEPTH", dReducedDepth) + ' EgtLuaSetGlobNumVar("CAM.HOLESOFFSET", dHolesOffset) + ' EgtLuaSetGlobNumVar("CAM.HOLESOVERLAP", dHolesOverlap) + ' EgtLuaSetGlobBoolVar("CAM.ONEHOLEINTCORNER", bOneHoleIntCorner) + ' EgtLuaSetGlobNumVar("CAM.CUTSAFETY", dCutSafety) + ' EgtLuaSetGlobNumVar("CAM.CORNERSAFETY", dCornerSafety) + ' EgtLuaSetGlobBoolVar("CAM.MILLINGONCORNERS", bMillingOnCorners) + ' EgtLuaSetGlobBoolVar("CAM.MILLINGONSINKS", bMillingOnSinks) + ' EgtLuaSetGlobNumVar("CAM.MILLINGSHORT", dMillingShort) + ' EgtLuaSetGlobNumVar("CAM.RAWHEIGHT", GetRawHeight()) + ' EgtLuaSetGlobNumVar("CAM.REGROT", 0.0) + ' 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 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 = EgtGetFirstRawPart() + ' 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 + ' ' Aggiungo taglio singolo + ' If Not AddFrameSawSingle() 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 = EgtGetFirstRawPart() + ' If nRawId = GDB_ID.NULL Then Return False + ' ' Se non ci sono pezzi, esco + ' Dim nPart1Id As Integer = EgtGetFirstPartInRawPart( nRawId) + ' If nPart1Id = GDB_ID.NULL Then Return True + ' ' Verifico se cornice curva + ' Dim nDir As Integer = 0 + ' EgtGetInfo(nPart1Id, INFO_FRAME_DIR, nDir) + ' Dim bSwap As Boolean = ( nDir = 0) + ' Dim bCurved As Boolean = ( nDir >= 2) + ' ' Recupero la lavorazione corrente di sgrossatura con lama + ' Dim sCurrSawRou As String = CurrentMachine.sCurrSawRoughing + ' If String.IsNullOrEmpty(sCurrSawRou) Then Return True + ' ' Inserisco la lavorazione corrente + ' Dim nMchId As Integer = EgtAddMachining(NAME_FRAME_SAWROU, sCurrSawRou) + ' 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, If( bSwap, -dTrimEnd, -dTrimStart)) + ' EgtSetMachiningParam(MCH_MP.ENDADDLEN, If( bSwap, -dTrimStart, -dTrimEnd)) + ' ' Se cornice curva, imposto SCC + ' If bCurved Then EgtSetMachiningParam(MCH_MP.SOLCHOICETYPE, MCH_SCC.ADIR_NEAR) + ' ' 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 = EgtGetFirstRawPart() + ' If nRawId = GDB_ID.NULL Then Return False + ' ' Se non ci sono pezzi, esco + ' Dim nPart1Id As Integer = EgtGetFirstPartInRawPart( nRawId) + ' If nPart1Id = GDB_ID.NULL Then Return True + ' ' Verifico se cornice curva + ' Dim nDir As Integer = 0 + ' EgtGetInfo( nPart1Id, INFO_FRAME_DIR, nDir) + ' Dim bSwap As Boolean = ( nDir = 0) + ' Dim bCurved As Boolean = ( nDir >= 2) + ' ' Recupero la lavorazione corrente di finitura con lama + ' Dim sCurrSawFin As String = CurrentMachine.sCurrSawFinishing + ' If String.IsNullOrEmpty(sCurrSawFin) Then Return True + ' ' Inserisco la lavorazione corrente + ' Dim nMchId As Integer = EgtAddMachining(NAME_FRAME_SAWFIN, sCurrSawFin) + ' 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, If( bSwap, -dTrimEnd, -dTrimStart)) + ' EgtSetMachiningParam(MCH_MP.ENDADDLEN, If( bSwap, -dTrimStart, -dTrimEnd)) + ' ' Se cornice curva, imposto SCC + ' If bCurved Then EgtSetMachiningParam(MCH_MP.SOLCHOICETYPE, MCH_SCC.ADIR_NEAR) + ' ' 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 = EgtGetFirstRawPart() + ' If nRawId = GDB_ID.NULL Then Return False + ' ' Se non ci sono pezzi, esco + ' Dim nPart1Id As Integer = EgtGetFirstPartInRawPart( nRawId) + ' If nPart1Id = GDB_ID.NULL Then Return True + ' ' Verifico se cornice curva + ' Dim nDir As Integer = 0 + ' EgtGetInfo(nPart1Id, INFO_FRAME_DIR, nDir) + ' Dim bSwap As Boolean = ( nDir = 0) + ' Dim bCurved As Boolean = ( nDir >= 2) + ' ' Recupero la lavorazione corrente di spatolatura con lama + ' Dim sCurrSawSideFin As String = CurrentMachine.sCurrSawSideFinishing + ' If String.IsNullOrEmpty(sCurrSawSideFin) Then Return True + ' ' Inserisco la lavorazione corrente + ' Dim nMchId As Integer = EgtAddMachining(NAME_FRAME_SAWSIDEFIN, sCurrSawSideFin) + ' 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, If( bSwap, -dTrimEnd, -dTrimStart)) + ' EgtSetMachiningParam(MCH_MP.ENDADDLEN, If( bSwap, -dTrimStart, -dTrimEnd)) + ' ' Se cornice curva, imposto SCC + ' If bCurved Then EgtSetMachiningParam(MCH_MP.SOLCHOICETYPE, MCH_SCC.ADIR_NEAR) + ' ' Applico la lavorazione + ' Return EgtApplyMachining(False) + 'End Function + + 'Friend Function AddFrameSawSingle() As Boolean + ' ' Cancello la lavorazione di taglio singolo + ' Dim nId As Integer = EgtGetOperationId(NAME_FRAME_SAWSINGLE) + ' EgtRemoveOperation(nId) + ' ' Recupero il grezzo corrente + ' Dim nRawId As Integer = GetCurrentRaw() + ' Dim nSolidId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID) + ' If nRawId = GDB_ID.NULL Or nSolidId = GDB_ID.NULL Then Return False + ' Dim b3Raw As New BBox3d + ' GetRawBox(b3Raw) + ' ' Se non ci sono pezzi, esco + ' If EgtGetPartInRawPartCount(nRawId) = 0 Then Return True + ' ' Recupero la lavorazione corrente di taglio singolo con lama + ' Dim sCurrSawSingle = CurrentMachine.sCurrSawSingle + ' If String.IsNullOrEmpty(sCurrSawSingle) Then Return True + ' ' Creo la lavorazione a partire dalla corrente + ' If Not EgtMdbSetCurrMachining(sCurrSawSingle) Then Return False + ' Dim sTuuid As String = String.Empty + ' Dim sTool As String = String.Empty + ' EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTuuid) + ' EgtTdbGetToolFromUUID(sTuuid, sTool) + ' EgtTdbSetCurrTool(sTool) + ' Dim dMaxMat As Double = 50 + ' EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dMaxMat) + ' Dim dTDiam As Double = 200 + ' EgtTdbGetCurrToolParam(MCH_TP.DIAM, dTDiam) + ' Dim nStepType As Integer = MCH_SAW_ST.ZIGZAG + ' EgtMdbGetCurrMachiningParam(MCH_MP.STEPTYPE, nStepType) + ' Dim dStep As Double = 0 + ' EgtMdbGetCurrMachiningParam(MCH_MP.STEP_, dStep) + ' Dim nLiType As Integer = MCH_SAW_LI.CENT + ' EgtMdbGetCurrMachiningParam(MCH_MP.LEADINTYPE, nLiType) + ' Dim nLoType As Integer = MCH_SAW_LO.CENT + ' EgtMdbGetCurrMachiningParam(MCH_MP.LEADOUTTYPE, nLoType) + ' Dim dSpeed As Double = 0 + ' EgtMdbGetCurrMachiningParam(MCH_MP.SPEED, dSpeed) + ' Dim dFeed As Double = 0 + ' EgtMdbGetCurrMachiningParam(MCH_MP.FEED, dFeed) + ' Dim dStartFeed As Double = 0 + ' EgtMdbGetCurrMachiningParam(MCH_MP.STARTFEED, dStartFeed) + ' Dim dEndFeed As Double = 0 + ' EgtMdbGetCurrMachiningParam(MCH_MP.ENDFEED, dEndFeed) + ' Dim dTipFeed As Double = 0 + ' EgtMdbGetCurrMachiningParam(MCH_MP.TIPFEED, dTipFeed) + ' Dim nMchId As Integer = EgtCreateMachining(NAME_FRAME_SAWSINGLE, MCH_MY.MILLING, sTool) + ' If nMchId = GDB_ID.NULL Then Return False + ' ' Recupero Id superficie e Ind facet + ' Dim nSurfId As Integer = GDB_ID.NULL + ' Dim nFacetInd As Integer = -1 + ' Dim nPirId As Integer = EgtGetFirstPartInRawPart(nRawId) + ' While nPirId <> GDB_ID.NULL + ' If EgtGetInfo(nPirId, INFO_FRAME_SURF, nSurfId) And + ' EgtGetInfo(nPirId, INFO_FRAME_FACET, nFacetInd) Then + ' Exit While + ' End If + ' nPirId = EgtGetNextPartInRawPart(nPirId) + ' End While + ' ' Recupero dati facet + ' Dim ptCen As Point3d + ' Dim vtN As Vector3d + ' If Not EgtSurfTmFacetCenter(nSurfId, nFacetInd, GDB_ID.ROOT, ptCen, vtN) Then Return False + ' ' Imposto la geometria + ' EgtSetMachiningGeometry({nSurfId}, {nFacetInd}) + ' ' Calcolo adiacenze + ' Dim vAdj As New List(Of Integer) + ' If Not EgtSurfTmFacetAdjacencies(nSurfId, nFacetInd, vAdj) Then Return False + ' ' Verifico facce adiacenti + ' Dim ptAdjCen As Point3d + ' Dim vtAdjN As Vector3d = Vector3d.NULL + ' For Each nAdj As Integer In vAdj + ' ' Ciclo sulle adiacenze del solo primo loop (esterno) + ' If nAdj = STM_FACETADJ_ENDLOOP Then Exit For + ' ' Verifico tipo di adiacenza + ' Dim bAdj As Boolean = False + ' Dim ptP1 As Point3d + ' Dim ptP2 As Point3d + ' Dim dAng As Double + ' If Not EgtSurfTmFacetsContact(nSurfId, nFacetInd, nAdj, GDB_ID.ROOT, bAdj, ptP1, ptP2, dAng) Then Return False + ' If dAng < 0 Then + ' ' Non sono ammesse due facce limitanti + ' If Not vtAdjN.IsSmall() Then Return False + ' ' Recupero la normale della faccia limitante + ' If Not EgtSurfTmFacetCenter(nSurfId, nAdj, GDB_ID.ROOT, ptAdjCen, vtAdjN) Then Return False + ' End If + ' Next + ' ' Proprietà faccia + ' Dim bHorizz As Boolean = (Math.Abs(vtN.x) < EPS_SMALL And Math.Abs(vtN.y) < EPS_SMALL) + ' Dim bFree As Boolean = (vtAdjN.IsSmall() OrElse (ptCen.z > ptAdjCen.z And vtN.z > -EPS_SMALL)) + ' Dim bLeftSide As Boolean = (vtN.z >= -EPS_SMALL) + ' Dim dElev As Double = 0 + ' Dim dStartDist As Double = 0 + ' Dim dEndDist As Double = 0 + ' ' Se faccia orizzontale non limitata da altre o sopra la limitante + ' If bHorizz And bFree Then + ' ' recupero ingombro della faccia + ' Dim nCopyId As Integer = EgtCopySurfTmFacet(nSurfId, nFacetInd, EgtGetParent(nSurfId)) + ' If nCopyId = GDB_ID.NULL Then Return False + ' Dim b3Copy As New BBox3d + ' EgtGetBBoxGlob(nCopyId, GDB_BB.STANDARD, b3Copy) + ' EgtErase(nCopyId) + ' If b3Copy.IsEmpty() Then Return False + ' ' assegno parametri lavorazione faccia + ' If b3Copy.DimY() >= b3Copy.DimX() Then + ' If (b3Raw.Max().x - b3Copy.Min().x) <= (b3Copy.Max().x - b3Raw.Min().x) Then + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_LEFT) + ' dElev = b3Raw.Max().x - b3Copy.Min().x + ' dStartDist = b3Raw.Max().y - b3Copy.Max().y + ' dEndDist = b3Copy.Min().y - b3Raw.Min().y + ' Else + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_RIGHT) + ' dElev = b3Copy.Max().x - b3Raw.Min().x + ' dStartDist = b3Copy.Min().y - b3Raw.Min().y + ' dEndDist = b3Raw.Max().y - b3Copy.Max().y + ' End If + ' Else + ' If (b3Raw.Max().y - b3Copy.Min().y) <= (b3Copy.Max().y - b3Raw.Min().y) Then + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_FRONT) + ' dElev = b3Raw.Max().y - b3Copy.Min().y + ' dStartDist = b3Copy.Min().x - b3Raw.Min().x + ' dEndDist = b3Raw.Max().x - b3Copy.Max().x + ' Else + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_BACK) + ' dElev = b3Copy.Max().y - b3Raw.Min().y + ' dStartDist = b3Raw.Max().x - b3Copy.Max().x + ' dEndDist = b3Copy.Min().x - b3Raw.Min().x + ' End If + ' End If + ' If Not bLeftSide Then + ' Dim dTemp As Double = dStartDist + ' dStartDist = dEndDist + ' dEndDist = dTemp + ' End If + ' ' altrimenti + ' Else + ' Dim vtSide As Vector3d + ' ' Se faccia non limitata da altre o sopra la limitante + ' If bFree Then + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_DOWN) + ' vtSide = Vector3d.Z_AX() + ' ' altrimenti è stata trovata una faccia adiacente limitante + ' Else + ' If vtAdjN.x > 10 * EPS_SMALL Then + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_LEFT) + ' vtSide = Vector3d.X_AX() + ' ElseIf vtAdjN.x < -10 * EPS_SMALL Then + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_RIGHT) + ' vtSide = -Vector3d.X_AX() + ' ElseIf vtAdjN.y > 10 * EPS_SMALL Then + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_FRONT) + ' vtSide = Vector3d.Y_AX() + ' ElseIf vtAdjN.y < -10 * EPS_SMALL Then + ' EgtSetMachiningParam(MCH_MP.FACEUSE, MCH_MIL_FU.ORTUP_BACK) + ' vtSide = -Vector3d.Y_AX() + ' End If + ' End If + ' ' Calcolo elevazione + ' Dim ptP1, ptP2 As Point3d + ' If Not EgtSurfTmFacetOppositeSide(nSurfId, nFacetInd, vtSide, GDB_ID.ROOT, ptP1, ptP2) Then Return False + ' Dim ptPM As Point3d = Point3d.Media(ptP1, ptP2) + ' Dim vtElev As Vector3d = vtN ^ (vtSide ^ vtN) + ' If Not vtElev.Normalize() Then Return False + ' Dim vInters As New List(Of FlagPar) + ' If Not EgtLineSurfTmInters(ptPM, vtElev, nSolidId, GDB_ID.ROOT, vInters) Then Return False + ' If vInters.Count() = 0 OrElse vInters(vInters.Count() - 1).dPar <= EPS_SMALL Then + ' If Not EgtLineSurfTmInters(ptPM, vtElev, nSurfId, GDB_ID.ROOT, vInters) Then Return False + ' End If + ' If vInters.Count() > 0 AndAlso vInters(vInters.Count() - 1).dPar > EPS_SMALL Then + ' dElev = vInters(vInters.Count() - 1).dPar + ' Else + ' dElev = dMaxMat + ' End If + ' ' Calcolo distanze iniziale e finale + ' Dim vtTg As Vector3d = ptP2 - ptP1 + ' If Not vtTg.Normalize() Then Return False + ' If Not EgtLineSurfTmInters(ptP1, -vtTg, nSolidId, GDB_ID.ROOT, vInters) Then Return False + ' If vInters.Count() > 0 AndAlso vInters(vInters.Count() - 1).dPar > EPS_SMALL Then + ' dStartDist = vInters(vInters.Count() - 1).dPar + ' Else + ' dStartDist = 0 + ' End If + ' If Not EgtLineSurfTmInters(ptP2, vtTg, nSolidId, GDB_ID.ROOT, vInters) Then Return False + ' If vInters.Count() > 0 AndAlso vInters(vInters.Count() - 1).dPar > EPS_SMALL Then + ' dEndDist = vInters(vInters.Count() - 1).dPar + ' Else + ' dEndDist = 0 + ' End If + ' End If + ' ' Imposto SCC + ' EgtSetMachiningParam(MCH_MP.SOLCHOICETYPE, MCH_SCC.ADIR_NEAR) + ' ' Imposto lato di correzione + ' EgtSetMachiningParam(MCH_MP.WORKSIDE, If(bLeftSide, MCH_MIL_WS.LEFT, MCH_MIL_WS.RIGHT)) + ' ' Annullo affondamento + ' EgtSetMachiningParam(MCH_MP.DEPTH, 0.0) + ' ' Se elevazione superiore a massimo materiale, riduco opportunamento per non collidere + ' If dElev > dMaxMat Then + ' EgtSetMachiningParam(MCH_MP.OFFSR, (dElev - dMaxMat)) + ' dElev = dMaxMat + ' End If + ' ' Se richiesto, imposto step di lato + ' EgtSetMachiningParam(MCH_MP.STEPTYPE, If(nStepType = MCH_SAW_ST.ONEWAY, MCH_MIL_ST.ONEWAY, MCH_MIL_ST.ZIGZAG)) + ' If dStep >= EPS_SMALL And dStep < dElev Then + ' EgtSetMachiningParam(MCH_MP.STEP_, dStep) + ' EgtSetMachiningParam(MCH_MP.USERNOTES, "SideElev=" & dElev.ToString() & ";") + ' End If + ' ' Recupero la distanza di sicurezza + ' Dim dSafeZ As Double = CurrentMachine.dSafeZ() + ' ' Imposto attacco e uscita + ' Dim dTgAgg As Double = Math.Sqrt(dElev * (dTDiam - dElev)) + ' EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_MIL_LI.LINEAR) + ' If nLiType = MCH_SAW_LI.CENT Or nLiType = MCH_SAW_LI.STRICT Then + ' EgtSetMachiningParam(MCH_MP.LIPERP, dElev + dSafeZ) + ' Else + ' EgtSetMachiningParam(MCH_MP.LITANG, dStartDist + dTgAgg + dSafeZ) + ' End If + ' EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_MIL_LO.LINEAR) + ' If nLoType = MCH_SAW_LO.CENT Or nLoType = MCH_SAW_LO.STRICT Then + ' EgtSetMachiningParam(MCH_MP.LOPERP, dElev + dSafeZ) + ' Else + ' EgtSetMachiningParam(MCH_MP.LOTANG, dEndDist + dTgAgg + dSafeZ) + ' End If + ' ' Imposto speed e feed + ' EgtSetMachiningParam(MCH_MP.SPEED, dSpeed) + ' EgtSetMachiningParam(MCH_MP.FEED, dFeed) + ' EgtSetMachiningParam(MCH_MP.STARTFEED, dStartFeed) + ' EgtSetMachiningParam(MCH_MP.ENDFEED, dEndFeed) + ' EgtSetMachiningParam(MCH_MP.TIPFEED, dTipFeed) + ' ' Applico la lavorazione + ' Return EgtApplyMachining(False) + 'End Function + +End Module diff --git a/EgtStoneLib/ConstMach.vb b/EgtStoneLib/ConstMach.vb new file mode 100644 index 0000000..4efc23a --- /dev/null +++ b/EgtStoneLib/ConstMach.vb @@ -0,0 +1,319 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2017 +'---------------------------------------------------------------------------- +' File : ConstMach.vb Data : 10.04.17 Versione : 1.8d1 +' Contenuto : Modulo costanti per lavorazioni/macchina. +' +' +' +' Modifiche : 10.04.17 DS Creazione modulo. +' +' +'---------------------------------------------------------------------------- +Imports EgtUILib + +Module ConstMach + + ' Delta Z sovratavola per evitare problemi di visualizzazione texture + Public Const DELTAZ_ADDTAB As Double = 0.1 + ' Nome gruppo dei sottopezzi + Public Const MACH_FIXT_GROUP As String = "Fixt" + ' Nome tavola addizionale nel gruppo dei sottopezzi + Public Const MACH_ADD_TABLE As String = "AddTab" + ' Info altezza tavola addizionale nella tavola + Public Const KEY_ADD_TABLE As String = "AddTab" + + ' Nome testa con ventose per spostamento pezzi + Public Const VACUUM_HEAD As String = "H4" + ' Info tipo ventosa + Public Const KEY_VAC_TYPE As String = "VacType" + ' Nome gruppo layout in testa con ventose + Public Const VACUUM_HEAD_LAYOUT As String = "LAYOUT" + ' Base di info in gruppo layout per selezioni di ventose da verificare + Public Const KEY_VACLAY_SEL As String = "Sel" + ' Info in gruppo layout per angolo di rotazione preferito + Public Const KEY_VACLAY_PREFROT As String = "PreferredRot" + ' Info in gruppo layout per direzione di riferimento ventose per tagli da sotto + Public Const KEY_VACLAY_DRIPREFDIR As String = "DripRefDir" + ' Info in asse rotante ventosa per step discreti + Public Const KEY_ROTVAC_STEPS As String = "STEPS" + ' Nome oggetto frame prima uscita di una testa + Public Const HEAD_FIRST_EXIT As String = "_T1" + + ' Nomi tavole principale, seconda e terza + Public Const MAIN_TAB As String = "MainTab" + Public Const SECOND_TAB As String = "2ndTab" + Public Const THIRD_TAB As String = "3rdTab" + ' Nome tavola ausiliaria per spostamento finale pezzi + Public Const AUX_TAB As String = "AuxTab" + + ' Costanti per lavorazioni + Public Const MACH_GROUP As String = "Mach01" + Public Const PHOTO_GRP As String = "Photos" + Public Const PHOTO_NAME As String = "Raw" + Public Const BASE_MACH_GROUP As String = "Mach_" + + ' Nome gruppo dei grezzi + Public Const MACH_RAWS_GROUP As String = "Raws" + ' Nome della superficie del grezzo + Public Const NAME_RAW_SOLID As String = "RawSolid" + ' Nome del centro del grezzo + Public Const NAME_RAW_CENTER As String = "RawCenter" + ' Nome del contorno di kerf nel grezzo + Public Const NAME_KERF As String = "Kerf" + ' Chiave per info di kerf nel grezzo + Public Const KEY_KERF As String = "Kerf" + ' Nome del contorno del grezzo + Public Const NAME_RAW_OUTLINE As String = "RawOutline" + ' Nome della regione del grezzo + Public Const NAME_RAW_REGION As String = "RawRegion" + ' Nome della regione del kerf grezzo + Public Const NAME_KERF_REGION As String = "KerfRegion" + ' Nome della regione fuori kerf nel grezzo + Public Const NAME_OUTKERF_REG As String = "SheetOut" + ' Nome della regione di riferimento nel grezzo + Public Const NAME_REF_REG As String = "RefReg" + ' Chiave per disabilitare la regione di riferimento + Public Const KEY_REF_REG_OFF As String = "Off" + ' Chiave per definizione del grezzo per punti + Public Const KEY_RAWBYPOINTS As String = "Rbp" + ' Nome del contorno di un'area rovinata + Public Const NAME_DAMAGED As String = "Damaged" + ' Nome della regione di un'area rovinata + Public Const NAME_DAMAGED_REG As String = "DmgReg" + ' Nome gruppo contorno grezzo da fotografia + Public Const NAME_RAW_PHOTO_OUTLINE As String = "RawPhotoOutline" + ' Nome testo per Barcode + Public Const NAME_BARCODE As String = "BarCode" + ' Info per identificativo blocco + Public Const INFO_RAW_BLOCK = "Block" + ' Info per numero lastra nel blocco + Public Const INFO_RAW_SLABNBR = "SlabNbr" + + ' Contrassegno di progetto OmagCut + Public Const NAME_PROJMARK As String = "OmagCut" + ' Info per stato flag taglio ridotto + Public Const INFO_REDUCEDCUT = "ReducedCut" + ' Info per tastatura tagli con angolo di fianco + Public Const INFO_SACPROBE As String = "SacProbe" + ' Info per lavaggio prima di spostamento pezzi con ventosa + Public Const INFO_WASHING As String = "Washing" + ' Info per lavorazioni già ordinate + Public Const INFO_MACHORDER As String = "MachOrder" + ' Info per indice progetto + Public Const INFO_PROJINDEX As String = "ProjIndex" + ' Info per materiale progetto + Public Const INFO_PROJMAT As String = "ProjMat" + ' Info per materiale foto + Public Const INFO_PHOTOMAT As String = "PhotoMat" + ' Info per nome lastra + Public Const INFO_SLABNAME As String = "SlabName" + ' Info per spessore lastra + Public Const INFO_SLABHEIGHT As String = "SlabHeight" + ' Info per taglio di lama corrente + Public Const INFO_CURRSAWING As String = "CurrSawing" + ' Info per fresatura corrente + Public Const INFO_CURRMILLING As String = "CurrMilling" + ' Info per foratura corrente + Public Const INFO_CURRDRILLING As String = "CurrDrilling" + ' Info per svuotatura corrente + Public Const INFO_CURRPOCKETING As String = "CurrPocketing" + ' Info per getto d'acqua corrente + Public Const INFO_CURRWATERJETTING As String = "CurrWaterjetting" + ' Info per programma di linea inviato + Public Const INFO_NCPROGSENT As String = "NcProgSent" + ' Info per ingombro pezzi con gocciolatoio + Public Const INFO_DRIPBBOX As String = "DripBBox" + + ' Nome layer delle regioni + Public Const NAME_REGION As String = "Region" + ' Nome solido derivato da regione del pezzo per taglio da sotto + Public Const NAME_DRIP_SOLID As String = "DripSolid" + ' Delta Z regioni di pezzi per evitare problemi di visualizzazione con grezzi + Public Const DELTAZ_REG As Double = 0.1 + ' Nome layer contorni esterni + Public Const NAME_OUTLOOP As String = "OutLoop" + ' Nome layer contorni interni + Public Const NAME_INLOOP As String = "InLoop" + ' Nome layer percorsi sul pezzo + Public Const NAME_ONPATH As String = "OnPath" + ' Nome layer percorsi di taglio da sotto (gocciolatoio) + Public Const NAME_DRIPCUT As String = "Drip" + ' Nome layer percorsi di foratura da sotto + Public Const NAME_UNDERDRILL As String = "UnderDrill" + ' Nome layer preview + Public Const NAME_PREVIEW As String = "PV" + ' Info in entità da tagliare per affondamento + Public Const INFO_DEPTH As String = "Depth" + Public Const INFO_DEPTH2 As String = "Depth2" + ' Info in entità da tagliare per taglio ristretto + Public Const INFO_STRICT As String = "Strict" + ' Info in entità da tagliare per angolo di lato e tallone + Public Const INFO_SIDE_ANGLE As String = "SideAng" + Public Const INFO_OFFSET As String = "Offset" + Public Const INFO_SIDE_ANGLE2 As String = "SideAng2" + Public Const INFO_OFFSET2 As String = "Offset2" + Public Const INFO_HEEL As String = "Heel" + Public Const INFO_ORIG_SIDE_ANGLE As String = "OrigSideAng" + Public const INFO_SIDE_FIXED As String = "SideFixed" + ' Info in entità da tagliare per gocciolatoio + Public Const INFO_HAVE_DRIP As String = "HaveDrip" + ' Info in entità da tagliare per direzione che varia a seconda del tipo (una via o zigzag) + Public Const INFO_DIR As String = "Dir" + ' Info in entità da tagliare per abilitare possibilità di inversione + Public Const INFO_ENABLE_INVERT As String = "EnInv" + ' Info in entità da tagliare per angolo con entità precedente e successiva + Public Const INFO_PREVANG As String = "PrevAng" + Public Const INFO_NEXTANG As String = "NextAng" + ' Info in entità da tagliare per lunghezza libera prima dell'inizio + Public Const INFO_START_FREELEN As String = "SFL" + ' Info in entità da tagliare per lunghezza libera dopo la fine + Public Const INFO_END_FREELEN As String = "EFL" + ' Angolo esterno minimo per calcolare la direzione libera sull'arco + Public Const FL_ARC_ANG_MIN As Double = 30 + ' Info in preview lavorazione con identificativo layer preview spostato nel pezzo + Public Const INFO_PV_ONPART_ID As String = "PvId" + ' Info in lavorazione con identificativo lavorazioni inglobate + Public Const INFO_MCH_OTHMID As String = "OthMIds" + ' Info in lavorazione con nome layer di provenieneza della geometria lavorata + Public Const INFO_MCH_LAYER As String = "Lay" + ' Info lavorazione disabilitata dall'utente + Public Const INFO_MCH_USER_OFF As String = "UserOff" + ' Info lavorazione disabilitata perchè lavorata in doppio con altra + Public Const INFO_MCH_DUPLED As String = "Dupled" + ' Info lavorazione per pausa alla fine + Public Const INFO_MCH_PAUSE As String = "Pause" + ' Info allungamento iniziale lavorazione imposto dall'utente + Public Const INFO_MCH_USER_SAL As String = "Usal" + ' Info allungamento finale lavorazione imposto dall'utente + Public Const INFO_MCH_USER_EAL As String = "Ueal" + ' Nome contorno taglio + Public Const NAME_PV_CUT As String = "CUT" + ' Nome contorno pre-taglio + Public Const NAME_PV_PRECUT As String = "PRC" + ' Nome contorno post-taglio + Public Const NAME_PV_POSTCUT As String = "POC" + ' Nome contorno in basso taglio + Public Const NAME_PV_DOWN_CUT As String = "DCUT" + ' Nome contorno in basso pre-taglio + Public Const NAME_PV_DOWN_PRECUT As String = "DPRC" + ' Nome contorno in basso post-taglio + Public Const NAME_PV_DOWN_POSTCUT As String = "DPOC" + ' Nome regione taglio + Public Const NAME_PV_RCUT As String = "RCUT" + ' Nome regione pre-taglio (attacco) + Public Const NAME_PV_RLICUT As String = "RLICUT" + ' Nome regione post-taglio (uscita) + Public Const NAME_PV_RLOCUT As String = "RLOCUT" + ' Info in lavorazione taglio per attacco originale + Public Const INFO_MCH_ORILEADIN As String = "OriLI" + ' Info in lavorazione taglio per uscita originale + Public Const INFO_MCH_ORILEADOUT As String = "OriLO" + ' Info in pezzo con path di provenienza + Public Const INFO_SOU_PATH As String = "SouPath" + ' Info in pezzo con path di Csv di provenienza + Public Const INFO_CSV_PATH As String = "CsvPath" + ' Info in pezzo con suo nome in Csv + Public Const INFO_CSV_PART As String = "CsvPart" + ' Info in pezzo con suo ordine in Csv + Public Const INFO_CSV_ORD As String = "CsvOrd" + ' Info in pezzo con sua distinta in Csv + Public Const INFO_CSV_DIST As String = "CsvDist" + ' Info in pezzo con suo materiale in Csv + Public Const INFO_CSV_MAT As String = "CsvMat" + ' Info in pezzo con dimensione X in Csv + Public Const INFO_CSV_V1 As String = "V1" + ' Info in pezzo con dimensione Y in Csv + Public Const INFO_CSV_V2 As String = "V2" + ' Nome layer per valori angoli di inclinazione dei lati + Public Const SIDE_ANGLE_LAYER As String = "SideAngle" + ' Nome layer per regioni selezione percorsi interni + Public Const SELECT_REGION_LAYER As String = "SelectRegion" + ' Info in pezzo per stato rotazione + Public Const INFO_PARTROT As String = "ROT" + + ' Nome di pezzo che è una cornice + Public Const NAME_FRAME As String = "Frame" + ' Nome del layer con la sezione della cornice + Public Const NAME_SECT As String = "Sect" + ' Nome del layer con la linea guida della cornice + Public Const NAME_GUIDE As String = "Guide" + ' Nome del layer con la superficie della cornice + Public Const NAME_SURF As String = "Surf" + ' Nome del layer con la superficie facet della cornice + Public Const NAME_FACET As String = "Facet" + ' Info con direzione della cornice (0=lungoX,1=lungoY,2=arca,3=guida) + Public Const INFO_FRAME_DIR As String = "Dir" + ' Info con raggio della cornice ad arco + Public Const INFO_FRAME_ARCRAD As String = "ArcRad" + ' Info con angolo della cornice ad arco + Public Const INFO_FRAME_ARCANG As String = "ArcAng" + ' Nome della lavorazione di sgrossatura cornici + Public Const NAME_FRAME_SAWROU As String = "FrameSawRou" + ' Nome della lavorazione di finitura cornici + Public Const NAME_FRAME_SAWFIN As String = "FrameSawFin" + ' Nome della lavorazione di spatolatura cornici + Public Const NAME_FRAME_SAWSIDEFIN As String = "FrameSawSideFin" + ' Nome della lavorazione di taglio singolo cornici + Public Const NAME_FRAME_SAWSINGLE As String = "FrameSawSingle" + ' Info in pezzo per ultima superficie selezionata + Public Const INFO_FRAME_SURF As String = "Surf" + ' Info in pezzo per facet di ultima superficie selezionata + Public Const INFO_FRAME_FACET As String = "Facet" + + ' Nome di pezzo per tagli diretti + Public Const NAME_DIRECTCUT As String = "DirectCut" + + ' Nome di pezzo temporaneo che serve per copia dime + Public Const NAME_COPYTEMPLATE As String = "CopyTemplate" + + ' Chiave per Id originale del pezzo per VeinMatch + Public Const KEY_ORI_ID As String = "OriId" + + ' Costante per flag di BBox + Public Const BBFLAG As Integer = GDB_BB.ONLY_VISIBLE + GDB_BB.IGNORE_TEXT + GDB_BB.IGNORE_DIM + + ' Lunghezza libera infinita + Public Const FREELEN_INF = 9999 + + ' Colori per lavorazioni + Public Function COL_MCH_CUT() As Color3d + Return New Color3d(0, 255, 0) + End Function + Public Function COL_MCH_CUT_ANG() As Color3d + Return New Color3d(255, 0, 255) + End Function + Public Function COL_MCH_FREE() As Color3d + Return New Color3d(0, 0, 255) + End Function + Public Function COL_MCH_ONCUT() As Color3d + Return New Color3d(255, 165, 0) + End Function + Public Function COL_MCH_ONFREE() As Color3d + Return New Color3d(192, 128, 0) + End Function + Public Function COL_MCH_DRIPCUT() As Color3d + Return New Color3d(255, 0, 165) + End Function + Public Function COL_MCH_DRIPFREE() As Color3d + Return New Color3d(192, 0, 128) + End Function + Public Function COL_MCH_INTERF() As Color3d + Return New Color3d(255, 0, 0) + End Function + Public Function COL_MCH_DISABLED() As Color3d + Return New Color3d(96, 96, 96) + End Function + Public Function COL_MCH_DIS_NUMBER() As Color3d + Return New Color3d(32, 32, 128) + End Function + Public Function COL_MCH_DIS_INTERF() As Color3d + Return New Color3d(224, 64, 64) + End Function + + ' Colore superficie di cornice + Public Function COL_FRAME() As Color3d + Return New Color3d(128, 192, 96) + End Function + +End Module diff --git a/EgtStoneLib/ConstMachIni.vb b/EgtStoneLib/ConstMachIni.vb new file mode 100644 index 0000000..9f21c7b --- /dev/null +++ b/EgtStoneLib/ConstMachIni.vb @@ -0,0 +1,263 @@ +Module ConstMachIni + + Public Const S_NUMERICALCONTROL As String = "NumericalControl" + Public Const K_TYPE As String = "Type" + + Public Const S_PARTPROGRAM As String = "PartProgram" + Public Const K_EXTENSION As String = "Extension" + + Public Const S_AXES As String = "Axes" + Public Const K_AXESNUM As String = "AxesNum" + Public Const K_SIMULATIONAXESNUM As String = "SimulationAxesNum" + Public Const K_L1NAME As String = "L1Name" + Public Const K_L1ID As String = "L1Id" + Public Const K_L2NAME As String = "L2Name" + Public Const K_L2ID As String = "L2Id" + Public Const K_L3NAME As String = "L3Name" + Public Const K_L3ID As String = "L3Id" + Public Const K_R1NAME As String = "R1Name" + Public Const K_R1ID As String = "R1Id" + Public Const K_R2NAME As String = "R2Name" + Public Const K_R2ID As String = "R2Id" + Public Const K_A6NAME As String = "A6Name" + Public Const K_A6ID As String = "A6Id" + Public Const K_A7NAME As String = "A7Name" + Public Const K_A7ID As String = "A7Id" + Public Const K_A8NAME As String = "A8Name" + Public Const K_A8ID As String = "A8Id" + Public Const K_A9NAME As String = "A9Name" + Public Const K_A9ID As String = "A9Id" + Public Const K_A10NAME As String = "A10Name" + Public Const K_A10ID As String = "A10Id" + Public Const K_DELTA_C As String = "DeltaC" + Public Const K_ININCHES As String = "InInches" + + Public Const S_NCSIEMENS As String = "NcSiemens" + Public Const K_COMM_NAME As String = "CommName" + Public Const K_PATH_HMI As String = "PathHmi" + + Public Const S_NCNUM As String = "NcNUM" + Public Const K_RESETSENDDELAY As String = "ResetSendDelay" + + Public Const S_NCDATA As String = "NcData" + Public Const K_COMM As String = "Comm" + Public Const K_REFRESH As String = "Refresh" + Public Const K_MODE As String = "Mode" + Public Const K_JOGINCR As String = "JogIncr" + Public Const K_FEED As String = "Feed" + Public Const K_FEEDOVR As String = "FeedOvr" + Public Const K_SPEED As String = "Speed" + Public Const K_SPEEDOVR As String = "SpeedOvr" + Public Const K_POWER As String = "Power" + Public Const K_SPINDLE As String = "Spindle" + Public Const K_LASER As String = "Laser" + Public Const K_LASERTRAC As String = "LaserTrac" + Public Const K_COOLANT As String = "Coolant" + Public Const K_INTERNALCOOLANT As String = "InternalCoolant" + Public Const K_EXTERNCOOLANT As String = "ExternCoolant" + Public Const K_CAXES As String = "CAxes" + Public Const K_BAXES As String = "BAxes" + Public Const K_THREEAXES As String = "ThreeAxes" + Public Const K_FIVEAXES As String = "FiveAxes" + Public Const K_AIRBLOW As String = "AirBlow" + Public Const K_HOME As String = "Home" + Public Const K_TABLEUP As String = "TableUp" + Public Const K_TABLEDOWN As String = "TableDown" + Public Const K_MANUAL As String = "Manual" + Public Const K_DOORCLOSED As String = "DoorClosed" + Public Const K_LIMITZ As String = "LimitZ" + Public Const K_POWEROVR As String = "PowerOvr" + Public Const K_VACUUMUP As String = "VacuumUp" + Public Const K_VACUUMDOWN As String = "VacuumDown" + Public Const K_VACUUM2UP As String = "Vacuum2Up" + Public Const K_VACUUM2DOWN As String = "Vacuum2Down" + Public Const K_VACUUM0 As String = "Vacuum0" + Public Const K_VACUUM90 As String = "Vacuum90" + Public Const K_VACUUM1STATE As String = "Vacuum1State" + Public Const K_VACUUM2STATE As String = "Vacuum2State" + Public Const K_VACUUM3STATE As String = "Vacuum3State" + Public Const K_VACUUM4STATE As String = "Vacuum4State" + Public Const K_VACUUM5STATE As String = "Vacuum5State" + Public Const K_VACUUM6STATE As String = "Vacuum6State" + Public Const K_VACUUM135STATE As String = "Vacuum135State" + Public Const K_VACUUM246STATE As String = "Vacuum246State" + Public Const K_OPENALLSTATE As String = "OpenAllState" + Public Const K_CLOSEALLSTATE As String = "CloseAllState" + Public Const K_OPEN123STATE As String = "Open123State" + Public Const K_OPEN456STATE As String = "Open456State" + Public Const K_CLOSE123STATE As String = "Close123State" + Public Const K_CLOSE456STATE As String = "Close456State" + Public Const K_BLOWSTATE As String = "BlowState" + Public Const K_VACUUMSTATE As String = "VacuumState" + Public Const K_VACUUMON As String = "VacuumOn" + Public Const K_VACUUMOFF As String = "VacuumOff" + Public Const K_BYPASSTATE As String = "BypassState" + + Public Const S_PRODUCTIONLINE As String = "ProductionLine" + Public Const K_ACTIVE As String = "Active" + Public Const K_NAMEPROG1 As String = "NameProg1" + Public Const K_VARPROG1 As String = "VarProg1" + Public Const K_NAMEPROG2 As String = "NameProg2" + Public Const K_VARPROG2 As String = "VarProg2" + Public Const K_LINEDATADIR As String = "DataDir" + Public Const K_VARPROJCOPY As String = "VarProjCopy" + Public Const K_SPECIALUNLOAD As String = "SpecialUnload" + Public Const K_SAVEPRODUCED As String = "SaveProduced" + Public Const K_VARPROGTWINS As String = "VarProgTwins" + Public Const K_ASKNEWONRESEND As String = "AskNewOnResend" + Public Const K_PRODLIENABLESAWPROBE As String = "EnableSawProbe" + Public Const K_PRODLIPROBINGSTATEVAR As String = "ProbingStateVar" + Public Const K_PRODLIPROBINGTCPOSVAR As String = "ProbingTcPosVar" + Public Const K_PRODLISAWDIAMETERVAR As String = "SawDiameterVar" + Public Const K_PRODLIPROBINGSTATE2VAR As String = "ProbingState2Var" + Public Const K_PRODLIPROBINGTCPOS2VAR As String = "ProbingTcPos2Var" + Public Const K_PRODLISAWDIAMETER2VAR As String = "SawDiameter2Var" + + Public Const S_STATISTICS As String = "Stats" + Public Const K_DATADIR As String = "DataDir" + Public Const K_SHOWAREAS As String = "ShowAreas" + + Public Const S_TABLE As String = "Table" + Public Const K_ADDITIONALTABLE As String = "AdditionalTable" + Public Const K_TAB2_ADDITIONALTABLE As String = "Tab2AdditionalTable" + Public Const K_TAB3_ADDITIONALTABLE As String = "Tab3AdditionalTable" + Public Const K_CENTER_RAW_ONX As String = "CenterRawOnX" + + Public Const S_PHOTO As String = "Photo" + Public Const K_PHOTO_OFFSETX As String = "OffsetX" + Public Const K_PHOTO_OFFSETY As String = "OffsetY" + Public Const K_PHOTO_TAB2_OFFSETX As String = "Tab2OffsetX" + Public Const K_PHOTO_TAB2_OFFSETY As String = "Tab2OffsetY" + + Public Const S_TOOLS As String = "Tools" + Public Const K_DRILLBIT As String = "Drillbit" + Public Const K_SAWBLADE As String = "Sawblade" + Public Const K_MILL As String = "Mill" + Public Const K_CUPWHEEL As String = "CupWheel" + Public Const K_POLISHINGWHEEL As String = "PolishingWheel" + Public Const K_WATERJET As String = "WaterJet" + Public Const K_SHOWTOOLCHANGER As String = "ShowToolChanger" + Public Const K_SHOWHEADEXIT As String = "ShowHeadExit" + Public Const K_SHOWUSERNOTES As String = "ShowUserNotes" + Public Const K_SHOWSPECIALS As String = "ShowSpecials" + Public Const K_DRILLHOLDER As String = "DrillHolder" + Public Const K_SAWBLADEHOLDER As String = "SawBladeHolder" + Public Const K_MILLHOLDER As String = "MillHolder" + Public Const K_DRILLMAKER As String = "DrillMaker" + Public Const K_SAWBLADEMAKER As String = "SawBladeMaker" + Public Const K_MILLMAKER As String = "MillMaker" + Public Const K_MOUNTEDTOOLCONFIG As String = "MountedToolConfig" + Public Const K_MAXSAWDIAMFORVAC As String = "MaxSawDiamForVac" + Public Const K_MAXSAWDIAMFORPROBE As String = "MaxSawDiamForProbe" + + Public Const S_MACHININGS As String = "Machinings" + Public Const K_SAWING As String = "Sawing" + Public Const K_DRILLING As String = "Drilling" + Public Const K_MILLING As String = "Milling" + Public Const K_POCKETING As String = "Pocketing" + Public Const K_POLISHING As String = "Polishing" + Public Const K_SAWROUGHING As String = "SawRoughing" + Public Const K_SAWFINISHING As String = "SawFinishing" + Public Const K_WATERJETTING As String = "WaterJetting" + Public Const K_SAWINGSPECIALLEADIN As String = "SawingSpecialLeadIn" + + Public Const S_MACH_NEST As String = "Nest" + Public Const K_MACH_HOLES_OFFSET As String = "HolesOffset" + Public Const K_MACH_HOLES_OVERLAP As String = "HolesOverlap" + Public Const K_MACH_HOLES_DIAMTOLER As String = "HolesDiamToler" + Public Const K_MACH_ONEHOLE_INTCORNER As String = "OneHoleOnIntCorner" + Public Const K_MACH_SAFE_LEN_CUT As String = "SafeLenOnCut" + Public Const K_MACH_SAFE_LEN_INTCORNER As String = "SafeLenOnIntCorner" + Public Const K_MACH_REDUCEDCUT As String = "ReducedCut" + Public Const K_MACH_REDUCEDDEPTH As String = "ReducedDepth" + Public Const K_MACH_EXTARCMINRAD As String = "ExtArcMinRad" + Public Const K_MACH_INTARCMAXSIDEANG As String = "IntArcMaxSideAng" + Public Const K_MACH_MILLING_ON_CORNERS As String = "MillingOnCorners" + 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_ENGRAVING_DEPTH As String = "EngravingDepth" + Public Const K_MACH_ENGRAVING_WIDTH As String = "EngravingWidth" + Public Const K_MACH_NEST_ALIGNED As String = "Aligned" + Public Const K_MACH_NEST_AUTOMATIC As String = "Automatic" + Public Const K_MACH_WASHING As String = "Washing" + Public Const K_MACH_SACPROBE As String = "SacProbe" + Public Const K_MACH_ENABLERESTART As String = "EnableRestart" + Public Const K_MACH_ENABLEPAUSE As String = "EnablePause" + Public Const K_MACH_CUTFSEVENABLE As String = "CutFsevEnable" + Public Const K_MACH_CUTFSEVLEN As String = "CutFsevLen" + Public Const K_MACH_CUTFSEVPERC As String = "CutFsevPerc" + ' DrillMillC90 + ' CutLongDxSx + ' AngRotMultiCut + ' MinDistHeadsMultiCut + ' MinSawRbHeight + + Public Const S_MACH_RAWMOVE As String = "RawMove" + Public Const K_MACH_RM_ROTATE As String = "Rotate" + Public Const K_MACH_RM_FINALMOVE As String = "FinalMove" + + Public Const S_MACH_REG As String = "Reg" + Public Const K_MACH_MAX_ROT_ANG As String = "MaxRotAng" + + Public Const S_TOOLCHANGER As String = "ToolChanger" + Public Const K_NUMBER As String = "Number" + Public Const K_POS As String = "Pos" + Public Const K_NAME As String = "Name" + Public Const K_MANUALNUMBER As String = "ManualNumber" + Public Const K_MANUALPOS As String = "ManualPos" + Public Const K_MANUALNAME As String = "ManualName" + + Public Const S_MACH_DIRECTCUTS As String = "DirectCuts" + Public Const K_FINALHOME As String = "FinalHome" + Public Const K_ADDSAWTHTO5AXMOVE As String = "AddSawThTo5AxMove" + + Public Const S_MACHBUTTONS As String = "MachButtons" + Public Const S_CONTROLMACHBUTTONS As String = "ControlMachButtons" + Public Const S_VACUUMMACHBUTTONS As String = "VacuumMachButtons" + Public Const K_BUTTON As String = "Button" + + Public Const S_MACH_INPROGRESS As String = "InProgress" + Public Const K_PHASEVAR As String = "PhaseVar" + + Public Const S_MACH_PROBING As String = "Probing" + Public Const K_PROBINGSTATEVAR As String = "ProbingStateVar" + Public Const K_SAWDIAMETER As String = "SawDiameter" + Public Const K_RAWTHICKNESS As String = "RawThickness" + Public Const K_ENABLERAWPROBE As String = "EnableRawProbe" + + Public Const S_MACH_BARCODEREADER As String = "BarcodeReader" + Public Const K_ENABLEBCR As String = "EnableBCR" + + Public Const S_MACH_ESTIMATIONS As String = "Estimations" + Public Const K_ENABLEEST As String = "Enable" + + Public Const S_MACH_MACH As String = "Mach" + Public Const K_CURRSAW As String = "CurrSaw" + Public Const K_CURRDRILL As String = "CurrDrill" + Public Const K_CURRMILL As String = "CurrMill" + Public Const K_CURRMILLNOTIP As String = "CurrMillNoTip" + Public Const K_CURRDRIPSAW As String = "CurrDripSaw" + Public Const K_CURRDRIPDRILL As String = "CurrDripDrill" + Public Const K_CURRWATERJET As String = "CurrWaterJet" + Public Const K_CURRSAWING As String = "CurrSawing" + Public Const K_CURRDRILLING As String = "CurrDrilling" + Public Const K_CURRMILLING As String = "CurrMilling" + Public Const K_CURRPOCKETING As String = "CurrPocketing" + Public Const K_CURRSAWROUGHING As String = "CurrSawRoughing" + Public Const K_CURRSAWFINISHING As String = "CurrSawFinishing" + Public Const K_CURRSAWSIDEFINISHING As String = "CurrSawSideFinishing" + Public Const K_CURRSAWSINGLE As String = "CurrSawSingle" + Public Const K_CURRDRIPSAWING As String = "CurrDripSawing" + Public Const K_CURRDRIPDRILLING As String = "CurrDripDrilling" + Public Const K_CURRWATERJETTING As String = "CurrWaterJetting" + + Public Const S_MATERIALS As String = "Materials" + Public Const K_CURRMATERIAL As String = "CurrMaterial" + Public Const K_CURROFFICEMATERIAL As String = "CurrOfficeMaterial" + Public Const K_MATERIAL As String = "Material" + + Public Const S_SETUP As String = "SetUp" + Public Const K_DEFAULT As String = "Default" + +End Module diff --git a/EgtStoneLib/CsvM.vb b/EgtStoneLib/CsvM.vb new file mode 100644 index 0000000..01088e1 --- /dev/null +++ b/EgtStoneLib/CsvM.vb @@ -0,0 +1,528 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Module CsvM + + ' Dati lista + Private m_sCsvPath As String = String.Empty + Public ReadOnly Property CsvPath As String + Get + Return m_sCsvPath + End Get + End Property + Private m_CsvPartList As New List(Of CsvPart) + Public ReadOnly Property CsvPartList As List(Of CsvPart) + Get + Return m_CsvPartList + End Get + End Property + Private m_bCsvPartListModified As Boolean = False + Private m_sCompoDir As String = String.Empty + +#Region "METHODS" + + Public Sub InitCsvM() + ' Leggo direttorio componenti + GetMainPrivateProfileString(S_COMPO, K_COMPODIR, "", m_sCompoDir) + ' Leggo lista pezzi corrente + Dim sCsvFile As String = String.Empty + GetMainPrivateProfileString(S_CSV, K_CSVLASTFILE, "", sCsvFile) + If Not String.IsNullOrEmpty(sCsvFile) Then + LoadCsvPartList(sCsvFile) + End If + End Sub + + Public Sub NewCmd() + ' Salvo lista dei pezzi attuale (se modificata) + If Not SaveCsvPartList() Then + ' Errore nel salvataggio del file CSV, vuoi continuare lo stesso ? - Errore + If MessageBox.Show(EgtMsg(MSG_CSVPAGEUC + 5), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.YesNo, MessageBoxImage.Error) <> MessageBoxResult.Yes Then + Return + End If + End If + ' Pulisco path e lista dei pezzi Csv + m_sCsvPath = String.Empty + m_CsvPartList.Clear() + m_bCsvPartListModified = False + ' Registro in ini nessuna path + WriteMainPrivateProfileString(S_CSV, K_CSVLASTFILE, "") + End Sub + + Public Sub Open() + ' Salvo lista dei pezzi attuale (se modificata) + If Not SaveCsvPartList() Then + ' Errore nel salvataggio del file CSV, vuoi continuare lo stesso ? - Errore + If MessageBox.Show(EgtMsg(MSG_CSVPAGEUC + 5), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.YesNo, MessageBoxImage.Error) <> MessageBoxResult.Yes Then + Return + End If + End If + ' Leggo direttorio corrente dei file CSV + Dim sCurrDir As String = "" + GetMainPrivateProfileString(S_CSV, K_CSVCURRDIR, "C:\", sCurrDir) + ' Apro dialogo scelta file + Dim CsvFileDlg As New Microsoft.Win32.OpenFileDialog() + If Directory.Exists(sCurrDir) Then CsvFileDlg.InitialDirectory = sCurrDir + CsvFileDlg.Filter = "Csv file|*.Csv|Epl file|*.Epl" + If Not CsvFileDlg.ShowDialog() Then Return + ' Salvo direttorio corrente + WriteMainPrivateProfileString(S_CSV, K_CSVCURRDIR, Path.GetDirectoryName(CsvFileDlg.FileName)) + ' Apertura file + Dim sPath = CsvFileDlg.FileName + If String.Compare(Path.GetExtension(sPath), ".CSV", True) = 0 Then + LoadCsvFile(sPath) + Else + LoadCsvPartList(sPath) + End If + End Sub + + Public Sub Insert() + ' Recupero lo spessore della lastra corrente + Dim dRawHeight As Double = EstCalc.GetRawHeight() + If dRawHeight < EPS_SMALL Then Return + ' Recupero il materiale della lastra corrente + Dim sCurrMat As String = String.Empty + If Not IsNothing(CurrentMachine.CurrMat) Then + sCurrMat = CurrentMachine.CurrMat.sName + End If + ' Creo la lista dei pezzi inseribili nella lastra corrente + Dim InsPartList As New List(Of CsvPart) + For i As Integer = 1 To m_CsvPartList.Count() + Dim CurrPart As CsvPart = m_CsvPartList(i - 1) + If CurrPart.m_bActive And + Math.Abs(CurrPart.m_dTh - dRawHeight) < 100 * EPS_SMALL And + (String.IsNullOrWhiteSpace(CurrPart.m_sMaterial) Or + String.IsNullOrWhiteSpace(sCurrMat) Or + sCurrMat = "***" Or + String.Compare(CurrPart.m_sMaterial, sCurrMat, True) = 0) Then + InsPartList.Add(CurrPart) + End If + Next + ' Lancio l'inserimento dei pezzi + ExecInsert(InsPartList) + ' Dichiaro lista modificata + m_bCsvPartListModified = True + ' Aggiorno visualizzazione + EgtDraw() + End Sub + + Private Function ExecInsert(InsPartList As List(Of CsvPart)) As Boolean + Dim bMaxDimOnX As Boolean = (GetMainPrivateProfileInt(S_CSV, K_MAXDIMONX, 1) <> 0) + If bMaxDimOnX Then + ' Ordino la lista dei pezzi secondo la dimensione minima decrescente (va su Y) + InsPartList.Sort(Function(P, Q) + Dim dPMin As Double = Math.Min(P.m_dDimX, P.m_dDimY) + Dim dQMin As Double = Math.Min(Q.m_dDimX, Q.m_dDimY) + If Math.Abs(dPMin - dQMin) < EPS_SMALL Then + Return (P.m_nOriInd - Q.m_nOriInd) + Else + Return CInt(Math.Ceiling(dQMin - dPMin)) + End If + End Function) + Else + ' Ordino la lista dei pezzi secondo le Y decrescenti + InsPartList.Sort(Function(P, Q) + If Math.Abs(P.m_dDimY - Q.m_dDimY) < EPS_SMALL Then + Return (P.m_nOriInd - Q.m_nOriInd) + Else + Return CInt(Math.Ceiling(Q.m_dDimY - P.m_dDimY)) + End If + End Function) + End If + ' Creo o svuoto gruppo temporaneo per i pezzi + Dim nIpGrp As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, "CSV") + If nIpGrp = GDB_ID.NULL Then + nIpGrp = EgtCreateGroup(GDB_ID.ROOT) + If nIpGrp = GDB_ID.NULL Then Return False + EgtSetName(nIpGrp, "CSV") + Else + EgtEmptyGroup(nIpGrp) + End If + EgtSetLevel(nIpGrp, GDB_LV.TEMP) + EgtSetStatus(nIpGrp, GDB_ST.OFF) + ' Carico lua per creare rettangoli + Dim sLuaPath = m_sCompoDir & "\Rettangolo.lua" + If Not EgtLuaExecFile(sLuaPath) Then Return False + ' Inserisco nel gruppo un nuovo componente per ogni pezzo da inserire + For i As Integer = 1 To InsPartList.Count() + Dim CurrPart As CsvPart = InsPartList(i - 1) + ' Definizione variabili + Dim dDimX = CurrPart.m_dDimX + Dim dDimY = CurrPart.m_dDimY + If bMaxDimOnX And dDimY > dDimX Then + Dim dTemp As Double = dDimX + dDimX = dDimY + dDimY = dTemp + End If + EgtLuaSetGlobNumVar("CMP.V1", dDimX) + EgtLuaSetGlobNumVar("CMP.V2", dDimY) + EgtLuaSetGlobStringVar("CMP.INFO", CurrPart.m_sName) + ' Esecuzione componente + If Not EgtLuaExecLine("CMP_Draw(false)") Then Return False + ' Recupero Id del nuovo componente + Dim nId As Integer = EgtGetLastPart() + If nId = GDB_ID.NULL Then Return False + CurrPart.m_nId = nId + ' Muovo la regione in Z per evitare problemi in visualizzazione + Dim nRegId = EgtGetFirstNameInGroup(nId, NAME_REGION) + EgtMove(nRegId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB) + ' Eventuale testo per indicare il sopra + If Not bMaxDimOnX Then + Dim dH As Double = Math.Min(0.1 * dDimY, 30) + Dim nText As Integer = EgtCreateTextAdv(nRegId, New Point3d(dDimX / 2, dDimY - 0.6 * dH, 0), 0, "*TOP*", "", 500, False, dH, 1, 0, INS_POS.MC) + EgtSetColor(nText, New Color3d( 0, 0, 0)) + End If + ' Aggiusto per lavorazioni + AdjustFlatPart(nId) + ' Aggiungo info su CSV di origine + EgtSetInfo(nId, INFO_CSV_PATH, m_sCsvPath) + EgtSetInfo(nId, INFO_CSV_PART, CurrPart.m_sName) + EgtSetInfo(nId, INFO_CSV_ORD, CurrPart.m_sOrd) + EgtSetInfo(nId, INFO_CSV_DIST, CurrPart.m_sDist) + EgtSetInfo(nId, INFO_CSV_MAT, CurrPart.m_sMaterial) + ' Imposto colore testi + EstCalc.SetTextColor( nRegId) + ' Lo sposto nel gruppo speciale + EgtRelocate(nId, nIpGrp) + Next + EgtLuaResetGlobVar("CMP") + EgtLuaResetGlobVar("CMP_Draw") + ' Provo ad inserire i pezzi + Dim bDirect As Boolean = (GetMainPrivateProfileInt(S_CSV, K_CSVDIRECT, 1) <> 0) + For i As Integer = 1 To InsPartList.Count() + Dim CurrPart As CsvPart = InsPartList(i - 1) + While CurrPart.m_nToNest > 0 + If PackOnePart(CurrPart.m_nId, bDirect) Then + CurrPart.m_nToNest -= 1 + Else + Exit While + End If + End While + Next + Return True + End Function + + Private Function PackOnePart(nId As Integer, bDirect As Boolean) As Boolean + ' Creo una copia del pezzo nella radice + Dim nId2 As Integer = EgtCopyGlob(nId, GDB_ID.ROOT) + If nId2 = GDB_ID.NULL Then Return False + ' Lo inserisco direttamente + If bDirect Then + ' Aggiungo riferimento e lo inserisco in VeinMatching + VeinMatching.SetRefOnPart(nId2) + VeinMatching.AddPart(nId2, True) + ' Provo inserimento in lastra + If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then + ' Eventuale notifica al VeinMatching + VeinMatching.OnInsertPartInRaw(nId2) + Return True + Else + ' Eventuale cancellazione per VM + VeinMatching.OnRemovePart(nId2) + ' Cancellazione del pezzo + EraseMachinings(nId2) + EgtRemovePartFromRawPart(nId2) + EgtErase(nId2) + Return False + End If + ' altrimenti lo metto in parcheggio + Else + ' Aggiungo riferimento e lo inserisco in VeinMatching + VeinMatching.SetRefOnPart(nId2) + VeinMatching.AddPart(nId2, True) + ' Inserisco in parcheggio + EstCalc.StoreOnePart(nId2, True) + Return True + End If + End Function + + Public Sub Remove(ByRef bOther As Boolean, ByRef sOtherCsv As String) + ' Rimuovo i pezzi selezionati della lista CSV corrente e ne aggiorno i contatori + Dim nId As Integer = EgtGetFirstSelectedObj() + While nId <> GDB_ID.NULL + Dim nNextId As Integer = EgtGetNextSelectedObj() + If Not RemoveOnePart(nId) Then + bOther = True + Dim sCsvPath As String = String.Empty + If EgtGetInfo(nId, INFO_CSV_PATH, sCsvPath) Then + Dim sCsvName As String = Path.GetFileNameWithoutExtension(sCsvPath) + If sOtherCsv.IndexOf(sCsvName) = -1 Then + sOtherCsv = sOtherCsv & sCsvName & ", " + End If + End If + End If + nId = nNextId + End While + ' Dichiaro lista modificata + m_bCsvPartListModified = True + ' Aggiorno visualizzazione + EgtDraw() + End Sub + + Private Function RemoveOnePart(nId As Integer) As Boolean + ' Recupero identificativi da Info + Dim sCsvPath As String = String.Empty + EgtGetInfo(nId, INFO_CSV_PATH, sCsvPath) + Dim sName As String = String.Empty + EgtGetInfo(nId, INFO_CSV_PART, sName) + ' Verifico che il pezzo appartenga a questo Csv + If String.Compare(sCsvPath, m_sCsvPath, True) = 0 Then + ' Cerco il pezzo nella lista dei pezzi + For i = 1 To m_CsvPartList.Count() + Dim CurrPart As CsvPart = m_CsvPartList(i - 1) + If String.Compare(sName, CurrPart.m_sName, True) = 0 Then + ' Se era nel grezzo + If EgtGetParent(nId) = EstCalc.GetRawId() Then + ' Rimuovo le lavorazioni + EraseMachinings(nId) + ' Rimuovo dal grezzo + EgtRemovePartFromRawPart(nId) + End If + ' Eventuale cancellazione per VM + VeinMatching.OnRemovePart(nId) + ' Cancello il pezzo + EgtErase(nId) + ' Aggiorno il contatore + CurrPart.m_nToNest += 1 + ' Esco + Return True + End If + Next + End If + ' Pezzo non appartenente al Csv corrente + Return False + End Function + + Private Function LoadCsvFile(sCsvPath As String) As Boolean + ' Pulisco path e lista dei pezzi Csv + m_sCsvPath = String.Empty + m_CsvPartList.Clear() + ' Definizione variabili + EgtLuaCreateGlobTable("CSV") + EgtLuaSetGlobStringVar("CSV.FILE", sCsvPath) + ' Esecuzione + Dim nErr As Integer = 999 + Dim sReader As String = String.Empty + GetMainPrivateProfileString(S_CSV, K_READER, "CsvRead.lua", sReader) + If EgtLuaExecFile(OmagOFFICEMap.refMainWindowVM.MainWindowM.sCsvAutoDir & "\" & sReader) AndAlso + EgtLuaCallFunction("CSV.Read") Then + ' Verifica stato di errore + EgtLuaGetGlobIntVar("CSV.ERR", nErr) + End If + If nErr <> 0 Then + EgtOutLog("Error in CsvRead : " & nErr.ToString()) + Return False + End If + ' Assegno path + m_sCsvPath = sCsvPath + ' Preparo lista dei pezzi + Dim nNbr As Integer = 0 + EgtLuaGetGlobIntVar("CSV.NBR", nNbr) + For i As Integer = 1 To nNbr + Dim OnePart As New CsvPart + Dim sN As String = i.ToString() + EgtLuaGetGlobStringVar("CSV.NAME" & sN, OnePart.m_sName) + OnePart.m_bActive = True + EgtLuaGetGlobStringVar("CSV.ORD" & sN, OnePart.m_sOrd) + EgtLuaGetGlobStringVar("CSV.DIST" & sN, OnePart.m_sDist) + EgtLuaGetGlobStringVar("CSV.MAT" & sN, OnePart.m_sMaterial) + EgtLuaGetGlobIntVar("CSV.COUNT" & sN, OnePart.m_nCount) + OnePart.m_nToNest = OnePart.m_nCount + EgtLuaGetGlobBoolVar("CSV.RECT" & sN, OnePart.m_bIsRect) + EgtLuaGetGlobNumVar("CSV.DIMX" & sN, OnePart.m_dDimX) + EgtLuaGetGlobNumVar("CSV.DIMY" & sN, OnePart.m_dDimY) + EgtLuaGetGlobNumVar("CSV.TH" & sN, OnePart.m_dTh) + OnePart.m_nOriInd = i + ' inserisco in lista + m_CsvPartList.Add(OnePart) + Next + EgtLuaResetGlobVar("CSV") + ' Ordinamento lista dei pezzi (ordine crescente su materiale e spessore) + m_CsvPartList.Sort(Function(x, y) + Dim nComp As Integer = String.Compare(x.m_sMaterial, y.m_sMaterial, True) + If nComp = 0 Then + If Math.Abs(x.m_dTh - y.m_dTh) < EPS_SMALL Then + Return (x.m_nOriInd - y.m_nOriInd) + Else + Return CInt(Math.Ceiling(x.m_dTh - y.m_dTh)) + End If + Else + Return nComp + End If + End Function) + ' Salvo come epl + m_bCsvPartListModified = True + SaveCsvPartList() + ' Rinomino file originale + Dim sBakPath As String = sCsvPath & ".bak" + Dim sBakName As String = Path.GetFileName(sBakPath) + ' cancello eventuale vecchio backup + If My.Computer.FileSystem.FileExists(sBakPath) Then + My.Computer.FileSystem.DeleteFile(sBakPath) + End If + ' eseguo rinomina + My.Computer.FileSystem.RenameFile(sCsvPath, sBakName) + Return True + End Function + + Public Function SaveCsvPartList() As Boolean + ' Se non c'è nulla di attivo, non faccio alcunché + If String.IsNullOrEmpty(m_sCsvPath) Then + EgtOutLog("CSV List Save Skipped : missing") + Return True + End If + ' Se lista non modificata, non faccio alcunchhé + If Not m_bCsvPartListModified Then + EgtOutLog("CSV List Save Skipped : not modified") + Return True + End If + ' Path del file + Dim sFile As String = Path.ChangeExtension(m_sCsvPath, ".epl") + ' Gestione file + Try + ' Apro file + Dim Writer As New IO.StreamWriter(sFile, False) + ' Intestazione + Writer.WriteLine("[General]") + Writer.WriteLine("Path=" & m_sCsvPath) + ' Ciclo sui pezzi + For i As Integer = 1 To m_CsvPartList.Count() + Dim CurrPart As CsvPart = m_CsvPartList(i - 1) + Writer.WriteLine("[P" & i.ToString() & "]") + Writer.WriteLine("Nam=" & CurrPart.m_sName) + Writer.WriteLine("Ord=" & CurrPart.m_sOrd) + Writer.WriteLine("Dist=" & CurrPart.m_sDist) + Writer.WriteLine("Mat=" & CurrPart.m_sMaterial) + Writer.WriteLine("Act=" & If(CurrPart.m_bActive, "1", "0")) + Writer.WriteLine("Cnt=" & CurrPart.m_nCount.ToString()) + Writer.WriteLine("Add=" & CurrPart.m_nAdd.ToString()) + Writer.WriteLine("ToN=" & CurrPart.m_nToNest.ToString()) + Writer.WriteLine("Rct=" & If(CurrPart.m_bIsRect, "1", "0")) + Writer.WriteLine("DX=" & DoubleToString(CurrPart.m_dDimX, 4)) + Writer.WriteLine("DY=" & DoubleToString(CurrPart.m_dDimY, 4)) + Writer.WriteLine("Th=" & DoubleToString(CurrPart.m_dTh, 4)) + Writer.WriteLine("OIn=" & CurrPart.m_nOriInd.ToString()) + Next + ' Terminatore + Writer.WriteLine("[END]") + ' Chiudo file + Writer.Close() + ' Dichiaro lista non più modificata + m_bCsvPartListModified = False + ' Registro in ini path + WriteMainPrivateProfileString(S_CSV, K_CSVLASTFILE, sFile) + Return True + ' Errore + Catch ex As Exception + EgtOutLog("CSV List error writing " & sFile) + Return False + End Try + End Function + + Private Function LoadCsvPartList(sFile As String) As Boolean + ' Pulisco path e lista dei pezzi Csv + m_sCsvPath = String.Empty + m_CsvPartList.Clear() + ' Gestione file + Try + ' Apro file + Dim Reader As New IO.StreamReader(sFile, False) + ' Lettura intestazione + Dim sLine As String = Reader.ReadLine() + While sLine <> Nothing + If sLine = "[General]" Then + ' non devo fare alcunché + ElseIf sLine.Length() >= 5 AndAlso sLine.Substring(0, 5) = "Path=" Then + Dim sItems() As String = sLine.Split("=".ToCharArray) + If sItems.Count() >= 2 Then + m_sCsvPath = sItems(1) + End If + Else + Exit While + End If + sLine = Reader.ReadLine() + End While + ' Ciclo di lettura dei pezzi + Dim nI As Integer = 1 + Dim sPart As String = "[P" & nI.ToString() & "]" + Dim OnePart As New CsvPart + While sLine <> Nothing + ' Inizio pezzo o fine del file + If sLine = sPart Or sLine = "[END]" Then + ' se esiste pezzo precedente, lo salvo + If nI > 1 Then + ' inserisco in lista + m_CsvPartList.Add(OnePart) + End If + ' predisposizioni per prossimo pezzo + nI += 1 + sPart = "[P" & nI.ToString() & "]" + OnePart = New CsvPart + ' Dato + Else + Dim sItems() As String = sLine.Split("=".ToCharArray) + If sItems.Count() >= 2 Then + If sItems(0) = "Nam" Then + OnePart.m_sName = sItems(1) + ElseIf sItems(0) = "Ord" Then + OnePart.m_sOrd = sItems(1) + ElseIf sItems(0) = "Dist" Then + OnePart.m_sDist = sItems(1) + ElseIf sItems(0) = "Mat" Then + OnePart.m_sMaterial = sItems(1) + ElseIf sItems(0) = "Act" Then + OnePart.m_bActive = If(sItems(1) = "0", False, True) + ElseIf sItems(0) = "Cnt" Then + StringToInt(sItems(1), OnePart.m_nCount) + ElseIf sItems(0) = "Add" Then + StringToInt(sItems(1), OnePart.m_nAdd) + ElseIf sItems(0) = "ToN" Then + StringToInt(sItems(1), OnePart.m_nToNest) + ElseIf sItems(0) = "Rct" Then + OnePart.m_bIsRect = If(sItems(1) = "0", False, True) + ElseIf sItems(0) = "DX" Then + StringToDouble(sItems(1), OnePart.m_dDimX) + ElseIf sItems(0) = "DY" Then + StringToDouble(sItems(1), OnePart.m_dDimY) + ElseIf sItems(0) = "Th" Then + StringToDouble(sItems(1), OnePart.m_dTh) + ElseIf sItems(0) = "OIn" Then + StringToInt(sItems(1), OnePart.m_nOriInd) + End If + End If + End If + sLine = Reader.ReadLine() + End While + ' Chiudo il file + Reader.Close() + ' Dichiaro lista non modificata + m_bCsvPartListModified = False + Return True + ' Errore + Catch ex As Exception + EgtOutLog("Error reading " & sFile) + Return False + End Try + End Function + +#End Region ' METHODS + +End Module + +Public Class CsvPart + Public m_sName As String = String.Empty + Public m_sOrd As String = String.Empty + Public m_sDist As String = String.Empty + Public m_sMaterial As String = String.Empty + Public m_bActive As Boolean = True + Public m_nCount As Integer = 0 + Public m_nAdd As Integer = 0 + Public m_nToNest As Integer = 0 + Public m_bIsRect As Boolean = True + Public m_dDimX As Double = 0 + Public m_dDimY As Double = 0 + Public m_dTh As Double = 0 + Public m_nOriInd As Integer = 0 + Public m_nId As Integer = GDB_ID.NULL +End Class diff --git a/EgtStoneLib/CurrentMachine.vb b/EgtStoneLib/CurrentMachine.vb new file mode 100644 index 0000000..fedab4a --- /dev/null +++ b/EgtStoneLib/CurrentMachine.vb @@ -0,0 +1,1444 @@ +Imports System.Collections.ObjectModel +Imports EgtUILib + +Public Module CurrentMachine + + ' Flag modalità Office + Private m_bOffice As Boolean = False + + ' Nome macchina corrente + Private m_sMachineName As String = String.Empty + ' Direttorio macchina corrente + Private m_sMachDir As String = String.Empty + ' File ini della macchina + Private m_sMachIniFile As String = String.Empty + + ' Estensione dei file programma pezzo (detti anche file Iso) + Private m_sIsoFileExt As String = String.Empty + + ' Incremento da dare all'asse C per far coincidere la linea della lama con l'asse X + Private m_dDeltaC As Double = 0 + + ' Ritardo tra reset e invio programma per NUM + Private m_nResetSendDelay As Integer = 1000 + + ' Dati su linea di produzione + Private m_bProdLine As Boolean = False + Private m_sVarProg1 As String = "E80021" + Private m_nProg1 As Integer = 901 + Private m_sVarProg2 As String = "E80022" + Private m_nProg2 As Integer = 902 + Private m_sLineDataDir As String = "" + Private m_sVarProjCopy As String = "E80025" + + ' Numero e tipo di utensili correntemente disponibili sulla macchina + Private m_MountedToolConfig As MountedToolConfigs = MountedToolConfigs.SAW + + ' Distanza di sicurezza + Private m_dSafeZ As Double = 0 + + ' Dati per nesting + Private m_bReducedCut As Boolean = True + Private m_bAligned As Boolean = True + Private m_bAutomatic As Boolean = False + + ' Dati per forature + Private m_dHolesOffset As Double = 0 + Private m_dHolesOverlap As Double = 0 + Private m_dHolesTolerance As Double = 0 + Private m_bOneHoleInCorner As Boolean = False + + ' Dati per tagli di lama + Private m_dCutExtraLen As Double = 0 + Private m_dAngleCutExtraLen As Double = 0 + Private m_dExtArcMinRad As Double = 0 + Private m_dIntArcMaxSideAng As Double = 0 + + ' Dati per fresatura + Private m_bCornerCuts As Boolean = False + Private m_bInternalCuts As Boolean = False + Private m_dShortCut As Double = 0 + + ' Abilitazione tastatura tagli inclinati (-1=non visibile, 0=disabilitato, 1=abilitato) + Private m_nSacProbe As Integer = -1 + + ' Abilitazione lavaggio lastra (-1=non visibile, 0=disabilitato, 1=abilitato) + Private m_nWashing As Integer = -1 + + ' Massimo diametro lama per utilizzo ventose movimento pezzi + Private m_dMaxSawDiamForVac As Double = 630 + ' Massimo diametro lama per tastatura grezzo + Private m_dMaxSawDiamForProbe As Double = 630 + + ' Possibilità di ruotare i grezzi durante separa e muovi + Private m_bRawSplMovRotate As Boolean = False + ' Possibilità di muovere i pezzi alla fine delle lavorazioni + Private m_bRawFinalMove As Boolean = False + + ' Flag che indicano stato tipologia utensili (attivo/non attivo) + Private m_bSaw As Boolean = False + Private m_bDrill As Boolean = False + Private m_bMill As Boolean = False + Private m_bCupWheel As Boolean = False + Private m_bPolishingWheel As Boolean = False + Private m_bWaterJet As Boolean = False + + ' Flag per visualizzazione TcPos, Testa/uscita e Note utente + Private m_nShowToolChanger As Integer = 0 ' 0=no, 1=tutti utensili, 2=solo lame + Private m_bShowHeadExit As Boolean = False + Private m_nShowUserNotes As Integer = 0 ' 0=no, 1=tutti utensili, 2=solo lame + + ' Flag che indicano presenza tipologia lavorazioni (attivo/non attivo) + Private m_bSawing As Boolean = False + Private m_bDrilling As Boolean = False + Private m_bMilling As Boolean = False + Private m_bPocketing As Boolean = False + Private m_bPolishing As Boolean = False + Private m_bSawRoughing As Boolean = False + Private m_bSawFinishing As Boolean = False + Private m_bWaterJetting As Boolean = False + Private m_bSawingSpecialLeadIn As Boolean = False + + ' Variabili che contengono il nome degli utensili disponibili per tipo + Private m_sCurrSaw As String = String.Empty + Private m_sCurrDrill As String = String.Empty + Private m_sCurrMill As String = String.Empty + Private m_sCurrMillNoTip As String = String.Empty + Private m_sCurrDripSaw As String = String.Empty + Private m_sCurrDripDrill As String = String.Empty + Private m_sCurrWaterJet As String = String.Empty + + ' Variabili che contengono le lavorazioni correntemente attive (utilizzate per definire lavorazioni nel programma) + Private m_sCurrSawing As String = String.Empty + Private m_sCurrDrilling As String = String.Empty + Private m_sCurrMilling As String = String.Empty + Private m_sCurrPocketing As String = String.Empty + Private m_sCurrSawRoughing As String = String.Empty + Private m_sCurrSawFinishing As String = String.Empty + Private m_sCurrSawSideFinishing As String = String.Empty + Private m_sCurrSawSingle As String = String.Empty + Private m_sCurrDripSawing As String = String.Empty + Private m_sCurrDripDrilling As String = String.Empty + Private m_sCurrWaterJetting As String = String.Empty + + ' Spessore sottopezzo + Private m_dAdditionalTable As Double = 0 + Private m_dTab2AdditionalTable As Double = 0 + Private m_dTab3AdditionalTable As Double = 0 + Private m_bCenterRawOnX As Boolean = False + + ' Offset aggiuntivi per fotografia + Private m_dPhotoOffsetX As Double = 0 + Private m_dPhotoOffsetY As Double = 0 + Private m_dTab2PhotoOffsetX As Double = 0 + Private m_dTab2PhotoOffsetY As Double = 0 + + ' Abilitazione scelta pausa a fine lavorazione + Private m_bEnablePause As Boolean = False + + ' Flag home finale per tagli diretti + Private m_bDirectCutsFinalHome As Boolean = True + + ' Variazione iniziale/finale della feed dei tagli + Private m_bFsevEnable As Boolean = False + Private m_dFsevLength As Double = 0 + Private m_dFsevPerc As Double = 0 + + ' Numero portautensili presenti + Private m_ToolChangerNbr As Integer = 0 + + ' Lista portautensili + Private m_ToolChanger As New List(Of ToolChangerPos) + + ' Numero portautensili manuali + Private m_ManualToolChangerNbr As Integer = 0 + + ' Lista portautensili + Private m_ManualToolChanger As New List(Of ToolChangerPos) + + ' Lista dei materiali + Private m_Materials As New ObservableCollection(Of Material) + + ' Massimo id della lista materiali nel file ini + Private m_MaxIdMat As Integer = 0 + + ' Materiale correntemente attivo (dell'ultimo grezzo impostato) + Private m_CurrMat As Material = Nothing + + ' Materiale definito nel Data Base (dell'Omag-PHOTO) + Private m_CurrMatDB As String = String.Empty + + ' Indica se la macchina ha il tastatore della lastra + Private m_HasRawProbe As Boolean = True + + ' Tipi di attrezzaggio + Friend Enum MountedToolConfigs As Integer + SAW = 0 + SAWANDAUXTOOL = 1 + MANUALTOOLCHANGER = 2 + TOOLCHANGER = 3 + End Enum + + ' Massimo numero di utensili su Tc automatico + Friend MAX_TC_TOOLS As Integer = 60 + + ' Massimo numero di utensili su Tc manuale + Friend MAX_TCMAN_TOOLS As Integer = 60 + + +#Region "Proprietà che leggono e scrivono i valori anche da o su file ini" + + Friend ReadOnly Property sMachineName As String + Get + Return m_sMachineName + End Get + End Property + + Friend ReadOnly Property sMachDir As String + Get + Return m_sMachDir + End Get + End Property + + Friend ReadOnly Property sMachIniFile As String + Get + Return m_sMachIniFile + End Get + End Property + + Friend ReadOnly Property sIsoFileExt As String + Get + Return m_sIsoFileExt + End Get + End Property + + Friend ReadOnly Property dDeltaC As Double + Get + Return m_dDeltaC + End Get + End Property + + Friend ReadOnly Property nResetSendDelay As Integer + Get + Return m_nResetSendDelay + End Get + End Property + + Friend ReadOnly Property bProdLine As Boolean + Get + Return m_bProdLine + End Get + End Property + + Friend ReadOnly Property sVarProg1 As String + Get + Return m_sVarProg1 + End Get + End Property + + Friend ReadOnly Property nProg1 As Integer + Get + Return m_nProg1 + End Get + End Property + + Friend ReadOnly Property sVarProg2 As String + Get + Return m_sVarProg2 + End Get + End Property + + Friend ReadOnly Property nProg2 As Integer + Get + Return m_nProg2 + End Get + End Property + + Friend ReadOnly Property sLineDataDir As String + Get + Return m_sLineDataDir + End Get + End Property + + Friend ReadOnly Property sVarProjCopy As String + Get + Return m_sVarProjCopy + End Get + End Property + + Friend ReadOnly Property MountedToolConfig As MountedToolConfigs + Get + Return m_MountedToolConfig + End Get + End Property + + Friend ReadOnly Property dMaxSawDiamForVac As Double + Get + Return m_dMaxSawDiamForVac + End Get + End Property + + Friend ReadOnly Property dMaxSawDiamForProbe As Double + Get + Return m_dMaxSawDiamForProbe + End Get + End Property + + Friend ReadOnly Property bRawSplMovRotate As Boolean + Get + Return m_bRawSplMovRotate + End Get + End Property + + Friend ReadOnly Property bRawFinalMove As Boolean + Get + Return m_bRawFinalMove + End Get + End Property + + Friend Property dSafeZ As Double + Get + If EgtMdbGetGeneralParam(MCH_GP.SAFEZ, m_dSafeZ) Then + Return m_dSafeZ + Else + Return Nothing + End If + End Get + Set(value As Double) + If EgtMdbSetGeneralParam(MCH_GP.SAFEZ, m_dSafeZ) And + EgtMdbSave() Then + m_dSafeZ = value + End If + End Set + End Property + + Public Property bReducedCut As Boolean + Get + Return m_bReducedCut + End Get + Set(value As Boolean) + WritePrivateProfileString(S_MACH_NEST, K_MACH_REDUCEDCUT, If(value, "1", "0"), sMachIniFile) + m_bReducedCut = value + End Set + End Property + + Public Property dHolesOffset As Double + Get + Return m_dHolesOffset + End Get + Set(value As Double) + If EgtMdbSetGeneralParam(MCH_GP.EXTRARONDRIREG, dHolesOffset) Then + EgtMdbSave() + WritePrivateProfileString(S_MACH_NEST, K_MACH_HOLES_OFFSET, DoubleToString(value, 2), sMachIniFile) + m_dHolesOffset = value + End If + End Set + End Property + + Public Property dHolesOverlap As Double + Get + Return m_dHolesOverlap + End Get + Set(value As Double) + WritePrivateProfileString(S_MACH_NEST, K_MACH_HOLES_OVERLAP, DoubleToString(value, 2), sMachIniFile) + m_dHolesOverlap = value + End Set + End Property + + Public Property dHolesTolerance As Double + Get + Return m_dHolesTolerance + End Get + Set(value As Double) + If EgtMdbSetGeneralParam(MCH_GP.HOLEDIAMTOLER, value) Then + EgtMdbSave() + WritePrivateProfileString(S_MACH_NEST, K_MACH_HOLES_DIAMTOLER, DoubleToString(value, 2), sMachIniFile) + m_dHolesTolerance = value + End If + End Set + End Property + + Public Property bOneHoleInCorner As Boolean + Get + Return m_bOneHoleInCorner + End Get + Set(value As Boolean) + WritePrivateProfileString(S_MACH_NEST, K_MACH_ONEHOLE_INTCORNER, If(value, "1", "0"), sMachIniFile) + m_bOneHoleInCorner = value + End Set + End Property + + Public Property dCutExtraLen As Double + Get + Return m_dCutExtraLen + End Get + Set(value As Double) + If EgtMdbSetGeneralParam(MCH_GP.EXTRALONCUTREG, value) Then + EgtMdbSave() + WritePrivateProfileString(S_MACH_NEST, K_MACH_SAFE_LEN_CUT, DoubleToString(value, 2), sMachIniFile) + m_dCutExtraLen = value + End If + End Set + End Property + + Public Property dAngleCutExtraLen As Double + Get + Return m_dAngleCutExtraLen + End Get + Set(value As Double) + WritePrivateProfileString(S_MACH_NEST, K_MACH_SAFE_LEN_INTCORNER, DoubleToString(value, 2), sMachIniFile) + m_dAngleCutExtraLen = value + End Set + End Property + + Public Property dExtArcMinRad As Double + Get + Return m_dExtArcMinRad + End Get + Set(value As Double) + If EgtMdbSetGeneralParam(MCH_GP.EXTSAWARCMINRAD, value) Then + EgtMdbSave() + WritePrivateProfileString(S_MACH_NEST, K_MACH_EXTARCMINRAD, DoubleToString(value, 2), sMachIniFile) + m_dExtArcMinRad = value + End If + End Set + End Property + + Public Property dIntArcMaxSideAng As Double + Get + Return m_dIntArcMaxSideAng + End Get + Set(value As Double) + If EgtMdbSetGeneralParam(MCH_GP.INTSAWARCMAXSIDEANG, value) Then + EgtMdbSave() + WritePrivateProfileString(S_MACH_NEST, K_MACH_INTARCMAXSIDEANG, DoubleToString(value, 2), sMachIniFile) + m_dIntArcMaxSideAng = value + End If + End Set + End Property + + Public Property bCornerCuts As Boolean + Get + Return m_bCornerCuts + End Get + Set(value As Boolean) + WritePrivateProfileString(S_MACH_NEST, K_MACH_MILLING_ON_CORNERS, If(value, "1", "0"), sMachIniFile) + m_bCornerCuts = value + End Set + End Property + + Public Property bInternalCuts As Boolean + Get + Return m_bInternalCuts + End Get + Set(value As Boolean) + WritePrivateProfileString(S_MACH_NEST, K_MACH_MILLING_ON_SINKS, If(value, "1", "0"), sMachIniFile) + m_bInternalCuts = value + End Set + End Property + + Public Property dShortCut As Double + Get + Return m_dShortCut + End Get + Set(value As Double) + WritePrivateProfileString(S_MACH_NEST, K_MACH_MILLING_SHORTENING, DoubleToString(value, 2), sMachIniFile) + m_dShortCut = value + End Set + End Property + + Public Property bAligned As Boolean + Get + Return m_bAligned + End Get + Set(value As Boolean) + If WritePrivateProfileString(S_MACH_NEST, K_MACH_NEST_ALIGNED, If(value, "1", "0"), sMachIniFile) Then + m_bAligned = value + End If + End Set + End Property + + Public Property bAutomatic As Boolean + Get + Return m_bAutomatic + End Get + Set(value As Boolean) + If WritePrivateProfileString(S_MACH_NEST, K_MACH_NEST_AUTOMATIC, If(value, "1", "0"), sMachIniFile) Then + m_bAutomatic = value + End If + End Set + End Property + + Public Property nSacProbe As Integer + Get + Return m_nSacProbe + End Get + Set(value As Integer) + If WritePrivateProfileString(S_MACH_NEST, K_MACH_SACPROBE, value.ToString(), sMachIniFile) Then + m_nSacProbe = value + End If + End Set + End Property + + Public Property nWashing As Integer + Get + Return m_nWashing + End Get + Set(value As Integer) + If WritePrivateProfileString(S_MACH_NEST, K_MACH_WASHING, value.ToString(), sMachIniFile) Then + m_nWashing = value + End If + End Set + End Property + + Public ReadOnly Property bSaw As Boolean + Get + Return m_bSaw + End Get + End Property + + Public ReadOnly Property bDrill As Boolean + Get + Return m_bDrill + End Get + End Property + + Public ReadOnly Property bMill As Boolean + Get + Return m_bMill + End Get + End Property + + Friend ReadOnly Property bCupWheel As Boolean + Get + Return m_bCupWheel + End Get + End Property + + Friend ReadOnly Property bPolishingWheel As Boolean + Get + Return m_bPolishingWheel + End Get + End Property + + Friend ReadOnly Property bWaterJet As Boolean + Get + Return m_bWaterJet + End Get + End Property + + Friend ReadOnly Property ShowToolChanger As Integer + Get + Return m_nShowToolChanger + End Get + End Property + + Friend ReadOnly Property bShowHeadExit As Boolean + Get + Return m_bShowHeadExit + End Get + End Property + + Friend ReadOnly Property ShowUserNotes As Integer + Get + Return m_nShowUserNotes + End Get + End Property + + Friend ReadOnly Property bSawing As Boolean + Get + Return m_bSawing + End Get + End Property + + Friend ReadOnly Property bDrilling As Boolean + Get + Return m_bDrilling + End Get + End Property + + Friend ReadOnly Property bMilling As Boolean + Get + Return m_bMilling + End Get + End Property + + Friend ReadOnly Property bPocketing As Boolean + Get + Return m_bPocketing + End Get + End Property + + Friend ReadOnly Property bPolishing As Boolean + Get + Return m_bPolishing + End Get + End Property + + Friend ReadOnly Property bSawRoughing As Boolean + Get + Return m_bSawRoughing + End Get + End Property + + Friend ReadOnly Property bSawFinishing As Boolean + Get + Return m_bSawFinishing + End Get + End Property + + Friend ReadOnly Property bWaterJetting As Boolean + Get + Return m_bWaterJetting + End Get + End Property + + Friend ReadOnly Property bSawingSpecialLeadIn As Boolean + Get + Return m_bSawingSpecialLeadIn + End Get + End Property + + Friend Property sCurrSaw As String + Get + Return m_sCurrSaw + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRSAW, value, sMachIniFile) Then + m_sCurrSaw = value + End If + End Set + End Property + + Friend Property sCurrDrill As String + Get + Return m_sCurrDrill + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRDRILL, value, sMachIniFile) Then + m_sCurrDrill = value + End If + End Set + End Property + + Friend Property sCurrMill As String + Get + Return m_sCurrMill + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRMILL, value, sMachIniFile) Then + m_sCurrMill = value + End If + End Set + End Property + + Friend Property sCurrDripSaw As String + Get + Return m_sCurrDripSaw + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRDRIPSAW, value, sMachIniFile) Then + m_sCurrDripSaw = value + End If + End Set + End Property + + Friend Property sCurrDripDrill As String + Get + Return m_sCurrDripDrill + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRDRIPDRILL, value, sMachIniFile) Then + m_sCurrDripDrill = value + End If + End Set + End Property + + Friend Property sCurrWaterJet As String + Get + Return m_sCurrWaterJet + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRWATERJET, value, sMachIniFile) Then + m_sCurrWaterJet = value + End If + End Set + End Property + + Friend Property sCurrSawing As String + Get + Return m_sCurrSawing + End Get + Set(value As String) + If EstCalc.SetCurrSawing(value) Then + m_sCurrSawing = value + End If + End Set + End Property + + Friend Property sCurrDrilling As String + Get + Return m_sCurrDrilling + End Get + Set(value As String) + If EstCalc.SetCurrDrilling(value) Then + m_sCurrDrilling = value + End If + End Set + End Property + + Friend Property sCurrMilling As String + Get + Return m_sCurrMilling + End Get + Set(value As String) + If EstCalc.SetCurrMilling(value) Then + m_sCurrMilling = value + End If + End Set + End Property + + Friend Property sCurrPocketing As String + Get + Return m_sCurrPocketing + End Get + Set(value As String) + If EstCalc.SetCurrPocketing( value) Then + m_sCurrPocketing = value + End If + End Set + End Property + + Friend Property sCurrSawRoughing As String + Get + Return m_sCurrSawRoughing + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRSAWROUGHING, value, sMachIniFile) Then + m_sCurrSawRoughing = value + End If + End Set + End Property + + Friend Property sCurrSawFinishing As String + Get + Return m_sCurrSawFinishing + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRSAWFINISHING, value, sMachIniFile) Then + m_sCurrSawFinishing = value + End If + End Set + End Property + + Friend Property sCurrSawSideFinishing As String + Get + Return m_sCurrSawSideFinishing + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRSAWSIDEFINISHING, value, sMachIniFile) Then + m_sCurrSawSideFinishing = value + End If + End Set + End Property + + Friend Property sCurrSawSingle As String + Get + Return m_sCurrSawSingle + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRSAWSINGLE, value, sMachIniFile) Then + m_sCurrSawSingle = value + End If + End Set + End Property + + Friend Property sCurrDripSawing As String + Get + Return m_sCurrDripSawing + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRDRIPSAWING, value, sMachIniFile) Then + m_sCurrDripSawing = value + End If + End Set + End Property + + Friend Property sCurrDripDrilling As String + Get + Return m_sCurrDripDrilling + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRDRIPDRILLING, value, sMachIniFile) Then + m_sCurrDripDrilling = value + End If + End Set + End Property + + Friend Property sCurrWaterJetting As String + Get + Return m_sCurrWaterJetting + End Get + Set(value As String) + If WritePrivateProfileString(S_MACH_MACH, K_CURRWATERJETTING, value, sMachIniFile) Then + m_sCurrWaterJetting = value + End If + End Set + End Property + + Friend ReadOnly Property WaterJettingActive As Boolean + Get + Return m_bWaterJetting AndAlso Not String.IsNullOrWhiteSpace( m_sCurrWaterJetting) + End Get + End Property + + Friend Property dAdditionalTable As Double + Get + Select Case GetCurrentTable() + Case 3 + Return m_dTab3AdditionalTable + Case 2 + Return m_dTab2AdditionalTable + Case Else + Return m_dAdditionalTable + End Select + End Get + Set(value As Double) + Select Case GetCurrentTable() + Case 3 + If Math.Abs(value - m_dTab3AdditionalTable) > EPS_SMALL And + WritePrivateProfileString(S_TABLE, K_TAB3_ADDITIONALTABLE, DoubleToString(value, 3), sMachIniFile) Then + ' Aggiorno il valore corrente + m_dTab3AdditionalTable = value + ' Aggiorno il progetto corrente + AdjustAdditionalTable() + End If + Case 2 + If Math.Abs(value - m_dTab2AdditionalTable) > EPS_SMALL And + WritePrivateProfileString(S_TABLE, K_TAB2_ADDITIONALTABLE, DoubleToString(value, 3), sMachIniFile) Then + ' Aggiorno il valore corrente + m_dTab2AdditionalTable = value + ' Aggiorno il progetto corrente + AdjustAdditionalTable() + End If + Case Else + If Math.Abs(value - m_dAdditionalTable) > EPS_SMALL And + WritePrivateProfileString(S_TABLE, K_ADDITIONALTABLE, DoubleToString(value, 3), sMachIniFile) Then + ' Aggiorno il valore corrente + m_dAdditionalTable = value + ' Aggiorno il progetto corrente + AdjustAdditionalTable() + End If + End Select + End Set + End Property + + Friend ReadOnly Property CenterRawOnX As Boolean + Get + Return m_bCenterRawOnX + End Get + End Property + + Friend ReadOnly Property PhotoOffset As Vector3d + Get + Select Case GetCurrentTable() + Case 2 + Return New Vector3d(m_dTab2PhotoOffsetX, m_dTab2PhotoOffsetY, 0) + Case Else + Return New Vector3d(m_dPhotoOffsetX, m_dPhotoOffsetY, 0) + End Select + End Get + End Property + + + Friend ReadOnly Property bEnablePause As Boolean + Get + Return m_bEnablePause + End Get + End Property + + Friend Property bDirectCutsFinalHome As Boolean + Get + Return m_bDirectCutsFinalHome + End Get + Set(value As Boolean) + If WritePrivateProfileString(S_MACH_DIRECTCUTS, K_FINALHOME, If(value, "1", "0"), sMachIniFile) Then + m_bDirectCutsFinalHome = value + End If + End Set + End Property + + Friend ReadOnly Property bFsevEnable As Boolean + Get + Return m_bFsevEnable + End Get + End Property + + Friend Property dFsevLength As Double + Get + Return m_dFsevLength + End Get + Set(value As Double) + If WritePrivateProfileString(S_MACH_NEST, K_MACH_CUTFSEVLEN, DoubleToString(value, 3), sMachIniFile) Then + m_dFsevLength = value + End If + End Set + End Property + + Friend Property dFsevPerc As Double + Get + Return m_dFsevPerc + End Get + Set(value As Double) + If WritePrivateProfileString(S_MACH_NEST, K_MACH_CUTFSEVPERC, DoubleToString(value, 3), sMachIniFile) Then + m_dFsevPerc = value + End If + End Set + End Property + + Friend ReadOnly Property ToolChangerNbr As Integer + Get + Return m_ToolChangerNbr + End Get + End Property + + Friend ReadOnly Property ToolChanger As List(Of ToolChangerPos) + Get + Return m_ToolChanger + End Get + End Property + + Friend ReadOnly Property ToolChangerName(Index As Integer) As String + Get + If Index >= 0 And Index < m_ToolChanger.Count Then + Return m_ToolChanger(Index).sName + Else + Return String.Empty + End If + End Get + End Property + + Friend WriteOnly Property ToolPos(Index As Integer) As String + Set(value As String) + If value <> m_ToolChanger(Index).sTool Then + m_ToolChanger(Index).sTool = value + WritePrivateProfileString(S_TOOLCHANGER, K_POS & Index + 1, value, sMachIniFile) + End If + End Set + End Property + + Friend ReadOnly Property ManualToolChangerNbr As Integer + Get + Return m_ManualToolChangerNbr + End Get + End Property + + Friend ReadOnly Property ManualToolChanger As List(Of ToolChangerPos) + Get + Return m_ManualToolChanger + End Get + End Property + + Friend ReadOnly Property ManualToolChangerName(Index As Integer) As String + Get + If Index >= 0 And Index < m_ManualToolChanger.Count Then + Return m_ManualToolChanger(Index).sName + Else + Return String.Empty + End If + End Get + End Property + + Friend WriteOnly Property ManualToolPos(Index As Integer) As String + Set(value As String) + If value <> m_ManualToolChanger(Index).sTool Then + m_ManualToolChanger(Index).sTool = value + WritePrivateProfileString(S_TOOLCHANGER, K_MANUALPOS & Index + 1, value, sMachIniFile) + End If + End Set + End Property + + Friend ReadOnly Property Materials As ObservableCollection(Of Material) + Get + Return m_Materials + End Get + End Property + + Friend Sub AddMaterial(value As Material) + For Each Material In Materials + If Material.nId = value.nId Then + Exit Sub + End If + Next + WritePrivateProfileMaterial(S_MATERIALS, K_MATERIAL & m_MaxIdMat + 1, value, sMachIniFile) + m_MaxIdMat += 1 + m_Materials.Add(value) + End Sub + + Friend Sub RemoveMaterial(value As Material) + ' Se è il materiale corrente lo tolgo + If Not IsNothing(CurrMat) AndAlso CurrMat.nId = value.nId Then + CurrMat = Nothing + End If + ' Rimuovo il materiale dall'elenco + Dim Index As Integer + For Index = 0 To Materials.Count - 1 + If Materials(Index).nId = value.nId Then + m_Materials.Remove(Materials(Index)) + Exit For + End If + Next + Dim TempMat As Material = Nothing + For I = Index To m_MaxIdMat - 1 + GetPrivateProfileMaterial(S_MATERIALS, K_MATERIAL & I + 2, TempMat, sMachIniFile) + WritePrivateProfileMaterial(S_MATERIALS, K_MATERIAL & I + 1, TempMat, sMachIniFile) + Next + WritePrivateProfileMaterial(S_MATERIALS, K_MATERIAL & m_MaxIdMat, Nothing, sMachIniFile) + m_MaxIdMat -= 1 + ' Rimuovo il materiale dall'elenco di tutte le lavorazioni + Dim MachiningName As String = String.Empty + Dim bFound As Boolean = EgtMdbGetFirstMachining(MCH_MY.SAWING, MachiningName) + While bFound + EgtMdbSetCurrMachining(MachiningName) + SearchAndRemoveMat(value.nId) + bFound = EgtMdbGetNextMachining(MCH_MY.SAWING, MachiningName) + End While + bFound = EgtMdbGetFirstMachining(MCH_MY.DRILLING, MachiningName) + While bFound + EgtMdbSetCurrMachining(MachiningName) + SearchAndRemoveMat(value.nId) + bFound = EgtMdbGetNextMachining(MCH_MY.DRILLING, MachiningName) + End While + bFound = EgtMdbGetFirstMachining(MCH_MY.MILLING, MachiningName) + While bFound + EgtMdbSetCurrMachining(MachiningName) + SearchAndRemoveMat(value.nId) + bFound = EgtMdbGetNextMachining(MCH_MY.DRILLING, MachiningName) + End While + + End Sub + + ' Funzione che dato l'Id di un materiale lo rimuove dalla lavorazione corrente + Friend Sub SearchAndRemoveMat(valueId As Integer) + Dim SysNotes As String = String.Empty + EgtMdbGetCurrMachiningParam(MCH_MP.SYSNOTES, SysNotes) + If SysNotes <> String.Empty Then + Dim MachiningMaterials() = SysNotes.Split(";".ToCharArray) + SysNotes = String.Empty + For Each Material In MachiningMaterials + Dim Param() As String = Material.Split(",".ToCharArray) + If Param(0) <> valueId.ToString Then + SysNotes &= Material & ";" + End If + Next + If SysNotes(SysNotes.Length - 1) = ";" Then + SysNotes = SysNotes.Substring(0, SysNotes.Length - 1) + End If + EgtMdbSetCurrMachiningParam(MCH_MP.SYSNOTES, SysNotes) + End If + EgtMdbSaveCurrMachining() + End Sub + + Friend Property CurrMat As Material + Get + Return m_CurrMat + End Get + Set(value As Material) + If Not IsNothing(value) Then + Dim CurrMatId As String = value.nId.ToString + Dim sKey As String = If(m_bOffice, K_CURROFFICEMATERIAL, K_CURRMATERIAL) + WritePrivateProfileString(S_MATERIALS, sKey, CurrMatId, sMachIniFile) + End If + m_CurrMat = value + End Set + End Property + + Friend Function SetCurrMatByName(sMatName As String) As Boolean + ' Reset del materiale corrente + CurrMat = Nothing + ' Verifico il nome + If String.IsNullOrWhiteSpace(sMatName) Then Return False + ' Cerco il nome nella lista dei materiali + For Index = 0 To Materials.Count - 1 + If String.Compare(Materials(Index).sName, sMatName, True) = 0 Then + CurrMat = Materials(Index) + Return True + End If + Next + Return False + End Function + + Friend ReadOnly Property bHasRawProbe As Boolean + Get + Return m_HasRawProbe + End Get + End Property + +#End Region + + Sub InitCurrentMachine(sMachinesRootDir As String, sMachineName As String, + bKeyProdLine As Boolean, bKeyMill As Boolean, bKeyPolish As Boolean, bKeyWJ As Boolean, Optional bOffice As Boolean = False) + ' Modalità OFFICE + m_bOffice = bOffice + ' Nome macchina corrente + m_sMachineName = sMachineName + ' Impostazione direttorio macchina + m_sMachDir = sMachinesRootDir & "\" & sMachineName + ' Impostazione path MachIni file + m_sMachIniFile = sMachinesRootDir & "\" & sMachineName & "\" & sMachineName & ".ini" + ' Leggo estensione del file programma pezzo + GetPrivateProfileString(S_PARTPROGRAM, K_EXTENSION, "xpi", m_sIsoFileExt, sMachIniFile) + If m_sIsoFileExt(0) <> "." Then m_sIsoFileExt = "." & m_sIsoFileExt + ' Leggo flag incremento asse C + m_dDeltaC = GetPrivateProfileDouble(S_AXES, K_DELTA_C, 0.0, sMachIniFile) + ' Leggo ritardo tra reset e send per NUM + m_nResetSendDelay = GetPrivateProfileInt(S_NCNUM, K_RESETSENDDELAY, 1000, sMachIniFile) + ' Leggo se linea di produzione e parametri relativi + m_bProdLine = (GetPrivateProfileInt(S_PRODUCTIONLINE, K_ACTIVE, 0, sMachIniFile) <> 0) + If m_bProdLine And Not bKeyProdLine Then + m_bProdLine = False + EgtOutLog("Error - Production line requested but not key enabled") + End If + GetPrivateProfileString(S_PRODUCTIONLINE, K_VARPROG1, "", m_sVarProg1, sMachIniFile) + m_nProg1 = GetPrivateProfileInt(S_PRODUCTIONLINE, K_NAMEPROG1, 0, sMachIniFile) + GetPrivateProfileString(S_PRODUCTIONLINE, K_VARPROG2, "", m_sVarProg2, sMachIniFile) + m_nProg2 = GetPrivateProfileInt(S_PRODUCTIONLINE, K_NAMEPROG2, 0, sMachIniFile) + GetPrivateProfileString(S_PRODUCTIONLINE, K_LINEDATADIR, "", m_sLineDataDir, sMachIniFile) + GetPrivateProfileString(S_PRODUCTIONLINE, K_VARPROJCOPY, "", m_sVarProjCopy, sMachIniFile) + ' Parametri per nesting dalla macchina + m_bReducedCut = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_REDUCEDCUT, 0, sMachIniFile) <> 0) + m_bAligned = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_NEST_ALIGNED, 0, sMachIniFile) <> 0) + m_bAutomatic = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_NEST_AUTOMATIC, 0, sMachIniFile) <> 0) + ' Leggo offset fori + m_dHolesOffset = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OFFSET, 0, sMachIniFile) + EgtMdbSetGeneralParam(MCH_GP.EXTRARONDRIREG, m_dHolesOffset) + ' Leggo sovrapposizione fori + m_dHolesOverlap = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_OVERLAP, 0, sMachIniFile) + ' Leggo tolleranza diametro fori + m_dHolesTolerance = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_HOLES_DIAMTOLER, 0, sMachIniFile) + EgtMdbSetGeneralParam(MCH_GP.HOLEDIAMTOLER, m_dHolesTolerance) + ' Leggo un solo foro in corner + m_bOneHoleInCorner = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_ONEHOLE_INTCORNER, 0, sMachIniFile) <> 0) + ' Leggo sicurezza su tagli + m_dCutExtraLen = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_CUT, 0, sMachIniFile) + EgtMdbSetGeneralParam(MCH_GP.EXTRALONCUTREG, m_dCutExtraLen) + ' Leggo sicurezza su tagli in angoli interni + m_dAngleCutExtraLen = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_SAFE_LEN_INTCORNER, 0, sMachIniFile) + ' Leggo raggio minimo arco esterno + m_dExtArcMinRad = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_EXTARCMINRAD, 200, sMachIniFile) + EgtMdbSetGeneralParam(MCH_GP.EXTSAWARCMINRAD, m_dExtArcMinRad) + ' Leggo angolo di fianco massimo arco interno + m_dIntArcMaxSideAng = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_INTARCMAXSIDEANG, 45, sMachIniFile) + EgtMdbSetGeneralParam(MCH_GP.INTSAWARCMAXSIDEANG, m_dIntArcMaxSideAng) + ' Leggo lavorazione angoli con fresa + m_bCornerCuts = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_MILLING_ON_CORNERS, 1, sMachIniFile) <> 0) + ' Leggo lavorazione interni con fresa + m_bInternalCuts = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_MILLING_ON_SINKS, 0, sMachIniFile) <> 0) + ' Leggo accorciamento fresate negli angoli + m_dShortCut = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_MILLING_SHORTENING, 0, sMachIniFile) + ' Leggo flag tastatura tagli inclinati + m_nSacProbe = GetPrivateProfileInt(S_MACH_NEST, K_MACH_SACPROBE, -1, sMachIniFile) + ' Leggo abilitazione lavaggio lastra + m_nWashing = GetPrivateProfileInt(S_MACH_NEST, K_MACH_WASHING, -1, sMachIniFile) + ' Leggo configurazione degli utensili in macchina + m_MountedToolConfig = DirectCast(GetPrivateProfileInt(S_TOOLS, K_MOUNTEDTOOLCONFIG, 0, sMachIniFile), MountedToolConfigs) + ' Leggo flag presenza tipologie utensili + ' lama + m_bSaw = (GetPrivateProfileInt(S_TOOLS, K_SAWBLADE, 0, sMachIniFile) > 0) + ' foretto + m_bDrill = (GetPrivateProfileInt(S_TOOLS, K_DRILLBIT, 0, sMachIniFile) > 0) + ' fresa + m_bMill = (GetPrivateProfileInt(S_TOOLS, K_MILL, 0, sMachIniFile) > 0) And bKeyMill + ' mola da scasso + m_bCupWheel = (GetPrivateProfileInt(S_TOOLS, K_CUPWHEEL, 0, sMachIniFile) > 0) And bKeyMill + ' lucidante + m_bPolishingWheel = (GetPrivateProfileInt(S_TOOLS, K_POLISHINGWHEEL, 0, sMachIniFile) > 0) And bKeyPolish + ' waterjet + m_bWaterJet = (GetPrivateProfileInt(S_TOOLS, K_WATERJET, 0, sMachIniFile) > 0) And bKeyWJ + ' Leggo abilitazione visualizzazione TcPos e Head/exit + m_nShowToolChanger = GetPrivateProfileInt(S_TOOLS, K_SHOWTOOLCHANGER, 0, sMachIniFile) + m_bShowHeadExit = (GetPrivateProfileInt(S_TOOLS, K_SHOWHEADEXIT, 0, sMachIniFile) > 0) + m_nShowUserNotes = GetPrivateProfileInt(S_TOOLS, K_SHOWUSERNOTES, 0, sMachIniFile) + ' Leggo limiti diametro lama per altre operazioni + m_dMaxSawDiamForVac = GetPrivateProfileDouble(S_TOOLS, K_MAXSAWDIAMFORVAC, 630, sMachIniFile) + m_dMaxSawDiamForProbe = GetPrivateProfileDouble(S_TOOLS, K_MAXSAWDIAMFORPROBE, 630, sMachIniFile) + ' Leggo flag abilitazione rotazione grezzi durante spezza e muovi + m_bRawSplMovRotate = (GetPrivateProfileInt(S_MACH_RAWMOVE, K_MACH_RM_ROTATE, 0, sMachIniFile) <> 0) + ' Leggo flag abilitazione spostamento pezzi alla fine delle lavorazioni + m_bRawFinalMove = (GetPrivateProfileInt(S_MACH_RAWMOVE, K_MACH_RM_FINALMOVE, 0, sMachIniFile) <> 0) + ' Leggo flag presenza tipologie lavorazioni + ' lama + m_bSawing = (GetPrivateProfileInt(S_MACHININGS, K_SAWING, 0, sMachIniFile) > 0) + ' foretto + m_bDrilling = (GetPrivateProfileInt(S_MACHININGS, K_DRILLING, 0, sMachIniFile) > 0) + ' fresa + m_bMilling = (GetPrivateProfileInt(S_MACHININGS, K_MILLING, 0, sMachIniFile) > 0) And bKeyMill + ' svuotatura + m_bPocketing = (GetPrivateProfileInt(S_MACHININGS, K_POCKETING, 0, sMachIniFile) > 0) And bKeyMill + ' lucidatura + m_bPolishing = (GetPrivateProfileInt(S_MACHININGS, K_POLISHING, 0, sMachIniFile) > 0) And bKeyMill + ' sgrossatura con lama + m_bSawRoughing = (GetPrivateProfileInt(S_MACHININGS, K_SAWROUGHING, 0, sMachIniFile) > 0) + ' finitura con lama + m_bSawFinishing = (GetPrivateProfileInt(S_MACHININGS, K_SAWFINISHING, 0, sMachIniFile) > 0) + ' waterjetting + m_bWaterJetting = (GetPrivateProfileInt(S_MACHININGS, K_WATERJETTING, 0, sMachIniFile) > 0) And bKeyWJ + ' possibilità di definire attacco speciale per materiali ceramici + m_bSawingSpecialLeadIn = (GetPrivateProfileInt(S_MACHININGS, K_SAWINGSPECIALLEADIN, 0, sMachIniFile) > 0) + + ' Leggo utensili correnti + ' lama + GetPrivateProfileString(S_MACH_MACH, K_CURRSAW, Nothing, m_sCurrSaw, sMachIniFile) + ' foretto + GetPrivateProfileString(S_MACH_MACH, K_CURRDRILL, Nothing, m_sCurrDrill, sMachIniFile) + ' fresa + GetPrivateProfileString(S_MACH_MACH, K_CURRMILL, Nothing, m_sCurrMill, sMachIniFile) + ' mola + GetPrivateProfileString(S_MACH_MACH, K_CURRMILLNOTIP, Nothing, m_sCurrMillNoTip, sMachIniFile) + ' lama da sotto + GetPrivateProfileString(S_MACH_MACH, K_CURRDRIPSAW, Nothing, m_sCurrDripSaw, sMachIniFile) + ' foretto da sotto + GetPrivateProfileString(S_MACH_MACH, K_CURRDRIPDRILL, Nothing, m_sCurrDripDrill, sMachIniFile) + ' waterjet + GetPrivateProfileString(S_MACH_MACH, K_CURRWATERJET, Nothing, m_sCurrWaterJet, sMachIniFile) + + ' Leggo lavorazioni correnti + ' lama + m_sCurrSawing = EstCalc.GetCurrSawing() + ' foretto + m_sCurrDrilling = EstCalc.GetCurrDrilling() + ' fresa + m_sCurrMilling = EstCalc.GetCurrMilling() + ' svuotatura + GetPrivateProfileString(S_MACH_MACH, K_CURRPOCKETING, Nothing, m_sCurrPocketing, sMachIniFile) + ' sgrossatura con lama + GetPrivateProfileString(S_MACH_MACH, K_CURRSAWROUGHING, Nothing, m_sCurrSawRoughing, sMachIniFile) + ' finitura con lama + GetPrivateProfileString(S_MACH_MACH, K_CURRSAWFINISHING, Nothing, m_sCurrSawFinishing, sMachIniFile) + ' spatolatura con lama + GetPrivateProfileString(S_MACH_MACH, K_CURRSAWSIDEFINISHING, Nothing, m_sCurrSawSideFinishing, sMachIniFile) + ' taglio singolo + GetPrivateProfileString(S_MACH_MACH, K_CURRSAWSINGLE, Nothing, m_sCurrSawSingle, sMachIniFile) + ' lama da sotto + GetPrivateProfileString(S_MACH_MACH, K_CURRDRIPSAWING, Nothing, m_sCurrDripSawing, sMachIniFile) + ' foretto da sotto + GetPrivateProfileString(S_MACH_MACH, K_CURRDRIPDRILLING, Nothing, m_sCurrDripDrilling, sMachIniFile) + ' waterjetting + GetPrivateProfileString(S_MACH_MACH, K_CURRWATERJETTING, Nothing, m_sCurrWaterJetting, sMachIniFile) + + ' Leggo numero di portautensili + m_ToolChangerNbr = GetPrivateProfileInt(S_TOOLCHANGER, K_NUMBER, 0, sMachIniFile) + m_ToolChangerNbr = Math.Min(m_ToolChangerNbr, MAX_TC_TOOLS) + + ' Leggo da file ini nomi e utensili presenti in portautensili + For Index As Integer = 1 To m_ToolChangerNbr + Dim sName As String = String.Empty + Dim sTool As String = String.Empty + GetPrivateProfileString(S_TOOLCHANGER, K_NAME & Index, Nothing, sName, sMachIniFile) + GetPrivateProfileString(S_TOOLCHANGER, K_POS & Index, Nothing, sTool, sMachIniFile) + m_ToolChanger.Add(New ToolChangerPos(Index, sName, sTool)) + Next + + ' Leggo numero portautensili manuali + m_ManualToolChangerNbr = GetPrivateProfileInt(S_TOOLCHANGER, K_MANUALNUMBER, 0, sMachIniFile) + m_ManualToolChangerNbr = Math.Min(m_ManualToolChangerNbr, MAX_TCMAN_TOOLS) + + ' Leggo da file ini nomi e utensili manuali presenti + For Index = 1 To m_ManualToolChangerNbr + Dim sName As String = String.Empty + Dim sTool As String = String.Empty + GetPrivateProfileString(S_TOOLCHANGER, K_MANUALNAME & Index, Nothing, sName, sMachIniFile) + GetPrivateProfileString(S_TOOLCHANGER, K_MANUALPOS & Index, Nothing, sTool, sMachIniFile) + m_ManualToolChanger.Add(New ToolChangerPos(Index, sName, sTool)) + Next + + ' Leggo altezza sopratavola + m_dAdditionalTable = GetPrivateProfileDouble(S_TABLE, K_ADDITIONALTABLE, 0, sMachIniFile) + m_dTab2AdditionalTable = GetPrivateProfileDouble(S_TABLE, K_TAB2_ADDITIONALTABLE, 0, sMachIniFile) + m_dTab3AdditionalTable = GetPrivateProfileDouble(S_TABLE, K_TAB3_ADDITIONALTABLE, 0, sMachIniFile) + + ' Leggo centratura del pezzo in X sulla tavola (per macchine con nastro) + m_bCenterRawOnX = (GetPrivateProfileInt(S_TABLE, K_CENTER_RAW_ONX, 0, sMachIniFile) <> 0) + + ' Leggo offset aggiuntivo a fotografia + m_dPhotoOffsetX = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_OFFSETX, 0, sMachIniFile) + m_dPhotoOffsetY = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_OFFSETY, 0, sMachIniFile) + m_dTab2PhotoOffsetX = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_TAB2_OFFSETX, 0, sMachIniFile) + m_dTab2PhotoOffsetY = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_TAB2_OFFSETY, 0, sMachIniFile) + + ' Leggo abilitazione scelta pausa a fine lavorazione + m_bEnablePause = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_ENABLEPAUSE, 0, sMachIniFile) <> 0) + + ' Leggo flag per posizione home alla fine dei tagli diretti + m_bDirectCutsFinalHome = (GetPrivateProfileInt(S_MACH_DIRECTCUTS, K_FINALHOME, 1, sMachIniFile) <> 0) + + ' Leggo dati per feed ridotta all'inizio/fine dei tagli + m_bFsevEnable = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_CUTFSEVENABLE, 0, sMachIniFile) <> 0) + m_dFsevLength = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_CUTFSEVLEN, 0, sMachIniFile) + m_dFsevPerc = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_CUTFSEVPERC, 0, sMachIniFile) + + ' Pulisco la lista dei materiali + m_Materials.Clear() + m_MaxIdMat = 0 + ' Leggo la lista dei materiali + Dim Material As Material = Nothing + Dim nIndex As Integer = 1 + While (GetPrivateProfileMaterial(S_MATERIALS, K_MATERIAL & nIndex, Material, sMachIniFile)) + m_Materials.Add(Material) + nIndex += 1 + End While + ' Salvo massimo indice a cui sono arrivato per usarlo quando devo aggiungere nuovi elementi alla lista + m_MaxIdMat = nIndex - 1 + + ' Leggo materiale correntemente attivo + Dim sKey As String = If(m_bOffice, K_CURROFFICEMATERIAL, K_CURRMATERIAL) + Dim CurrMatId As Integer = GetPrivateProfileInt(S_MATERIALS, sKey, 0, sMachIniFile) + For Each Material In Materials + If Material.nId = CurrMatId Then + m_CurrMat = Material + Exit For + End If + Next + ' Leggo se la macchina ha il tastatore dello spessore lastra + m_HasRawProbe = (GetPrivateProfileInt(S_MACH_PROBING, K_ENABLERAWPROBE, 1, sMachIniFile) <> 0) + End Sub + + Friend Function IsVacuumMovePossible() As Boolean + ' Recupero lama della lavorazione di lama corrente + EgtMdbSetCurrMachining(sCurrSawing) + Dim sTuuid As String = String.Empty + EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTuuid) + Dim sSaw As String = String.Empty + EgtTdbGetToolFromUUID(sTuuid, sSaw) + ' Recupero diametro lama corrente + EgtTdbSetCurrTool(sSaw) + Dim dToolDiam As Double = 0 + EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolDiam) + ' Confronto con massimo ammesso + Return (dToolDiam <= dMaxSawDiamForVac) + End Function + + Friend Function IsRawProbingPossible() As Boolean + ' Recupero lama della lavorazione di lama corrente + EgtMdbSetCurrMachining(sCurrSawing) + Dim sTuuid As String = String.Empty + EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTuuid) + Dim sSaw As String = String.Empty + EgtTdbGetToolFromUUID(sTuuid, sSaw) + ' Recupero diametro lama corrente + EgtTdbSetCurrTool(sSaw) + Dim dToolDiam As Double = 0 + EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolDiam) + ' Confronto con massimo ammesso + Return (dToolDiam <= dMaxSawDiamForProbe) + End Function + + Friend Function GetPrivateProfileMaterial( + ByVal lpAppName As String, + ByVal lpKeyName As String, + ByRef Material As Material, + ByVal lpFileName As String) As Boolean + + Dim sVal As String = String.Empty + GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName) + Dim sItems() As String = sVal.Split(",".ToCharArray) + If sItems.Count() = 2 Then + Dim nId As Integer = 0 + StringToInt(sItems(0), nId) + Material = New Material(nId, sItems(1)) + Return True + End If + Return False + + End Function + + Friend Function WritePrivateProfileMaterial( + ByVal lpAppName As String, + ByVal lpKeyName As String, + ByVal Material As Material, + ByVal lpFileName As String) As Boolean + + Dim MatStr As String = Nothing + If Not IsNothing(Material) Then + MatStr = Material.nId.ToString & "," & Material.sName + End If + If WritePrivateProfileString(lpAppName, lpKeyName, MatStr, sMachIniFile) Then + Return True + End If + Return False + End Function + +End Module + +Class ToolChangerPos + + Private m_nPosition As Integer + Private m_sName As String = String.Empty + Private m_sTool As String = String.Empty + + Public ReadOnly Property nPosition As Integer + Get + Return m_nPosition + End Get + End Property + + Public ReadOnly Property sName As String + Get + Return m_sName + End Get + End Property + + Public Property sTool As String + Get + Return m_sTool + End Get + Set(value As String) + m_sTool = value + End Set + End Property + + Sub New(sPosition As Integer, sName As String, sTool As String) + m_nPosition = sPosition + m_sName = sName + m_sTool = sTool + End Sub + +End Class + +Public Class Material + + Private m_nId As Integer + Private m_sName As String + + Public ReadOnly Property nId As Integer + Get + Return m_nId + End Get + End Property + + Public Property sName As String + Get + Return m_sName + End Get + Set(value As String) + m_sName = value + End Set + End Property + + Sub New(sName As String, MaterialList As ObservableCollection(Of Material)) + Dim nMaxId As Integer = 0 + For Each Material In MaterialList + If Material.nId > nMaxId Then + nMaxId = Material.nId + End If + Next + m_nId = nMaxId + 1 + m_sName = sName + End Sub + + Sub New(nId As Integer, sName As String) + m_nId = nId + m_sName = sName + End Sub + +End Class diff --git a/EgtStoneLib/EstCalc.vb b/EgtStoneLib/EstCalc.vb new file mode 100644 index 0000000..736215f --- /dev/null +++ b/EgtStoneLib/EstCalc.vb @@ -0,0 +1,789 @@ +Imports System.Globalization +Imports EgtUILib +Imports EgtWPFLib5 + +Module EstCalc + + '-------------------------------------------------------------------------------------------------- + Friend Function DoubleToString(ByVal dVal As Double, ByVal nNumDec As Integer) As String + Dim sFormat As String = "F" + Math.Abs(nNumDec).ToString() + Dim sVal As String = dVal.ToString(sFormat, CultureInfo.InvariantCulture) + If nNumDec > 0 Then + Return sVal.TrimEnd("0".ToCharArray()).TrimEnd(".".ToCharArray) + Else + Return sVal + End If + End Function + + Friend Function StringToDouble(ByVal sVal As String, ByRef dVal As Double) As Boolean + If String.IsNullOrEmpty(sVal) Then Return False + Return EgtLuaEvalNumExpr(sVal, dVal) + End Function + + Friend Function StringToInt(sVal As String, ByRef nVal As Integer) As Boolean + Dim dVal As Double = 0 + If Not StringToDouble(sVal, dVal) Then Return False + nVal = CInt(Math.Round(dVal)) + Return True + End Function + + Friend Function LenToString(ByVal dVal As Double, ByVal nNumDec As Integer) As String + Return DoubleToString(EgtToUiUnits(dVal), nNumDec) + End Function + + Friend Function StringToLen(ByVal sVal As String, ByRef dVal As Double) As Boolean + If String.IsNullOrEmpty(sVal) Then Return False + If EgtLuaEvalNumExpr(sVal, dVal) Then + dVal = EgtFromUiUnits(dVal) + Return True + Else + Return False + End If + End Function + + '-------------------------------------------------------------------------------------------------- + Private m_nRawId As Integer = GDB_ID.NULL + Public Function GetRawId() As Integer + Return m_nRawId + End Function + + Private m_b3Raw As New BBox3d + Public Function GetRawPtMin() As Point3d + If m_b3Raw.IsEmpty() Then Return Point3d.ORIG() + Return m_b3Raw.Min() + End Function + Public Function GetRawPtMax() As Point3d + If m_b3Raw.IsEmpty() Then Return Point3d.ORIG() + Return m_b3Raw.Max() + End Function + Public Function GetRawLength() As Double + Return m_b3Raw.DimX() + End Function + Public Function GetRawWidth() As Double + Return m_b3Raw.DimY() + End Function + Public Function GetRawHeight() As Double + Return m_b3Raw.DimZ() + End Function + + Public Function UpdateRawPart() As Boolean + ' determino il grezzo (è il primo con fase 1) + m_nRawId = CamAuto.GetCurrentRaw() + If Not EgtGetRawPartBBox(m_nRawId, m_b3Raw) Then + m_nRawId = GDB_ID.NULL + m_b3Raw.Setup() + End If + Return (m_nRawId <> GDB_ID.NULL) + End Function + + ''-------------------------------------------------------------------------------------------------- + 'Public Function SetMaterialName() As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' If Not IsNothing(CurrentMachine.CurrMat) Then + ' Return EgtSetInfo(nMGrpId, INFO_PROJMAT, CurrentMachine.CurrMat.sName) + ' Else + ' Return EgtSetInfo(nMGrpId, INFO_PROJMAT, "") + ' End If + 'End Function + + 'Public Function SetMaterialPhoto(sMatDB As String) As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' ' insesrisco il nome del materiale letto dal DB + ' If Not String.IsNullOrEmpty(sMatDB) Then + ' Return EgtSetInfo(nMGrpId, INFO_PHOTOMAT, sMatDB) + ' Else + ' Return False + ' End If + 'End Function + + 'Friend Function GetMaterialName() As String + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Dim sName As String = String.Empty + ' EgtGetInfo(nMGrpId, INFO_PROJMAT, sName) + ' Return sName + 'End Function + + 'Friend Function GetMaterialPhoto() As String + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Dim sName As String = String.Empty + ' If EgtGetInfo(nMGrpId, INFO_PHOTOMAT, sName) Then + ' Return sName + ' Else + ' Return String.Empty + ' End If + 'End Function + + ''-------------------------------------------------------------------------------------------------- + 'Public Function SetSlabName(sSlabName As String) As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Return EgtSetInfo(nMGrpId, INFO_SLABNAME, sSlabName) + 'End Function + + 'Friend Function GetSlabName() As String + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Dim sSlabName As String = "" + ' EgtGetInfo(nMGrpId, INFO_SLABNAME, sSlabName) + ' Return sSlabName + 'End Function + + 'Public Function SetBlockCode(sBlockCode As String) As Boolean + ' Dim nRawId As Integer = EstCalc.GetRawId() + ' Return EgtSetInfo(nRawId, INFO_RAW_BLOCK, sBlockCode) + 'End Function + + 'Public Function SetSlabCode(sSlabCode As String) As Boolean + ' Dim nRawId As Integer = EstCalc.GetRawId() + ' Return EgtSetInfo(nRawId, INFO_RAW_SLABNBR, sSlabCode) + 'End Function + + ''-------------------------------------------------------------------------------------------------- + 'Public Function SetSlabHeight(dSlabHeight As Double) As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Return EgtSetInfo(nMGrpId, INFO_SLABHEIGHT, dSlabHeight) + 'End Function + + 'Friend Function GetSlabHeight() As Double + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Dim dSlabHeight As Double = 0 + ' EgtGetInfo(nMGrpId, INFO_SLABHEIGHT, dSlabHeight) + ' Return dSlabHeight + 'End Function + + ''-------------------------------------------------------------------------------------------------- + 'Friend Function SetCurrSawing(sCurrSawing As String) As Boolean + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return False + ' Return EgtSetInfo(nOperId, INFO_CURRSAWING, sCurrSawing) + 'End Function + + 'Friend Function GetCurrSawing() As String + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return "" + ' Dim sCurrSawing As String = String.Empty + ' EgtGetInfo(nOperId, INFO_CURRSAWING, sCurrSawing) + ' Return sCurrSawing + 'End Function + + 'Friend Function SetCurrMilling(sCurrMilling As String) As Boolean + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return False + ' Return EgtSetInfo(nOperId, INFO_CURRMILLING, sCurrMilling) + 'End Function + + 'Friend Function GetCurrMilling() As String + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return "" + ' Dim sCurrMilling As String = String.Empty + ' EgtGetInfo(nOperId, INFO_CURRMILLING, sCurrMilling) + ' Return sCurrMilling + 'End Function + + 'Friend Function SetCurrDrilling(sCurrDrilling As String) As Boolean + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return False + ' Return EgtSetInfo(nOperId, INFO_CURRDRILLING, sCurrDrilling) + 'End Function + + 'Friend Function GetCurrDrilling() As String + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return "" + ' Dim sCurrDrilling As String = String.Empty + ' EgtGetInfo(nOperId, INFO_CURRDRILLING, sCurrDrilling) + ' Return sCurrDrilling + 'End Function + + 'Friend Function SetCurrPocketing(sCurrMilling As String) As Boolean + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return False + ' Return EgtSetInfo(nOperId, INFO_CURRPOCKETING, sCurrMilling) + 'End Function + + 'Friend Function GetCurrPocketing() As String + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return "" + ' Dim sCurrPocketing As String = String.Empty + ' EgtGetInfo(nOperId, INFO_CURRPOCKETING, sCurrPocketing) + ' Return sCurrPocketing + 'End Function + + 'Friend Function SetCurrWaterjetting(sCurrMilling As String) As Boolean + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return False + ' Return EgtSetInfo(nOperId, INFO_CURRWATERJETTING, sCurrMilling) + 'End Function + + 'Friend Function GetCurrWaterjetting() As String + ' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers") + ' If nOperId = GDB_ID.NULL Then Return "" + ' Dim sCurrWaterjetting As String = String.Empty + ' EgtGetInfo(nOperId, INFO_CURRWATERJETTING, sCurrWaterjetting) + ' Return sCurrWaterjetting + 'End Function + + ''-------------------------------------------------------------------------------------------------- + 'Public Function SetOrderMachiningFlag() As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Return EgtSetInfo(nMGrpId, INFO_MACHORDER, 1) + 'End Function + + 'Friend Function ResetOrderMachiningFlag() As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Return EgtRemoveInfo(nMGrpId, INFO_MACHORDER) + 'End Function + + 'Friend Function GetOrderMachiningFlag() As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Dim nFlag As Integer = 0 + ' EgtGetInfo(nMGrpId, INFO_MACHORDER, nFlag) + ' Return (nFlag <> 0) + 'End Function + + 'Public Function AdjustAdditionalTable() As Boolean + ' ' Recupero altezza sottotavola corrente + ' Dim nFixtId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), MACH_FIXT_GROUP) + ' Dim nAddTabId As Integer = EgtGetFirstNameInGroup(nFixtId, MACH_ADD_TABLE) + ' Dim dCurrAddTab As Double = 0 + ' If nAddTabId <> GDB_ID.NULL And Not EgtGetInfo(nAddTabId, KEY_ADD_TABLE, dCurrAddTab) Then + ' Dim b3AddTab As New BBox3d + ' EgtGetBBoxGlob(nAddTabId, GDB_BB.STANDARD, b3AddTab) + ' dCurrAddTab = b3AddTab.DimZ() + ' End If + ' ' Se valore cambiato, aggiorno... + ' Dim dDeltaZ As Double = dAdditionalTable - dCurrAddTab + ' If Math.Abs(dDeltaZ) > EPS_SMALL Then + ' AddAdditionalTable() + ' UpdateAllRawsZ(dDeltaZ) + ' ' !!! FOTO DA GESTIRE !!! + ' 'If GetPhoto() <> GDB_ID.NULL Then + ' ' UpdatePhoto() + ' ' UpdateContour() + ' ' If EgtGetRawPartCount() > 0 Then + ' ' ShowPhoto(False) + ' ' End If + ' 'End If + ' End If + ' Return True + 'End Function + + 'Public Function AddAdditionalTable() As Boolean + ' ' Gruppo dei sottopezzi + ' Dim nFixtId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), MACH_FIXT_GROUP) + ' ' Elimino eventuale vecchia tavola dal gruppo dei bloccaggi + ' EgtErase(EgtGetFirstNameInGroup(nFixtId, MACH_ADD_TABLE)) + ' ' Altezza eventuale tavola aggiuntiva + ' Dim dAddTable As Double = dAdditionalTable + ' ' Se non esiste sovratavola, esco subito + ' If dAddTable < 10 * EPS_SMALL Then Return True + ' ' Recupero box tavola + ' Dim ptMin, ptMax As Point3d + ' EgtGetTableArea(1, ptMin, ptMax) + ' ' Aggiungo sovratavola nel gruppo dei bloccaggi + ' ptMax.z -= DELTAZ_ADDTAB + ' ptMin.z = ptMax.z + ' ptMax.z += dAddTable + ' Dim nAddTabId As Integer = EgtCreateSurfTmBBox(nFixtId, ptMin, ptMax, GDB_RT.GLOB) + ' If nAddTabId = GDB_ID.NULL Then Return False + ' EgtSetName(nAddTabId, MACH_ADD_TABLE) + ' EgtSetColor(nAddTabId, New Color3d(150, 75, 0, 100), True) + ' EgtSetInfo(nAddTabId, KEY_ADD_TABLE, dAddTable) + ' Return True + 'End Function + + 'Public Function SetWashingFlag(bWash As Boolean) As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Return EgtSetInfo(nMGrpId, INFO_WASHING, bWash) + 'End Function + + 'Public Function GetWashingFlag() As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Dim bFlag As Boolean = True + ' EgtGetInfo(nMGrpId, INFO_WASHING, bFlag) + ' Return bFlag + 'End Function + + 'Public Function UpdateWashingFlag() As Boolean + ' Dim bCurrWash As Boolean = ( CurrentMachine.nWashing <> 0) + ' Dim bProjWash As Boolean = GetWashingFlag() + ' If bCurrWash <> bProjWash Then Return SetWashingFlag(bCurrWash) + ' Return True + 'End Function + + 'Public Function SetSideAngCutProbeFlag(bSacProbe As Boolean) As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' If bSacProbe Then + ' Return EgtSetInfo(nMGrpId, INFO_SACPROBE, True) + ' Else + ' Return EgtRemoveInfo(nMGrpId, INFO_SACPROBE) + ' End If + 'End Function + + 'Public Function GetSideAngCutProbeFlag() As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Dim bFlag As Boolean = False + ' EgtGetInfo(nMGrpId, INFO_SACPROBE, bFlag) + ' Return bFlag + 'End Function + + 'Public Function UpdateSideAngCutProbeFlag() As Boolean + ' Dim bCurrSacProbe As Boolean = ( CurrentMachine.nSacProbe > 0) + ' Dim bProjSacProbe As Boolean = GetSideAngCutProbeFlag() + ' If bCurrSacProbe <> bProjSacProbe Then Return SetSideAngCutProbeFlag(bCurrSacProbe) + ' Return True + 'End Function + + 'Public Function SetReducedCut(bReduced As Boolean) As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Return EgtSetInfo(nMGrpId, INFO_REDUCEDCUT, bReduced) + 'End Function + + 'Public Function GetReducedCut() As Boolean + ' Dim nMGrpId As Integer = EgtGetCurrMachGroup() + ' Dim bFlag As Boolean = False + ' EgtGetInfo(nMGrpId, INFO_REDUCEDCUT, bFlag) + ' Return bFlag + 'End Function + + ''-------------------------------------------------------------------------------------------------- + 'Public Function PartIsFree(nId As Integer) As Boolean + ' ' Deve essere un pezzo + ' If Not EgtIsPart(nId) Then Return False + ' ' Non deve essere inserito in grezzi della prima fase di qualche gruppo di lavoro + ' Dim sList As String = String.Empty + ' If Not EgtGetInfo(nId, "!LST", sList) Then Return True + ' Dim sItems() As String = sList.Split(",".ToCharArray) + ' If sItems.Count() = 0 Then Return True + ' For Each sLstId In sItems + ' Dim nLstId As Integer = GDB_ID.NULL + ' StringToInt(sLstId, nLstId) + ' Dim nRawId = EgtGetParent(nLstId) + ' Dim nPhase As Integer = 1 + ' EgtGetInfo(nRawId, "Ph", nPhase) + ' If nPhase = 1 Then + ' Dim sName As String = String.Empty + ' If EgtGetName(EgtGetParent(nRawId), sName) AndAlso sName = MACH_RAWS_GROUP Then Return False + ' End If + ' Next + ' Return True + 'End Function + + 'Public Function GetPartMachGroup(nId As Integer) As Integer + ' ' Identificativo di ricerca nel grezzo + ' Dim nFindId As Integer = GDB_ID.NULL + ' ' Se pezzo non assegnato a gruppo + ' If EgtIsPart(nId) Then + ' ' Cerco associazione a gruppo in grezzo della prima fase di qualche gruppo di lavoro + ' Dim sList As String = String.Empty + ' If Not EgtGetInfo(nId, "!LST", sList) Then Return GDB_ID.NULL + ' Dim sItems() As String = sList.Split(",".ToCharArray) + ' If sItems.Count() = 0 Then Return GDB_ID.NULL + ' For Each sLstId In sItems + ' Dim nLstId As Integer = GDB_ID.NULL + ' StringToInt(sLstId, nLstId) + ' Dim nRawId = EgtGetParent(nLstId) + ' Dim nPhase As Integer = 1 + ' EgtGetInfo(nRawId, "Ph", nPhase) + ' If nPhase = 1 Then + ' Dim sRawsName As String = String.Empty + ' If EgtGetName(EgtGetParent(nRawId), sRawsName) AndAlso sRawsName = MACH_RAWS_GROUP Then + ' nFindId = nLstId + ' Exit For + ' End If + ' End If + ' Next + ' Else + ' nFindId = nId + ' End If + ' ' Verifico identificativo di ricerca + ' If nFindId = GDB_ID.NULL Then Return GDB_ID.NULL + ' ' Il padre del padre deve essere il gruppo dei grezzi + ' Dim nRawsId As Integer = EgtGetParent(EgtGetParent(nFindId)) + ' Dim sName As String = String.Empty + ' If Not EgtGetName(nRawsId, sName) OrElse sName <> MACH_RAWS_GROUP Then Return GDB_ID.NULL + ' ' Il padre del gruppo dei grezzi deve essere il gruppo di lavoro + ' Dim nMachGrpId As Integer = EgtGetParent(nRawsId) + ' Dim sMachGrpName As String = String.Empty + ' If Not EgtGetMachGroupName(nMachGrpId, sMachGrpName) Then Return GDB_ID.NULL + ' Return nMachGrpId + 'End Function + + ''-------------------------------------------------------------------------------------------------- + 'Public Sub HideParkedParts(Optional bDisableModified As Boolean = True) + ' ' Se richiesto, disabilito impostazione modificato + ' Dim bOldEnMod As Boolean = False + ' If bDisableModified Then + ' bOldEnMod = EgtGetEnableModified() + ' If bOldEnMod Then EgtDisableModified() + ' End If + ' ' Nascondo pezzi parcheggiati + ' Dim nPartId As Integer = EgtGetFirstPart() + ' While nPartId <> GDB_ID.NULL + ' EgtSetStatus(nPartId, GDB_ST.OFF) + ' nPartId = EgtGetNextPart(nPartId) + ' End While + ' ' Se necessario, ripristino precedente impostazione modificato + ' If bOldEnMod Then EgtEnableModified() + 'End Sub + + 'Public Sub ShowParkedParts(Optional bDisableModified As Boolean = True) + ' ' Se richiesto, disabilito impostazione modificato + ' Dim bOldEnMod As Boolean = False + ' If bDisableModified Then + ' bOldEnMod = EgtGetEnableModified() + ' If bOldEnMod Then EgtDisableModified() + ' End If + ' ' Visualizzo pezzi parcheggiati che non appartengano a grezzi di altri gruppi + ' Dim nPartId As Integer = EgtGetFirstPart() + ' While nPartId <> GDB_ID.NULL + ' If PartIsFree(nPartId) Then + ' EgtSetStatus(nPartId, GDB_ST.ON_) + ' Else + ' EgtSetStatus(nPartId, GDB_ST.OFF) + ' End If + ' nPartId = EgtGetNextPart(nPartId) + ' End While + ' ' Se necessario, ripristino precedente impostazione modificato + ' If bOldEnMod Then EgtEnableModified() + 'End Sub + + 'Public Function AdjustFlatPart(nPartId As Integer) As Boolean + ' ' Ciclo sui layer + ' Dim nLayerId As Integer = EgtGetFirstLayer(nPartId) + ' While nLayerId <> GDB_ID.NULL + ' ' Recupero il layer successivo + ' Dim nNextLayerId As Integer = EgtGetNextLayer(nLayerId) + ' ' Recupero il nome del layer + ' Dim sLayName As String = String.Empty + ' If EgtGetName(nLayerId, sLayName) Then + ' ' Se layer OutLoop o InLoop + ' If String.Compare(sLayName, NAME_OUTLOOP, True) = 0 Or + ' String.Compare(sLayName, NAME_INLOOP, True) = 0 Then + ' ' Sistemo i layer per applicare facilmente le lavorazioni + ' EgtAdjustFlatPartLayer(nLayerId) + ' End If + ' ' Se senza nome, lo elimino + ' Else + ' EgtErase(nLayerId) + ' End If + ' ' Passo al layer successivo + ' nLayerId = nNextLayerId + ' End While + ' Return True + 'End Function + + 'Friend Function SetTextColor( nGroup As Integer) As Boolean + ' ' Recupero il colore da assegnare ai testi + ' Dim colText As New Color3d( 0, 0, 0) + ' Dim sTextColor As String = " " + ' If GetMainPrivateProfileString(S_NEST, K_TEXTCOLOR, " ", sTextColor) <> 0 Then + ' Dim sTextColorArray() As String = sTextColor.Split(","c) + ' Dim nRed As Integer = 0 : Integer.TryParse( sTextColorArray(0), nRed) + ' Dim nGreen As Integer = 0 : Integer.TryParse( sTextColorArray(1), nGreen) + ' Dim nBlue As Integer = 0 : Integer.TryParse( sTextColorArray(2), nBlue) + ' colText.Setup( nRed, nGreen, nBlue) + ' End If + ' ' Assegno questo colore ai testi del layer indicato + ' Dim nId As Integer = EgtGetFirstInGroup( nGroup) + ' While nId <> GDB_ID.NULL + ' If EgtGetType(nId) = GDB_TY.EXT_TEXT Then + ' EgtSetColor(nId, colText) + ' End If + ' nId = EgtGetNext(nId) + ' End While + ' Return True + 'End Function + + ''-------------------------------------------------------------------------------------------------- + 'Public Function VerifyTrfData(nId As Integer) As Boolean + ' ' Verifico se pezzo da Trf + ' If Not EgtExistsInfo(nId, "OC") Then Return True + ' ' Recupero e verifico lo spessore del pezzo + ' Dim dTh As Double = 0 + ' EgtGetInfo(nId, "T", dTh) + ' dim dTrfThickTolerance As double = GetMainPrivateProfileDouble(S_NEST, K_TRFTHICKTOLERANCE, 0.1) + ' If Math.Abs(dTh - m_b3Raw.DimZ()) > dTrfThickTolerance Then Return False + ' ' Recupero il materiale e la finitura superficiale del pezzo + ' Dim sMat As String = "" + ' EgtGetInfo(nId, "MT", sMat) + ' Dim sSurf As String = "" + ' EgtGetInfo(nId, "SRF", sSurf) + ' ' Recupero materiale e finitura superficiale di pezzo già inserito (come dati di riferimento) + ' Dim sRefMat As String = "" + ' Dim sRefSurf As String = "" + ' Dim nPartId As Integer = EgtGetFirstPartInRawPart(m_nRawId) + ' While nPartId <> GDB_ID.NULL + ' If EgtGetInfo(nPartId, "MT", sRefMat) And EgtGetInfo(nPartId, "SRF", sRefSurf) Then Exit While + ' nPartId = EgtGetNextPartInRawPart(nPartId) + ' End While + ' If String.IsNullOrWhiteSpace(sRefMat) And String.IsNullOrWhiteSpace(sRefSurf) Then Return True + ' ' Verifico materiale e finitura superficiale + ' If sMat <> sRefMat Or sSurf <> sRefSurf Then Return False + ' Return True + 'End Function + + 'Public Function PreInsertOnePart(nId As Integer) As Boolean + ' ' Se non esiste grezzo o pezzo non in parcheggio, esco + ' If m_nRawId = GDB_ID.NULL OrElse Not EgtIsPart(nId) Then Return False + ' ' Sistemazioni per eventuali lati inclinati con tallone + ' AdjustPartSideAngleHeel(nId, m_b3Raw.DimZ()) + ' ' Sistemazioni per eventuali lati esterni inclinati e/o offsettati + ' EgtCalcFlatPartUpRegion(nId, True) + ' EgtCalcFlatPartDownRegion(nId, m_b3Raw.DimZ()) + ' ' Dimensioni del pezzo + ' Dim b3Part As New BBox3d + ' If Not EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, b3Part) Then Return False + ' ' Centro del grezzo + ' Dim ptRawCenter As Point3d + ' If Not EgtGetRawPartCenter(m_nRawId, ptRawCenter) Then Return False + ' Dim dRawCenX = ptRawCenter.x - m_b3Raw.Min().x + ' Dim dRawCenY = ptRawCenter.y - m_b3Raw.Min().y + ' ' Inserisco il pezzo nel grezzo, in centro in XY e in alto in Z + ' Dim ptP As New Point3d(dRawCenX - 0.5 * b3Part.DimX(), dRawCenY - 0.5 * b3Part.DimY(), m_b3Raw.DimZ()) + ' If Not EgtAddPartToRawPart(nId, ptP, m_nRawId) Then Return False + ' ' Aggiungo le lavorazioni standard + ' Dim nWarn As Integer = 0 + ' AddMachinings(nId, nWarn) + ' ' Lama troppo grande per utilizzo ventosa + ' If nWarn = 1 Then OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SPLITPAGEUC + 11), 3, MSG_TYPE.WARNING) + ' Return true + 'End Function + + 'Public Function PreRemoveOnePart(nId As Integer) As Boolean + ' ' Se non esiste il pezzo, esco + ' If nId = GDB_ID.NULL Then Return false + ' ' Rimuovo le lavorazioni + ' EraseMachinings(nId) + ' ' Elimino eventuali modifiche per lati esterni inclinati e/o offsettati + ' EgtCalcFlatPartUpRegion(nId, False) + ' EgtCalcFlatPartDownRegion(nId, 0) + ' ' Eventuale cancellazione solido per taglio da sotto + ' EraseSolidForDrip(nId) + ' ' Parcheggio + ' EgtRemovePartFromRawPart(nId) + ' EgtSetStatus(nId, GDB_ST.ON_) + ' Return true + 'End Function + + 'Public Function InsertOnePart(nId As Integer, bAligned As Boolean, bReducedCut As Boolean) As Boolean + ' ' Se il pezzo non è in parcheggio, non si può inserire + ' If Not EgtIsPart(nId) Then Return False + ' ' Metto pezzo in centro grezzo con lavorazioni e sistemazioni varie + ' Dim bFit As Boolean = False + ' If PreInsertOnePart( nId) Then + ' ' Eseguo nesting + ' If UpdateNestRegions() Then + ' EnableReferenceRegion(bAligned) + ' If Not EgtExistsInfo(m_nRawId, KEY_RAWBYPOINTS) Then + ' bFit = EgtPackPartInRectangle(nId, bReducedCut, True) + ' End If + ' If Not bFit Then + ' bFit = EgtPackPart(nId, bReducedCut, True) + ' End If + ' End If + ' End If + ' ' Gestione risultato nesting + ' If bFit Then + ' ' Eventuale aggiunta solido per taglio da sotto + ' UpdateSolidForDrip(nId) + ' Return True + ' Else + ' ' Ripristino lo stato originale + ' PreRemoveOnePart( nId) + ' Return False + ' End If + 'End Function + + 'Private Function AdjustPartSideAngleHeel(nPartId As Integer, dTh As Double) As Boolean + ' ' Recupero entità del layer esterno e di quelli interni + ' Dim vEnt As New List(Of Integer) + ' Dim nEntId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_OUTLOOP)) + ' While nEntId <> GDB_ID.NULL + ' vEnt.Add(nEntId) + ' nEntId = EgtGetNext(nEntId) + ' End While + ' Dim nLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_INLOOP) + ' While nLayId <> GDB_ID.NULL + ' nEntId = EgtGetFirstInGroup(nLayId) + ' While nEntId <> GDB_ID.NULL + ' vEnt.Add(nEntId) + ' nEntId = EgtGetNext(nEntId) + ' End While + ' nLayId = EgtGetNextName(nLayId, NAME_INLOOP) + ' End While + ' ' Aggiorno le entità con tallone e quelle con angolo esterno + ' Const AGG_DEPTH As Double = 2.0 + ' For Each nEnt As Integer In vEnt + ' ' Se aggiornamento vietato, vado oltre + ' If EgtExistsInfo( nEnt, INFO_SIDE_FIXED) Then continue for + ' ' Recupero eventuali tallone ed angolo originale + ' Dim dHeel As Double = 0 + ' Dim dSideAng As Double = 0 + ' EgtGetInfo(nEnt, INFO_HEEL, dHeel) + ' EgtGetInfo(nEnt, INFO_ORIG_SIDE_ANGLE, dSideAng) + ' If Math.Abs(dSideAng) > EPS_ANG_SMALL And dHeel > 10 * EPS_SMALL Then + ' ' Angolo esterno + ' If dSideAng > 0 Then + ' ' Se tallone inferiore a spessore + ' If dHeel < dTh - 10 * EPS_SMALL Then + ' EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0) + ' EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, dSideAng) + ' EgtSetInfo(nEnt, INFO_OFFSET2, -(dTh - dHeel) * Math.Tan(dSideAng * Math.PI / 180)) + ' EgtSetInfo(nEnt, INFO_DEPTH2, (dTh - dHeel) + AGG_DEPTH) + ' ' altrimenti, tallone superiore a spessore -> non c'è taglio inclinato + ' Else + ' EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0) + ' EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, 0.0) + ' EgtRemoveInfo(nEnt, INFO_OFFSET2) + ' EgtRemoveInfo(nEnt, INFO_DEPTH2) + ' End If + ' ' Angolo interno + ' Else + ' ' Se tallone inferiore a spessore + ' If dHeel < dTh - 10 * EPS_SMALL Then + ' EgtSetInfo(nEnt, INFO_OFFSET, dHeel * Math.Tan(-dSideAng * Math.PI / 180)) + ' EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, 0.0) + ' EgtSetInfo(nEnt, INFO_DEPTH2, dHeel + AGG_DEPTH) + ' ' altrimenti, tallone superiore a spessore -> non c'è taglio inclinato + ' Else + ' EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0) + ' EgtRemoveInfo(nEnt, INFO_OFFSET) + ' EgtRemoveInfo(nEnt, INFO_SIDE_ANGLE2) + ' EgtRemoveInfo(nEnt, INFO_DEPTH2) + ' End If + ' End If + ' ' Se altrimenti inclinazione esterna + ' ElseIf dSideAng > EPS_ANG_SMALL Then + ' EgtSetInfo(nEnt, INFO_OFFSET, -dTh * Math.Tan(dSideAng * Math.PI / 180)) + ' End If + ' Next + ' Return True + 'End Function + + 'Public Function StoreOnePart(ByVal nId As Integer, Optional ByVal bForced As Boolean = False) As Boolean + ' ' Se pezzo in grezzo, metto in parcheggio (sempre possibile) + ' If bForced OrElse + ' (m_nRawId <> GDB_ID.NULL AndAlso EgtGetParent(nId) = m_nRawId) Then + ' ' Ripristino lo stato originale + ' PreRemoveOnePart( nId) + ' ' Parcheggio + ' PackPartInStore(nId) + ' ' Aggiusto la posizione in Z + ' Dim ptPartMin, ptPartMax As Point3d + ' If EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, ptPartMin, ptPartMax) And m_nRawId <> GDB_ID.NULL Then + ' EgtMove(nId, New Vector3d(0, 0, m_b3Raw.Max().z - ptPartMax.z), GDB_RT.GLOB) + ' End If + ' Return True + ' End If + ' Return False + 'End Function + + 'Public Function PackPartInStore(nId As Integer) As Boolean + ' ' Recupero box tavola + ' Dim b3Tab As New BBox3d + ' If Not EgtGetTableArea(1, b3Tab) Then + ' b3Tab.Add(New Point3d(0, 0, 0)) + ' b3Tab.Add(New Point3d(-3600, -2600, 0)) + ' End If + ' ' Parcheggio + ' Const STORE_LARGH As Double = 6000 + ' Const STORE_DIST As Double = 200 + ' Const STORE_OFFS As Double = 20 + ' Dim dStXmin As Double = b3Tab.Min().x - 0.5 * (STORE_LARGH - b3Tab.DimX()) + ' Return EgtPackBox(nId, dStXmin, -INFINITO, dStXmin + STORE_LARGH, b3Tab.Min().y - STORE_DIST, STORE_OFFS, False) + 'End Function + + 'Friend Function VerifyPartsNesting(bReducedCut As Boolean) As Boolean + ' ' Aggiorno regioni per nesting + ' UpdateNestRegions() + ' EnableReferenceRegion(False) + ' ' Ciclo su tutti i pezzi in tavola + ' Dim nPartId As Integer = EgtGetFirstGroupInGroup(m_nRawId) + ' While nPartId <> GDB_ID.NULL + ' If Not EgtVerifyPart(nPartId, bReducedCut) Then + ' Return False + ' End If + ' nPartId = EgtGetNextGroup(nPartId) + ' End While + ' Return True + 'End Function + + 'Friend Function StoreCollisionParts(bReducedCut As Boolean) As Boolean + ' ' Aggiorno regioni per nesting + ' UpdateNestRegions() + ' EnableReferenceRegion(False) + ' ' Ciclo su tutti i pezzi in tavola (dall'ultimo) + ' Dim nPartId As Integer = EgtGetLastGroupInGroup(m_nRawId) + ' While nPartId <> GDB_ID.NULL + ' Dim nPrevPartId As Integer = EgtGetPrevGroup(nPartId) + ' If Not EgtVerifyPart(nPartId, bReducedCut) Then + ' StoreOnePart(nPartId, True) + ' End If + ' nPartId = nPrevPartId + ' End While + ' Return True + 'End Function + + 'Public Function UpdateNestRegions() As Boolean + ' ' Se necessario, creo la regione fuori kerf + ' Dim nKerfId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF) + ' EgtCreateOutRegion(GetRawId(), nKerfId) + ' ' Se necessario, creo la regione di riferimento + ' EgtCreateReferenceRegion(GetRawId(), nKerfId, True) + ' ' Se necessario, creo le regioni per le aree danneggiate + ' Dim nId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED) + ' While nId <> GDB_ID.NULL + ' EgtCreateDamagedRegion(GetRawId(), nId) + ' nId = EgtGetNextName(nId, NAME_DAMAGED) + ' End While + ' Return True + 'End Function + + 'Public Function EnableReferenceRegion(bEnable As Boolean) As Boolean + ' ' Recupero identificativo della regione di riferimento + ' Dim nRegId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_REF_REG) + ' If nRegId = GDB_ID.NULL Then Return False + ' ' Imposto l'abilitazione voluta + ' If bEnable Then + ' EgtRemoveInfo(nRegId, KEY_REF_REG_OFF) + ' Else + ' EgtSetInfo(nRegId, KEY_REF_REG_OFF, 1) + ' End If + ' Return True + 'End Function + + 'Public Function AddTopToPartRegion( nRegId As Integer) As Boolean + ' Dim frReg As New Frame3d : EgtGetGroupGlobFrame( nRegId, frReg) + ' Dim b3Reg As New BBox3d : EgtGetBBoxGlob( nRegId, GDB_BB.STANDARD, b3Reg) + ' Dim dH As Double = Math.Min(0.1 * b3Reg.DimY(), 30) + ' Dim ptIns As New Point3d( b3Reg.Center().x, b3Reg.Max().y - dH, 0) + ' ptIns.ToLoc( frReg) + ' Dim nSfrId As Integer = EgtGetFirstInGroup( nRegId) + ' While nSfrId <> GDB_ID.NULL + ' If EgtGetType( nSfrId) = GDB_TY.SRF_FRGN Then Exit While + ' nSfrId = EgtGetNext( nSfrId) + ' End While + ' If nSfrId <> GDB_ID.NULL Then + ' Dim ptStart As New Point3d ( b3Reg.Min().x, b3Reg.Max().y - dH, 0) + ' ptStart.ToLoc( frReg) + ' Dim ptEnd As New Point3d ( b3Reg.Max().x, b3Reg.Max().y - dH, 0) + ' ptEnd.ToLoc( frReg) + ' Dim nLineId As Integer = EgtCreateLine( nRegId, ptStart, ptEnd) + ' Dim nCount As Integer = 0 + ' Dim nNewId As Integer = EgtTrimCurveWithRegion( nLineId, nSfrId, True, False, nCount) + ' If nNewId <> GDB_ID.NULL Then + ' If nCount > 0 Then EgtMidPoint( nNewId, ptIns) + ' For nTmpId As Integer = nNewId To nNewId + nCount - 1 + ' EgtErase( nTmpId) + ' Next + ' Else + ' EgtErase( nLineId) + ' End If + ' End If + ' Dim vtDir As New Vector3d( 1, 0, 0) + ' vtDir.ToLoc( frReg) + ' Dim dLen, dAngV, dAngH As Double + ' vtDir.ToSpherical( dLen, dAngV, dAngH) + ' Dim nText As Integer = EgtCreateTextAdv(nRegId, ptIns, dAngH, "*TOP*", "", 500, False, dH, 1, 0, INS_POS.MC) + ' Return ( nText <> GDB_ID.NULL) + 'End Function + +End Module diff --git a/EgtStoneLib/EstPhoto.vb b/EgtStoneLib/EstPhoto.vb new file mode 100644 index 0000000..6234323 --- /dev/null +++ b/EgtStoneLib/EstPhoto.vb @@ -0,0 +1,521 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2017 +'---------------------------------------------------------------------------- +' File : GenPhoto.vb Data : 12.04.17 Versione : 1.8d1 +' Contenuto : Modulo gestione fotografie. +' Ogni gruppo di lavoro può avere una sua foto della lastra. +' +' +' Modifiche : 12.04.17 DS Creazione modulo. +' +' +'---------------------------------------------------------------------------- + +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Module EstPhoto + + Friend Function LoadPhoto(sPath As String, + ByRef nSlabId As Integer, ByRef sBlockCode As String, ByRef sSlabCode As String, ByRef sSlabName As String, ByRef sMat As String) As Boolean + ' Verifico esistenza file immagine + If Not File.Exists(sPath) Then Return False + ' Leggo eventuale file dati aggiuntivi + Dim dThick As Double = 0 + Dim ptOri As New Point3d(0, 0, 0) + Dim ptCen As New Point3d(0, 0, INFINITO) + Dim dMMxPixel As Double = 1 + Dim dCoeff As Double = 1 + If Not ReadAuxData(sPath, nSlabId, sBlockCode, sSlabCode, sSlabName, sMat, dThick, ptOri, ptCen, dMMxPixel, dCoeff) Then Return False + ' Aggiungo eventuali offset + ptOri += CurrentMachine.PhotoOffset + ptCen += CurrentMachine.PhotoOffset + ' Imposto eventuale spezzore grezzo + If dThick > EPS_SMALL Then + OmagOFFICEMap.refRawPartTabVM.Height = DoubleToString( dThick, 3) + End If + ' Altezza eventuale tavola aggiuntiva + Dim dAddTable As Double = CurrentMachine.dAdditionalTable + ' Aggiusto dati per spessore grezzo + If Math.Abs(EstCalc.GetRawHeight() + dAddTable) > EPS_SMALL Then + ' Coefficiente di scalatura + Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z) + dMMxPixel *= dFsca + ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca + ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca + ptOri.z = EstCalc.GetRawHeight() + dAddTable + End If + ' Recupero origine della tavola e porto i punti in globale + Dim ptTab As Point3d + If Not EgtGetTableRef(1, ptTab) Then Return False + ptOri.ToGlob(New Frame3d(ptTab)) + ptCen.ToGlob(New Frame3d(ptTab)) + ' Recupero le dimensioni della tavola + Dim b3Tab As New BBox3d + If Not EgtGetTableArea(1, b3Tab) Then Return False + b3Tab.Expand(100, 100, 0) + ' Elimino eventuale precedente foto + Dim nOldPhotoId = GetPhoto() + If nOldPhotoId <> GDB_ID.NULL Then EgtErase(nOldPhotoId) + ' Se non esiste il gruppo per le foto, lo creo + Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP) + If nPhGrpId = GDB_ID.NULL Then + nPhGrpId = EgtCreateGroup(GDB_ID.ROOT) + If nPhGrpId = GDB_ID.NULL Then Return False + EgtSetName(nPhGrpId, PHOTO_GRP) + End If + EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM) + ' Carico la fotografia + Return EgtAddPhoto(GetPhotoName(), sPath, ptOri, ptCen, dMMxPixel, nPhGrpId, b3Tab.Min(), b3Tab.Max()) <> GDB_ID.NULL + End Function + + Friend Function LoadContour(sPath As String) As Boolean + ' Elimino eventuale vecchio contorno + RemoveContour() + ' Leggo eventuale file dati aggiuntivi + Dim nSlabId As Integer = 0 + Dim sBlockCode As String = "" + Dim sSlabCode As String = "" + Dim sSlabName As String = "" + Dim sMat As String = "" + Dim dThick As Double = 0 + Dim ptOri As New Point3d(0, 0, 0) + Dim ptCen As New Point3d(0, 0, INFINITO) + Dim dMMxPixel As Double = 1 + Dim dCoeff As Double = 1 + If Not ReadAuxData(sPath, nSlabId, sBlockCode, sSlabCode, sSlabName, sMat, dThick, ptOri, ptCen, dMMxPixel, dCoeff) Then Return False + ' Aggiungo eventuali offset + ptOri += CurrentMachine.PhotoOffset + ptCen += CurrentMachine.PhotoOffset + ' Recupero dimensione della immagine originale della fotografia + Dim nPixelX As Integer = 0 + Dim nPixelY As Integer = 0 + If Not EgtGetPhotoImagePixels(GetPhoto(), nPixelX, nPixelY) Then Return False + ' Altezza eventuale tavola aggiuntiva + Dim dAddTable As Double = CurrentMachine.dAdditionalTable + ' Aggiusto dati per spessore grezzo + If Math.Abs(EstCalc.GetRawHeight() + dAddTable) > EPS_SMALL Then + ' Coefficiente di scalatura + Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z) + dMMxPixel *= dFsca + ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca + ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca + ptOri.z = EstCalc.GetRawHeight() + dAddTable + End If + ' Recupero origine della tavola e porto i punti in globale + Dim ptTab As Point3d + If Not EgtGetTableRef(1, ptTab) Then Return False + ptOri.ToGlob(New Frame3d(ptTab)) + ptCen.ToGlob(New Frame3d(ptTab)) + ' Verifico coefficiente scalatura Pixel (per MapaScan, normalmente 1) + If dCoeff < EPS_SMALL Then + EgtOutLog("ReadContour : coefficiente di scalatura pixel nullo") + Return False + End If + + ' Se esiste file dxf lancio lettore standard, altrimenti quello personalizzato + Dim nCrvId As Integer = GDB_ID.NULL + Dim sCntPath As String = Path.ChangeExtension(sPath, ".dxf") + If My.Computer.FileSystem.FileExists(sCntPath) Then + nCrvId = LoadStandardContour(sCntPath, ptOri, dMMxPixel, nPixelY, dCoeff) + Else + nCrvId = LoadCustomContour(sPath, ptOri, dMMxPixel, nPixelY, dCoeff) + End If + ' Eseguo le semplificazioni + Dim nApprType As Integer = APP_TYPE.LEFT_LINES + Dim dTol As Double = GetMainPrivateProfileDouble(S_CAMERA, K_CAM_TOLERANCE, 5) + EgtApproxCurve(nCrvId, nApprType, dTol) + Dim ptNew As Point3d + EgtMidPoint(nCrvId, ptNew) + EgtChangeClosedCurveStartPoint(nCrvId, ptNew) + EgtApproxCurve(nCrvId, nApprType, dTol) + Return True + End Function + + Private Function LoadStandardContour(sPath As String, ptOri As Point3d, dMMxPixel As Double, nPixelY As Integer, dCoeff As Double) As Integer + ' Carico Dxf del contorno + If Not EgtImportDxf(sPath, 1) Then Return GDB_ID.NULL + Dim nPartId As Integer = EgtGetLastPart() + Dim nLayerId As Integer = EgtGetFirstLayer(nPartId) + EgtSetName(nPartId, NAME_RAW_PHOTO_OUTLINE) + EgtSetLevel(nPartId, GDB_LV.SYSTEM) + If nPartId = GDB_ID.NULL Or nLayerId = GDB_ID.NULL Then Return GDB_ID.NULL + ' Ribalto rispetto a YZ locale (i contorni da CW diventano CCW) + EgtMirror(nLayerId, New Point3d(0, nPixelY * dCoeff / 2, 0), Vector3d.Y_AX(), GDB_RT.GLOB) + ' Eseguo scalatura + Dim dScaCoeff As Double = dMMxPixel / dCoeff + EgtScale(nLayerId, New Frame3d(), dScaCoeff, dScaCoeff, dScaCoeff, GDB_RT.GLOB) + ' Eseguo spostamento + EgtMove(nLayerId, (ptOri - Point3d.ORIG()), GDB_RT.GLOB) + ' Eseguo concatenamento + EgtSelectGroupObjs(nLayerId) + EgtCreateCurveCompoByReorder(nLayerId, 1, {GDB_ID.SEL}, New Point3d(), True) + ' Conservo la curva chiusa di area massima + Dim dAreaMax As Double = 0 + Dim nCrvId As Integer = GDB_ID.NULL + Dim nCurrCrvId As Integer = EgtGetFirstInGroup(nLayerId) + While nCurrCrvId <> GDB_ID.NULL + Dim dArea As Double = 0 + If Not EgtCurveAreaXY(nCurrCrvId, dArea) OrElse dArea <= dAreaMax Then + Dim nToEraseId = nCurrCrvId + nCurrCrvId = EgtGetNext(nCurrCrvId) + EgtErase(nToEraseId) + Else + dAreaMax = dArea + EgtErase(nCrvId) + nCrvId = nCurrCrvId + nCurrCrvId = EgtGetNext(nCurrCrvId) + End If + End While + EgtSetColor(nCrvId, New Color3d(0, 255, 0)) + Return nCrvId + End Function + + Private Function LoadCustomContour(sPath As String, ptOri As Point3d, dMMxPixel As Double, nPixelY As Integer, dCoeff As Double) As Integer + ' Definizione variabili + EgtLuaCreateGlobTable("RCT") + EgtLuaSetGlobStringVar("RCT.FILE", sPath) + ' Esecuzione + Dim nErr As Integer = 999 + If EgtLuaExecFile(OmagOFFICEMap.refMainWindowVM.MainWindowM.sImgAutoDir & "\ReadContour.lua") AndAlso + EgtLuaCallFunction("RCT.ReadContour") Then + ' Verifica stato di errore + EgtLuaGetGlobIntVar("RCT.ERR", nErr) + End If + If nErr <> 0 Then + EgtOutLog("Error in ReadContour : " & nErr.ToString()) + Return GDB_ID.NULL + End If + ' Leggo i risultati + Dim nPartId As Integer = GDB_ID.NULL + EgtLuaGetGlobIntVar("RCT.PARTID", nPartId) + If nPartId = GDB_ID.NULL Then Return GDB_ID.NULL + EgtSetName(nPartId, NAME_RAW_PHOTO_OUTLINE) + EgtSetLevel(nPartId, GDB_LV.SYSTEM) + Dim nCrvId As Integer = GDB_ID.NULL + EgtLuaGetGlobIntVar("RCT.CRVID", nCrvId) + EgtLuaResetGlobVar("RCT") + If nCrvId = GDB_ID.NULL Then Return GDB_ID.NULL + EgtSetColor(nCrvId, New Color3d(0, 255, 0)) + ' Ribalto rispetto a YZ locale (i contorni da CW diventano CCW) + EgtMirror(nCrvId, New Point3d(0, nPixelY * dCoeff / 2, 0), Vector3d.Y_AX(), GDB_RT.GLOB) + ' Eseguo scalatura + Dim dScaCoeff As Double = dMMxPixel / dCoeff + EgtScale(nCrvId, New Frame3d(), dScaCoeff, dScaCoeff, dScaCoeff, GDB_RT.GLOB) + ' Eseguo spostamento + EgtMove(nCrvId, (ptOri - Point3d.ORIG()), GDB_RT.GLOB) + ' Deve essere CCW + Dim dArea As Double = 0 + If EgtCurveAreaXY(nCrvId, dArea) AndAlso dArea < 0 Then + EgtInvertCurve(nCrvId) + End If + Return nCrvId + End Function + + Private Function ReadAuxData(sPath As String, + ByRef nSlabId As Integer, ByRef sBlockCode As String, ByRef sSlabCode As String, ByRef sSlabName As String, ByRef sMat As String, + ByRef dThick As Double, ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean + ' Se esiste file txt lancio lettore standard, altrimenti quello personalizzato + Dim sAuxPath As String = Path.ChangeExtension(sPath, ".txt") + If My.Computer.FileSystem.FileExists(sAuxPath) Then + Return ReadStandardAuxData(sAuxPath, nSlabId, sBlockCode, sSlabCode, sSlabName, sMat, dThick, ptOri, ptCen, dMMxPixel, dCoeff) + Else + Return ReadCustomAuxData(sPath, nSlabId, sBlockCode, sSlabCode, sSlabName, sMat, dThick, ptOri, ptCen, dMMxPixel, dCoeff) + End If + End Function + + Private Function ReadStandardAuxData(sAuxPath As String, + ByRef nSlabId As Integer, ByRef sBlockCode As String, ByRef sSlabCode As String, ByRef sSlabName As String, ByRef sMat As String, + ByRef dThick As Double, ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean + nSlabId = 0 + sBlockCode = "" + sSlabCode = "" + sSlabName = "" + sMat = "" + dThick = 0 + dCoeff = 1 + Try + Dim sLine As String = String.Empty + Dim sr As StreamReader = New StreamReader(sAuxPath) + Do While sr.Peek() > -1 + sLine = sr.ReadLine() + sLine = sLine.Replace(" ", "") + If sLine.StartsWith("X=") Then + StringToDouble(sLine.Substring(2), ptOri.x) + ElseIf sLine.StartsWith("Y=") Then + StringToDouble(sLine.Substring(2), ptOri.y) + ElseIf sLine.StartsWith("Z_Lastra=") Then + StringToDouble(sLine.Substring(9), ptOri.z) + ElseIf sLine.StartsWith("X_ScaleCenter=") Then + StringToDouble(sLine.Substring(14), ptCen.x) + ElseIf sLine.StartsWith("Y_ScaleCenter=") Then + StringToDouble(sLine.Substring(14), ptCen.y) + ElseIf sLine.StartsWith("Z_ScaleCenter=") Then + StringToDouble(sLine.Substring(14), ptCen.z) + ElseIf sLine.StartsWith("Pixelxmm=") Then + Dim dTmp As Double + StringToDouble(sLine.Substring(9), dTmp) + If dTmp > EPS_SMALL Then + dMMxPixel = 1 / dTmp + End If + End If + Loop + sr.Close() + Return True + Catch ex As Exception + EgtOutLog("LoadPhoto Error on auxfile : " & sAuxPath) + Return False + End Try + End Function + + Private Function ReadCustomAuxData(sPath As String, + ByRef nSlabId As Integer, ByRef sBlockCode As String, ByRef sSlabCode As String, ByRef sSlabName As String, ByRef sMat As String, + ByRef dThick As Double, ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean + ' Definizione variabili + EgtLuaCreateGlobTable("RDT") + EgtLuaSetGlobStringVar("RDT.FILE", sPath) + ' Esecuzione + Dim nErr As Integer = 999 + If EgtLuaExecFile(OmagOFFICEMap.refMainWindowVM.MainWindowM.sImgAutoDir & "\ReadData.lua") AndAlso + EgtLuaCallFunction("RDT.ReadData") Then + ' Verifica stato di errore + EgtLuaGetGlobIntVar("RDT.ERR", nErr) + End If + If nErr <> 0 Then + EgtOutLog("Error in ReadData : " & nErr.ToString()) + Return False + End If + ' Leggo i risultati + If Not EgtLuaGetGlobIntVar("RDT.SLABID", nSlabId) Then nSlabId = 0 + If Not EgtLuaGetGlobStringVar("RDT.SLABNAME", sSlabName) Then sSlabName = String.Empty + If Not EgtLuaGetGlobStringVar("RDT.BLOCKCODE", sBlockCode) Then sBlockCode = String.Empty + If Not EgtLuaGetGlobStringVar("RDT.SLABCODE", sSlabCode) Then sSlabCode = String.Empty + If Not EgtLuaGetGlobStringVar("RDT.MATERIAL", sMat) Then sMat = String.Empty + if Not EgtLuaGetGlobNumVar("RDT.TH", dThick) Then dThick = 0 + EgtLuaGetGlobPointVar("RDT.ORI", ptOri) + EgtLuaGetGlobPointVar("RDT.CEN", ptCen) + EgtLuaGetGlobNumVar("RDT.COEFF", dCoeff) + EgtLuaGetGlobNumVar("RDT.MMXPIXEL", dMMxPixel) + EgtLuaResetGlobVar("RDT") + Return True + End Function + + Public Function GetPhotoName() As String + ' Recupero il nome del gruppo di lavoro corrente + Dim sMGrp As String = String.Empty + If Not EgtGetMachGroupName(EgtGetCurrMachGroup(), sMGrp) Then Return "" + ' Creo il nome della foto + Return PHOTO_NAME & sMGrp + End Function + + Public Function GetPhoto() As Integer + ' Recupero Id del gruppo delle foto + Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP) + ' Recupero Id della foto + Return EgtGetFirstNameInGroup(nPhGrpId, GetPhotoName()) + End Function + + Public Function GetPhotoTexturePath() As String + ' Recupero la foto + Dim nId As Integer = GetPhoto() + If nId = GDB_ID.NULL Then Return "" + ' Recupero la path della texture + Dim sPath As String = String.Empty + If EgtGetPhotoPath(nId, sPath) Then + Return sPath + Else + Return "" + End If + End Function + + Public Function GetPhotoTextureRef(ByRef refTxr As Frame3d) As Boolean + ' Recupero la foto + Dim nId As Integer = GetPhoto() + If nId = GDB_ID.NULL Then Return False + ' Recupero il riferimento in globale + Return EgtGetTextureFrame(nId, GDB_ID.ROOT, refTxr) + End Function + + Public Function ShowPhoto(ByVal bShow As Boolean, Optional bDisableModified As Boolean = True) As Boolean + ' Recupero la foto + Dim nId As Integer = GetPhoto() + If nId = GDB_ID.NULL Then Return False + ' Se richiesto, disabilito impostazione modificato + Dim bOldEnMod As Boolean = False + If bDisableModified Then + bOldEnMod = EgtGetEnableModified() + If bOldEnMod Then EgtDisableModified() + End If + ' Ne cambio lo stato + Dim bOk As Boolean = EgtSetStatus(nId, If(bShow, GDB_ST.ON_, GDB_ST.OFF)) + ' Se necessario, ripristino precedente impostazione modificato + If bOldEnMod Then EgtEnableModified() + Return bOk + End Function + + Public Function GetPhotoOffsetRot(ByRef dOffsetX As Double, ByRef dOffsetY As Double, ByRef dRot As Double) As Boolean + ' Verifico esistenza oggetto foto + Dim nPhotoId As Integer = GetPhoto() + If nPhotoId = GDB_ID.NULL Then Return False + ' Recupero valori + If Not EgtGetInfo(nPhotoId, "OffsX", dOffsetX) Then dOffsetX = 0 + If Not EgtGetInfo(nPhotoId, "OffsY", dOffsetY) Then dOffsetY = 0 + If Not EgtGetInfo(nPhotoId, "Rot", dRot) Then dRot = 0 + Return True + End Function + + Public Function UpdatePhoto() As Boolean + ' Verifico esistenza oggetto foto + Dim nPhotoId As Integer = GetPhoto() + If nPhotoId = GDB_ID.NULL Then Return False + ' Verifico esistenza texture della foto + Dim sPath As String = String.Empty + If Not EgtGetPhotoPath(nPhotoId, sPath) OrElse Not File.Exists(sPath) Then Return False + ' Recupero i dati aggiuntivi della foto + Dim ptOri As New Point3d(0, 0, 0) + If Not EgtGetPhotoOrigin(nPhotoId, ptOri) Then Return False + Dim ptCen As New Point3d(0, 0, 1) + If Not EgtGetPhotoCenter(nPhotoId, ptCen) Then Return False + Dim dDimX, dDimY As Double + If Not EgtGetPhotoDimensions(nPhotoId, dDimX, dDimY) Then Return False + ' Recupero origine della tavola + Dim ptTab As Point3d + If Not EgtGetTableRef(1, ptTab) Then Return False + ' Porto i punti in locale + ptOri.ToLoc(New Frame3d(ptTab)) + ptCen.ToLoc(New Frame3d(ptTab)) + ' Altezza eventuale tavola aggiuntiva + Dim dAddTable As Double = CurrentMachine.dAdditionalTable + ' Aggiusto dati per spessore grezzo (Coefficiente di scalatura) + Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z) + dDimX *= dFsca + dDimY *= dFsca + ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca + ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca + ptOri.z = EstCalc.GetRawHeight() + dAddTable + ' Porto i punti in globale + ptOri.ToGlob(New Frame3d(ptTab)) + ptCen.ToGlob(New Frame3d(ptTab)) + ' Carico gli offset + Dim dOffsetX As Double = 0 + EgtGetInfo(nPhotoId, "OffsX", dOffsetX) + Dim dOffsetY As Double = 0 + EgtGetInfo(nPhotoId, "OffsY", dOffsetY) + Dim dRot As Double = 0 + EgtGetInfo(nPhotoId, "Rot", dRot) + ' Recupero le dimensioni della tavola + Dim ptMin, ptMax As Point3d + If Not EgtGetTableArea(1, ptMin, ptMax) Then Return False + ' Elimino precedente foto + EgtErase(nPhotoId) + ' Se non esiste il gruppo per le foto, lo creo + Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP) + If nPhGrpId = GDB_ID.NULL Then + nPhGrpId = EgtCreateGroup(GDB_ID.ROOT) + If nPhGrpId = GDB_ID.NULL Then Return False + EgtSetName(nPhGrpId, PHOTO_GRP) + End If + EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM) + ' Carico la fotografia + Dim nNewPhotoId As Integer = EgtAddPhoto2(GetPhotoName(), sPath, ptOri, ptCen, dDimX, dDimY, nPhGrpId, ptMin, ptMax) + If nNewPhotoId = GDB_ID.NULL Then Return False + ' Eseguo eventuale rotazione attorno all'origine + EgtRotatePhoto(nNewPhotoId, ptOri, Vector3d.Z_AX(), dRot) + ' Salvo gli offset + EgtSetInfo(nNewPhotoId, "OffsX", dOffsetX) + EgtSetInfo(nNewPhotoId, "OffsY", dOffsetY) + EgtSetInfo(nNewPhotoId, "Rot", dRot) + Return True + End Function + + Public Function ChangeOffsetPhoto(dOffsetX As Double, dOffsetY As Double) As Boolean + ' Verifico esistenza oggetto foto + Dim nPhotoId As Integer = GetPhoto() + If nPhotoId = GDB_ID.NULL Then Return False + ' Verifico esistenza texture della foto + Dim sPath As String = String.Empty + EgtGetPhotoPath(nPhotoId, sPath) + If Not File.Exists(sPath) Then Return False + ' Recupero offset corrente + Dim dOldOffsX As Double = 0 + EgtGetInfo(nPhotoId, "OffsX", dOldOffsX) + Dim dOldOffsY As Double = 0 + EgtGetInfo(nPhotoId, "OffsY", dOldOffsY) + ' Eseguo traslazione + Dim vtMove As New Vector3d(dOffsetX - dOldOffsX, dOffsetY - dOldOffsY, 0) + EgtMovePhoto(nPhotoId, vtMove) + ' Aggiorno valori di offset + EgtSetInfo(nPhotoId, "OffsX", dOffsetX) + EgtSetInfo(nPhotoId, "OffsY", dOffsetY) + Return True + End Function + + Public Function ChangeRotationPhoto(ptAx As Point3d, dRot As Double) As Boolean + ' Verifico esistenza oggetto foto + Dim nPhotoId As Integer = GetPhoto() + If nPhotoId = GDB_ID.NULL Then Return False + ' Verifico esistenza texture della foto + Dim sPath As String = String.Empty + EgtGetPhotoPath(nPhotoId, sPath) + If Not File.Exists(sPath) Then Return False + ' Recupero rotazione corrente + Dim dOldRot As Double = 0 + EgtGetInfo(nPhotoId, "Rot", dOldRot) + ' Eseguo rotazione + EgtRotatePhoto(nPhotoId, ptAx, Vector3d.Z_AX(), dRot - dOldRot) + ' Aggiorno valore di rotazione + EgtSetInfo(nPhotoId, "Rot", dRot) + Return True + End Function + + Public Function UpdateContour() As Boolean + ' Verifico esistenza oggetto contorno + Dim nCrvId As Integer = GetContour() + If nCrvId = GDB_ID.NULL Then Return False + ' Verifico esistenza oggetto foto + Dim nPhotoId As Integer = GetPhoto() + If nPhotoId = GDB_ID.NULL Then Return False + ' Recupero centro della foto + Dim ptCen As New Point3d(0, 0, 1) + EgtGetPhotoCenter(nPhotoId, ptCen) + ' Recupero origine della tavola + Dim ptTab As Point3d + If Not EgtGetTableRef(1, ptTab) Then Return False + ' Altezza eventuale tavola aggiuntiva + Dim dAddTable As Double = CurrentMachine.dAdditionalTable + ' Recupero inizio contorno + Dim ptStart As Point3d + EgtStartPoint(nCrvId, GDB_ID.ROOT, ptStart) + ' Calcolo coefficiente di scalatura + Dim dFsca As Double = (ptCen.z - ptTab.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptStart.z) + ' Scalo opportunamente + EgtScale(nCrvId, New Frame3d(ptCen), dFsca, dFsca, 1, GDB_RT.GLOB) + ' Sposto in Z + Dim vtMove As New Vector3d(0, 0, ptTab.z + EstCalc.GetRawHeight() + dAddTable - ptStart.z) + EgtMove(nCrvId, vtMove, GDB_RT.GLOB) + Return True + End Function + + Public Function GetContour() As Integer + Dim nPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE) + Dim nLayerId As Integer = EgtGetFirstGroupInGroup(nPartId) + Dim nCrvId As Integer = EgtGetFirstInGroup(nLayerId) + Return nCrvId + End Function + + Friend Sub RemoveContour() + EgtErase(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE)) + End Sub + + Public Sub ShowContour(bShow As Boolean) + ' Disabilito impostazione modificato + Dim bOldEnMod As Boolean = EgtGetEnableModified() + If bOldEnMod Then EgtDisableModified() + ' Cambio stato di visualizzazione + EgtSetStatus(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE), If(bShow, GDB_ST.ON_, GDB_ST.OFF)) + ' Se necessario, ripristino precedente impostazione modificato + If bOldEnMod Then EgtEnableModified() + End Sub + +End Module diff --git a/EgtStoneLib/EstProject.vb b/EgtStoneLib/EstProject.vb new file mode 100644 index 0000000..00c10a9 --- /dev/null +++ b/EgtStoneLib/EstProject.vb @@ -0,0 +1,44 @@ +Imports EgtUILib + +Module EstProject + + Public Function FilterNge() As Boolean + ' Rimuovo eventuali gruppi con livello System + Dim nId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) + While nId <> GDB_ID.NULL + ' Recupero il prossimo gruppo + Dim nNextId = EgtGetNextGroup(nId) + ' Verifico il livello e se necessario cancello + Dim nLevel As Integer = GDB_LV.USER + EgtGetLevel(nId, nLevel) + If nLevel = GDB_LV.SYSTEM Then + EgtErase(nId) + End If + ' Passo al prossimo gruppo + nId = nNextId + End While + ' Processo i sottogruppi, se di livello System li rimuovo altrimenti ne cancello il nome + Dim nGrpId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) + While nGrpId <> GDB_ID.NULL + ' Ciclo sui sottogruppi + Dim nSubId As Integer = EgtGetFirstGroupInGroup(nGrpId) + While nSubId <> GDB_ID.NULL + ' Recupero il prossimo sottogruppo + Dim nNextSubId = EgtGetNextGroup(nSubId) + ' Verifico il livello, eventuale cancellazione o rimozione nome + Dim nLevel As Integer = GDB_LV.USER + EgtGetLevel(nSubId, nLevel) + If nLevel = GDB_LV.SYSTEM Then + EgtErase(nSubId) + Else + EgtRemoveName(nSubId) + End If + nSubId = nNextSubId + End While + ' Passo al prossimo gruppo + nGrpId = EgtGetNextGroup(nGrpId) + End While + Return True + End Function + +End Module diff --git a/EgtStoneLib/GeomCalc.vb b/EgtStoneLib/GeomCalc.vb new file mode 100644 index 0000000..2eeb6b5 --- /dev/null +++ b/EgtStoneLib/GeomCalc.vb @@ -0,0 +1,115 @@ +Imports EgtUILib + +Module GeomCalc + + Public Function GetRegionOutLoop(nRegId As Integer, nDestGrpId As Integer) As Integer + Dim nCount As Integer = 0 + Dim nOutId As Integer = EgtExtractSurfFrChunkLoops(nRegId, 0, nDestGrpId, nCount) + If nOutId <> GDB_ID.NULL Then + For nId As Integer = nOutId + 1 To nOutId + nCount - 1 + EgtErase(nId) + Next + End If + Return nOutId + End Function + + Public Function CreateSolidFromRegion(nRegId As Integer, vtExtr As Vector3d, nDestGrpId As Integer) As Integer + Dim nOutId As Integer = GetRegionOutLoop(nRegId, nDestGrpId) + If nOutId = GDB_ID.NULL Then Return GDB_ID.NULL + Dim nSolId As Integer = EgtCreateSurfTmByRegionExtrusion(nDestGrpId, 1, {nOutId}, vtExtr, + 100 * EPS_SMALL, GDB_RT.GLOB) + EgtErase(nOutId) + Return nSolId + End Function + + Public Function GetMaxSideId(nPartId As Integer) As Integer + Dim nId As Integer = EgtGetFirstInGroup(nPartId) + Dim sName As String = String.Empty + While nId <> GDB_ID.NULL + EgtGetName(nId, sName) + If sName = NAME_OUTLOOP Then + Exit While + End If + nId = EgtGetNext(nId) + End While + Dim nIdMax As Integer = EgtGetFirstInGroup(nId) + Dim nIdCurr As Integer = nIdMax + Dim dLen As Double + Dim dLenMax As Double + EgtCurveLength(nIdMax, dLen) + dLenMax = dLen + nIdCurr = EgtGetNext(nIdCurr) + While nIdCurr <> GDB_ID.NULL + EgtCurveLength(nIdCurr, dLen) + If dLen > dLenMax Then + nIdMax = nIdCurr + End If + nIdCurr = EgtGetNext(nIdCurr) + End While + Return nIdMax + End Function + + Friend Function UpdateSolidForDrip(nPartId As Integer) As Boolean + ' se non ci sono lavorazioni da sotto nel pezzo si esce + If EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_DRIPCUT)) = 0 AndAlso + EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_UNDERDRILL)) = 0 Then Return True + ' Recupero lo spessore del grezzo + Dim dThick As Double = EstCalc.GetRawHeight() + ' Recupero layer Regione + Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION) + ' Elimino eventuale vecchio solido + EgtErase(EgtGetFirstNameInGroup(nGrpRegId, NAME_DRIP_SOLID)) + ' Recupero la regione del pezzo + Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId) + While nRegId <> GDB_ID.NULL + If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While + nRegId = EgtGetNext(nRegId) + End While + ' Ne derivo il solido di estrusione + Dim nSolId As Integer = CreateSolidFromRegion(nRegId, -dThick * Vector3d.Z_AX(), nGrpRegId) + EgtSetName(nSolId, NAME_DRIP_SOLID) + EgtSetColor(nSolId, New Color3d(0, 255, 255, 25)) + EgtSetStatus(nSolId, GDB_ST.OFF) + Return nSolId <> GDB_ID.NULL + End Function + + Friend Function EraseSolidForDrip(nPartId As Integer) As Boolean + ' Recupero layer Regione + Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION) + ' Elimino eventuale vecchio solido + EgtErase(EgtGetFirstNameInGroup(nGrpRegId, NAME_DRIP_SOLID)) + Return True + End Function + + Friend Function GetPartArea(nPartId As Integer) As Double + Dim nRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION) + Dim nSurfId As Integer = EgtGetFirstInGroup(nRegId) + While nSurfId <> GDB_ID.NULL And EgtGetType(nSurfId) <> GDB_TY.SRF_FRGN + nSurfId = EgtGetNext(nSurfId) + End While + Dim dArea As Double = 0 + EgtSurfFrGrossArea(nSurfId, dArea) + Return dArea + End Function + + Public Function EgtGetPartCenter(nPartId As Integer, ByRef ptCenter As Point3d) As Boolean + Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION) + Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId) + While nRegId <> GDB_ID.NULL + If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While + nRegId = EgtGetNext(nRegId) + End While + Return EgtCentroid(nRegId, GDB_ID.ROOT, ptCenter) + End Function + + Public Function GetPointInTableRef(ByVal ptCenter As Point3d, ByRef ptTable As Point3d) As Point3d + ' setto il riferimento del tavolo1 (passo l'indice della tavola e il punto su cui salvare l'informazione) + If Not EgtGetTableRef(1, ptTable) Then Return Nothing + Dim ptResult As New Point3d + ptResult.x = ptCenter.x - ptTable.x + ptResult.y = ptCenter.y - ptTable.y + ptResult.z = ptCenter.z - ptTable.z + Return ptResult + End Function + +End Module diff --git a/EgtStoneLib/SplitAuto.vb b/EgtStoneLib/SplitAuto.vb new file mode 100644 index 0000000..b25b959 --- /dev/null +++ b/EgtStoneLib/SplitAuto.vb @@ -0,0 +1,810 @@ +Imports EgtUILib +Imports EgtWPFLib5 + +Public Module SplitAuto + + Private m_dLastDT As Double = 0 + + '----------------------------------------------------------------------------------------------- + Friend Class SplitMach + Public m_nId As Integer + Public m_vOthId As New List(Of Integer) + Public m_nType As Integer + Public m_dSideAng As Double + Public m_sLay As String + Public m_nNbrId As Integer + Public m_nInterf As Integer + Public m_bCanStartAll As Boolean + Public m_bCanEndAll As Boolean + Public m_bStartAll As Boolean + Public m_bEndAll As Boolean + Public m_bEnabled As Boolean + Public m_bPause As Boolean + Public m_bInvert As Boolean + Public m_bIsLine As Boolean + Public m_dPrevAng As Double + Public m_dNextAng As Double + Public m_dStartFreeLen As Double + Public m_dEndFreeLen As Double + End Class + + '----------------------------------------------------------------------------------------------- + Friend Function CalculateSplitMachList(nCurrPhase As Integer, ByRef MachSplitList As List(Of SplitMach)) As Boolean + ' Pulisco la lista delle lavorazioni + MachSplitList.Clear() + ' La riempio + Dim nOperId As Integer = EgtGetFirstOperation() + While nOperId <> GDB_ID.NULL + ' verifico sia una lavorazione valida della fase corrente + If IsValidMachining(nOperId) And EgtGetOperationPhase(nOperId) = nCurrPhase Then + ' se appartiene ad un grezzo attivo la inserisco in lista + If IsMachiningInActiveRaw(nOperId) Then + Dim Mach As New SplitMach + ' identificativo + Mach.m_nId = nOperId + ' eventuali lavorazioni inglobate + 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 Mach.m_vOthId.Add(nId) + Next + End If + ' tipo + Mach.m_nType = EgtGetOperationType(nOperId) + ' layer di origine + EgtGetInfo(nOperId, INFO_MCH_LAYER, Mach.m_sLay) + ' se taglio con lama + If Mach.m_nType = MCH_OY.SAWING Then + ' verifica interferenza + If Mach.m_sLay = NAME_OUTLOOP Then + EgtVerifyMachining(nOperId, Mach.m_nInterf) + For Each nId As Integer In Mach.m_vOthId + Dim nRes As Integer = FMI_TYPE.LI Or FMI_TYPE.RM Or FMI_TYPE.LO + EgtVerifyMachining(nId, nRes) + Mach.m_nInterf = Mach.m_nInterf Or nRes + Next + Else + Mach.m_nInterf = FMI_TYPE.NONE + End If + ' la imposto come lavorazione corrente + EgtSetCurrMachining(nOperId) + ' inversione + EgtGetMachiningParam(MCH_MP.INVERT, Mach.m_bInvert) + ' recupero l'angolo di fianco + EgtGetMachiningParam(MCH_MP.SIDEANGLE, Mach.m_dSideAng) + ' recupero allungamento iniziale e finale (negativi vicino ad angoli interni) + Dim dStartAddLen As Double = -10 + EgtGetMachiningParam(MCH_MP.STARTADDLEN, dStartAddLen) + Dim dEndAddLen As Double = -10 + EgtGetMachiningParam(MCH_MP.ENDADDLEN, dEndAddLen) + ' recupero tipo entità, ancolo con entità precedente e successiva, lunghezze libere iniziale e finale + Mach.m_bIsLine = True + Mach.m_dPrevAng = 0 + Mach.m_dNextAng = 0 + Mach.m_dStartFreeLen = FREELEN_INF + 1 + Mach.m_dEndFreeLen = FREELEN_INF + 1 + Dim nEntId, nSub As Integer + If EgtGetMachiningGeometry( 0, nEntId, nSub) Then + If EgtGetType( nEntId) = GDB_TY.CRV_ARC OrElse EgtGetType( nEntId) = GDB_TY.CRV_COMPO Then Mach.m_bIsLine = False + EgtGetInfo( nEntId, If( Not Mach.m_bInvert, INFO_PREVANG, INFO_NEXTANG), Mach.m_dPrevAng) + EgtGetInfo( nEntId, If( Not Mach.m_bInvert, INFO_NEXTANG, INFO_PREVANG), Mach.m_dNextAng) + EgtGetInfo( nEntId, If( Not Mach.m_bInvert, INFO_START_FREELEN, INFO_END_FREELEN), Mach.m_dStartFreeLen) + EgtGetInfo( nEntId, If( Not Mach.m_bInvert, INFO_END_FREELEN, INFO_START_FREELEN), Mach.m_dEndFreeLen) + End If + ' verifico se trasformabile in un taglio di separazione (almeno da un lato) + If (dStartAddLen > -EPS_SMALL Or dEndAddLen > -EPS_SMALL) And + Mach.m_sLay = NAME_OUTLOOP And Mach.m_nInterf = FMI_TYPE.NONE Then + Dim nRes As Integer = EgtVerifyCutAsSplitting(nOperId) + Mach.m_bCanStartAll = (dStartAddLen > -EPS_SMALL And (nRes And CAR_RES.LI_OK) <> 0) And + Mach.m_dStartFreeLen > FREELEN_INF And Mach.m_bIsLine + Mach.m_bCanEndAll = (dEndAddLen > -EPS_SMALL And (nRes And CAR_RES.LO_OK) <> 0) And + Mach.m_dEndFreeLen > FREELEN_INF And Mach.m_bIsLine + End If + ' se trasformabile in taglio di separazione, verifico se lo è + If Mach.m_bCanStartAll Or Mach.m_bCanEndAll Then + EgtSetCurrMachining(nOperId) + Dim nLiType As Integer + EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiType) + Dim nLoType As Integer + EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoType) + Mach.m_bStartAll = (nLiType = MCH_SAW_LI.EXT_CENT Or nLiType = MCH_SAW_LI.EXT_OUT) + Mach.m_bEndAll = (nLoType = MCH_SAW_LO.EXT_CENT Or nLoType = MCH_SAW_LO.EXT_OUT) + Else + Mach.m_bStartAll = False + Mach.m_bEndAll = False + End If + ' Waterjet + ElseIf Mach.m_nType = MCH_OY.WATERJETTING Then + Mach.m_nInterf = FMI_TYPE.NONE + ' recupero l'angolo di fianco + EgtGetMachiningParam(MCH_MP.SIDEANGLE, Mach.m_dSideAng) + Mach.m_bCanStartAll = False + Mach.m_bCanEndAll = False + Mach.m_bStartAll = False + Mach.m_bEndAll = False + ' Forature e fresature + Else + Mach.m_nInterf = FMI_TYPE.NONE + Mach.m_dSideAng = 0 + Mach.m_bCanStartAll = False + Mach.m_bCanEndAll = False + Mach.m_bStartAll = False + Mach.m_bEndAll = False + End If + ' abilitazione + Mach.m_bEnabled = Not EgtExistsInfo(nOperId, INFO_MCH_USER_OFF) + ' pausa + Mach.m_bPause = GetPause(nOperId) + ' inserisco in lista + MachSplitList.Add(Mach) + ' altrimenti la disattivo + Else + EgtSetOperationMode(nOperId, False) + End If + End If + nOperId = EgtGetNextOperation(nOperId) + End While + Return True + End Function + + '----------------------------------------------------------------------------------------------- + Friend Sub ColorMachining(MachSplit As SplitMach, Optional bReset As Boolean = False) + EgtDisableModified() + ' Assegno stato + Dim bEnabled As Boolean = MachSplit.m_bEnabled + Dim nInterf As Integer = If(bReset, FMI_TYPE.NONE, MachSplit.m_nInterf) + ' Colore della lavorazione principale + ColorSingleMachining(MachSplit.m_nId, MachSplit.m_sLay, MachSplit.m_dSideAng, bEnabled, nInterf) + ' Colore delle lavorazioni inglobate + For Each nId As Integer In MachSplit.m_vOthId + ColorSingleMachining(nId, MachSplit.m_sLay, MachSplit.m_dSideAng, bEnabled, nInterf) + Next + EgtEnableModified() + End Sub + + Private Sub ColorSingleMachining(nOperId As Integer, sLay As String, dSideAng As Double, bEnabled As Boolean, nInterf As Integer) + ' Verifico se è un taglio da sopra o da sotto + Dim bOnCut As Boolean = (sLay = NAME_ONPATH) + Dim bDrip As Boolean = (sLay = NAME_DRIPCUT Or sLay = NAME_UNDERDRILL) + ' Recupero il preview della lavorazione + Dim nPvId As Integer = GDB_ID.NULL + EgtGetInfo(EgtGetFirstNameInGroup(nOperId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId) + ' Cambio il colore + Dim nGrpId As Integer = EgtGetFirstGroupInGroup(nPvId) + While nGrpId <> GDB_ID.NULL + Dim vCutId As New List(Of Integer) + Dim nId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_CUT) + While nId <> GDB_ID.NULL + vCutId.Add(nId) + nId = EgtGetNextName(nId, NAME_PV_CUT) + End While + Dim nPrcId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_PRECUT) + Dim nPocId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_POSTCUT) + Dim nDwnCutId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_CUT) + Dim nDwnPrcId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_PRECUT) + Dim nDwnPocId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_POSTCUT) + If Not bEnabled Then + For Each nId In vCutId + EgtSetColor(nId, COL_MCH_DISABLED) + Next + EgtSetColor(nDwnCutId, COL_MCH_DISABLED) + Dim bFreeStart As Boolean = (nInterf And FMI_TYPE.LI) <> FMI_TYPE.LI + EgtSetColor(nPrcId, If(bFreeStart, COL_MCH_DISABLED, COL_MCH_DIS_INTERF)) + EgtSetColor(nDwnPrcId, If(bFreeStart, COL_MCH_DISABLED, COL_MCH_DIS_INTERF)) + Dim bFreeEnd As Boolean = (nInterf And FMI_TYPE.LO) <> FMI_TYPE.LO + EgtSetColor(nPocId, If(bFreeEnd, COL_MCH_DISABLED, COL_MCH_DIS_INTERF)) + EgtSetColor(nDwnPocId, If(bFreeEnd, COL_MCH_DISABLED, COL_MCH_DIS_INTERF)) + Else + Dim colCut As Color3d + If bOnCut Then + colCut = COL_MCH_ONCUT() + ElseIf bDrip Then + colCut = COL_MCH_DRIPCUT() + ElseIf Math.Abs(dSideAng) > EPS_ANG_SMALL Then + colCut = COL_MCH_CUT_ANG() + Else + colCut = COL_MCH_CUT() + End If + For Each nId In vCutId + EgtSetColor(nId, colCut) + Next + EgtSetColor(nDwnCutId, colCut) + Dim colStart As Color3d = COL_MCH_INTERF() + If (nInterf And FMI_TYPE.LI) <> FMI_TYPE.LI Then + If bOnCut Then + colStart = COL_MCH_ONFREE() + ElseIf bDrip Then + colStart = COL_MCH_DRIPFREE() + Else + colStart = COL_MCH_FREE() + End If + End If + EgtSetColor(nPrcId, colStart) + EgtSetColor(nDwnPrcId, colStart) + Dim colEnd As Color3d = COL_MCH_INTERF() + If (nInterf And FMI_TYPE.LO) <> FMI_TYPE.LO Then + If bOnCut Then + colEnd = COL_MCH_ONFREE() + ElseIf bDrip Then + colEnd = COL_MCH_DRIPFREE() + Else + colEnd = COL_MCH_FREE() + End If + End If + EgtSetColor(nPocId, colEnd) + EgtSetColor(nDwnPocId, colEnd) + End If + nGrpId = EgtGetNextGroup(nGrpId) + End While + End Sub + + '----------------------------------------------------------------------------------------------- + Friend Sub ShowOnePhaseMachiningPreview(nPhase As Integer) + Dim bOldEnMod As Boolean = EgtGetEnableModified() + EgtDisableModified() + Dim nOpeId = EgtGetFirstOperation() + While nOpeId <> GDB_ID.NULL + If EgtGetOperationType(nOpeId) <> MCH_OY.DISP And + (EgtGetOperationMode(nOpeId) OrElse EgtExistsInfo(nOpeId, INFO_MCH_USER_OFF) OrElse EgtExistsInfo(nOpeId, INFO_MCH_DUPLED)) Then + Dim nStatus As Integer = If(EgtGetOperationPhase(nOpeId) = nPhase, GDB_ST.ON_, GDB_ST.OFF) + ' Lavorazione principale + Dim nPvId As Integer = GDB_ID.NULL + EgtGetInfo(EgtGetFirstNameInGroup(nOpeId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId) + EgtSetStatus(nPvId, nStatus) + ' Eventuali lavorazioni inglobate + Dim sInfo As String = String.Empty + If EgtGetInfo(nOpeId, INFO_MCH_OTHMID, sInfo) Then + Dim sItems() As String = sInfo.Split(",".ToCharArray) + For Each sId In sItems + Dim nId As Integer = GDB_ID.NULL + StringToInt(sId, nId) + Dim nPvId2 As Integer = GDB_ID.NULL + EgtGetInfo(EgtGetFirstNameInGroup(nId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId2) + EgtSetStatus(nPvId2, nStatus) + Next + End If + End If + nOpeId = EgtGetNextOperation(nOpeId) + End While + If bOldEnMod Then EgtEnableModified() + End Sub + + Friend Sub ShowAllPhasesMachiningPreview() + Dim bOldEnMod As Boolean = EgtGetEnableModified() + EgtDisableModified() + Dim nOpeId = EgtGetFirstOperation() + While nOpeId <> GDB_ID.NULL + If EgtGetOperationType(nOpeId) <> MCH_OY.DISP And + (EgtGetOperationMode(nOpeId) OrElse EgtExistsInfo(nOpeId, INFO_MCH_USER_OFF) OrElse EgtExistsInfo(nOpeId, INFO_MCH_DUPLED)) Then + Dim nStatus As Integer = GDB_ST.ON_ + ' Lavorazione principale + Dim nPvId As Integer = GDB_ID.NULL + EgtGetInfo(EgtGetFirstNameInGroup(nOpeId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId) + EgtSetStatus(nPvId, nStatus) + ' Eventuali lavorazioni inglobate + Dim sInfo As String = String.Empty + If EgtGetInfo(nOpeId, INFO_MCH_OTHMID, sInfo) Then + Dim sItems() As String = sInfo.Split(",".ToCharArray) + For Each sId In sItems + Dim nId As Integer = GDB_ID.NULL + StringToInt(sId, nId) + Dim nPvId2 As Integer = GDB_ID.NULL + EgtGetInfo(EgtGetFirstNameInGroup(nId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId2) + EgtSetStatus(nPvId2, nStatus) + Next + End If + End If + nOpeId = EgtGetNextOperation(nOpeId) + End While + If bOldEnMod Then EgtEnableModified() + End Sub + + '----------------------------------------------------------------------------------------------- + Friend Function SplitRawParts(nPrevPhase As Integer, vCuts() As Integer, + ByRef vNewRaws As List(Of Integer)) As Boolean + ' Aggiorno preview di questi tagli lasciandoli nella lavorazione + For Each nCut As Integer In vCuts + UpdateMachiningPreview(nCut, False) + Next + ' Creo nuova fase + Dim nNewPhase As Integer = EgtAddPhase() + ' Origine della tavola + Dim ptOri As Point3d + EgtGetTableRef(1, ptOri) + Dim vtOri As New Vector3d(ptOri.x, ptOri.y, ptOri.z) + ' Eseguo eventuali spezzature dei grezzi e vi sposto i pezzi (i grezzi devono essere sempre copiati per Registrazione con rotazione) + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + ' se il grezzo è presente nella fase precedente + If EgtVerifyRawPartPhase(nRawId, nPrevPhase) Then + ' Calcolo nuovi grezzi + Dim nRaw1Id = EgtSplitFlatRawPartWithMachinings(nRawId, vCuts) + ' Fisso posizione dei nuovi grezzi + Dim nNewRawId = nRaw1Id + While nNewRawId <> GDB_ID.NULL + Dim ptMin, ptMax As Point3d + EgtGetRawPartBBox(nNewRawId, ptMin, ptMax) + EgtMoveToCornerRawPart(nNewRawId, ptMin - vtOri, MCH_CR.BL) + nNewRawId = EgtGetNextRawPart(nNewRawId) + End While + ' Se almeno 2 grezzi da uno vecchio, li considero nuovi + If EgtGetNextRawPart(nRaw1Id) <> GDB_ID.NULL Then + nNewRawId = nRaw1Id + While nNewRawId <> GDB_ID.NULL + vNewRaws.Add(nNewRawId) + nNewRawId = EgtGetNextRawPart(nNewRawId) + End While + End If + ' Assegno ai nuovi grezzi eventuale texture del grezzo originale + Dim nSolidId = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID) + Dim nameTxr As String = String.Empty + If EgtGetTextureName(nSolidId, nameTxr) Then + Dim refTxr As New Frame3d + EgtGetTextureFrame(nSolidId, GDB_ID.ROOT, refTxr) + nNewRawId = nRaw1Id + While nNewRawId <> GDB_ID.NULL + ' Carico la texture sul nuovo grezzo + Dim nNewSolidId = EgtGetFirstNameInGroup(nNewRawId, NAME_RAW_SOLID) + EgtSetTextureName(nNewSolidId, nameTxr) + ' Sistemo il riferimento della texture + EgtSetTextureFrame(nNewSolidId, refTxr, GDB_RT.GLOB) + ' Passo al grezzo successivo + nNewRawId = EgtGetNextRawPart(nNewRawId) + End While + End If + End If + ' passo al successivo grezzo + nRawId = EgtGetNextRawPart(nRawId) + End While + ' Cancello preview dei tagli allungati dalla lavorazione + For Each nCut As Integer In vCuts + RemoveMachiningPreview(nCut) + Next + ' Sposto tutte le lavorazioni disabilitate e le eventuali inglobate nella nuova fase + Dim nId = EgtGetFirstOperation() + While nId <> GDB_ID.NULL + Dim nNextId = EgtGetNextOperation(nId) + If IsValidMachining(nId) And EgtGetOperationPhase(nId) = nNewPhase - 1 And EgtExistsInfo(nId, INFO_MCH_USER_OFF) Then + ' sposto la lavorazione + EgtChangeOperationPhase(nId, nNewPhase) + ' sposto le inglobate + Dim sInfo As String = String.Empty + If EgtGetInfo(nId, INFO_MCH_OTHMID, sInfo) Then + Dim sItems() As String = sInfo.Split(",".ToCharArray) + For Each sId2 In sItems + Dim nId2 As Integer = 0 + StringToInt(sId2, nId2) + If nId2 > 0 Then EgtChangeOperationPhase(nId2, nNewPhase) + Next + End If + End If + nId = nNextId + End While + Return True + End Function + + '----------------------------------------------------------------------------------------------- + Friend Function CalculateSplitAuto() As Boolean + ' Fase iniziale + EgtSetCurrPhase(1) + ' Cancello tutte le lavorazioni + EraseMachinings(GDB_ID.NULL) + ' Reinserisco tutte le lavorazioni + Dim nWarn As Integer = 0 + AddMachinings(GDB_ID.NULL, nWarn) + If nWarn = 1 Then OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SPLITPAGEUC + 11), MSG_TYPE.WARNING) ' Lama troppo grande per utilizzo ventosa + ' Carico ventose + LoadVacuumCups() + ' Lancio calcolo separazione + Dim bFinished As Boolean = False + While CalculateOnePhaseSplitAuto(bFinished) + If bFinished Then + Exit While + End If + End While + ' Se non finito con successo, verifico se necessario limitare lavorazioni + If Not bFinished Then + If Not TestMachiningCurrPhaseForStrict() Then + OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90321), MSG_TYPE.WARNING) 'Ridotte alcune lavorazioni per evitare interferenze + End If + End If + EgtSetCurrPhase(1) + ' Scarico ventose + RemoveVacuumCups() + Return bFinished + End Function + + '----------------------------------------------------------------------------------------------- + Friend Function CalculateOnePhaseSplitAuto(ByRef bFinished As Boolean) As Boolean + ' Faccio ordine automatico delle lavorazioni + If Not SortAllMachinings() Then Return False + EstCalc.SetOrderMachiningFlag() + ' Recupero l'indice della fase corrente + Dim nCurrPhase As Integer = EgtGetCurrPhase() + ' Preparo la lista delle lavorazioni + Dim MachSplitList As New List(Of SplitMach) + If Not CalculateSplitMachList(nCurrPhase, MachSplitList) Then Return False + ' Se non ci sono interferenze + If Not FindInterferences(MachSplitList) Then + ' Abilito tutte le lavorazioni della lista + EnableAllMachinings(MachSplitList) + ' Dichiaro conclusione ed esco + bFinished = True + Return True + End If + ' Disabilito tutte le lavorazioni della lista + DisableAllMachinings(MachSplitList) + ' Cerco il miglior taglio di separazione + Dim nCutInd As Integer = FindBestSeparationCut(MachSplitList) + If nCutInd < 0 Then Return False + ' Eseguo il taglio + If Not MakeSeparatingCut(MachSplitList(nCutInd).m_nId) Then Return False + MachSplitList(nCutInd).m_bEnabled = True + MachSplitList(nCutInd).m_bStartAll = True + MachSplitList(nCutInd).m_bEndAll = True + ColorMachining(MachSplitList(nCutInd)) + ' Spezzo i grezzi creando una nuova fase di lavoro + Dim vCuts() As Integer = {MachSplitList(nCutInd).m_nId} + Dim vNewRaws As New List(Of Integer) + If SplitRawParts(nCurrPhase, vCuts, vNewRaws) Then + ' Eseguo gli spostamenti dei grezzi + If MoveRawParts(MachSplitList(nCutInd).m_nId, vNewRaws) Then + While vNewRaws.Count() >= 4 + vNewRaws.RemoveAt(0) + vNewRaws.RemoveAt(0) + MoveRawParts(MachSplitList(nCutInd).m_nId, vNewRaws) + End While + bFinished = False + Return True + End If + End If + ' Ci sono stati errori dopo aver creato la nuova fase, ripristino la vecchia + RemoveLastPhase() + bFinished = False + Return False + End Function + + '----------------------------------------------------------------------------------------------- + '----------------------------------------------------------------------------------------------- + Private Function FindInterferences(ByRef MachSplitList As List(Of SplitMach)) As Boolean + Dim bInterf As Boolean = False + For Each MachSplit As SplitMach In MachSplitList + If MachSplit.m_nInterf <> FMI_TYPE.NONE Then + bInterf = True + Exit For + End If + Next + Return bInterf + End Function + + Private Function EnableAllMachinings(ByRef MachSplitList As List(Of SplitMach)) As Boolean + For nI As Integer = 0 To MachSplitList.Count() - 1 + If Not MachSplitList(nI).m_bEnabled Then + MachSplitList(nI).m_bEnabled = True + EgtSetOperationMode(MachSplitList(nI).m_nId, True) + EgtRemoveInfo(MachSplitList(nI).m_nId, INFO_MCH_USER_OFF) + ColorMachining(MachSplitList(nI)) + End If + Next + Return True + End Function + + Private Function DisableAllMachinings(ByRef MachSplitList As List(Of SplitMach)) As Boolean + For nI As Integer = 0 To MachSplitList.Count() - 1 + If MachSplitList(nI).m_bEnabled Then + MachSplitList(nI).m_bEnabled = False + EgtSetOperationMode(MachSplitList(nI).m_nId, False) + EgtSetInfo(MachSplitList(nI).m_nId, INFO_MCH_USER_OFF, True) + ColorMachining(MachSplitList(nI)) + End If + Next + Return True + End Function + + Private Function FindBestSeparationCut(MachSplitList As List(Of SplitMach)) As Integer + Dim nInd As Integer = -1 + Dim nMaxInterf As Integer = 0 + m_dLastDT = 0 + For nI As Integer = 0 To MachSplitList.Count() - 1 + Dim MachSplit As SplitMach = MachSplitList(nI) + ' Se non allungabile ad entrambi gli estremi, vado oltre + If Not MachSplit.m_bCanStartAll Or Not MachSplit.m_bCanEndAll Then Continue For + ' Se ci sono lavorazioni componenti, calcolo preview completo in lavorazione + If MachSplit.m_vOthId.Count() > 0 Then + UpdateMachiningPreview(MachSplit.m_nId, False) + End If + ' Contatore interferenze altri tagli con taglio corrente + Dim nCurrInterf As Integer = 0 + ' Lunghezza baffi altri tagli che interferiscono su taglio corrente + Dim dCurrInterfLen As Double = 0 + ' Determino quanti tagli con interferenza interseca + For Each MachSplit2 As SplitMach In MachSplitList + ' Se coincide con il precedente, vado oltre + If MachSplit2.m_nId = MachSplit.m_nId Then Continue For + ' Se non interferisce, vado oltre + If MachSplit2.m_nInterf = FMI_TYPE.NONE Then Continue For + ' Se ci sono lavorazioni componenti, calcolo preview completo in lavorazione + If MachSplit2.m_vOthId.Count() > 0 Then + UpdateMachiningPreview(MachSplit2.m_nId, False) + End If + ' Eseguo verifica tra le lavorazioni + Dim bInterf As Boolean = False + If GetInterferenceWithOtherCut(MachSplit.m_nId, MachSplit2.m_nId, MachSplit2.m_nInterf) Then + bInterf = True + ' Recupero lunghezza baffo secondo taglio + Dim nPvId As Integer = GDB_ID.NULL + EgtGetInfo(EgtGetFirstNameInGroup(MachSplit2.m_nId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId) + Dim dDT As Double + If EgtGetInfo(EgtGetFirstGroupInGroup(nPvId), "DT", dDT) And dDT > dCurrInterfLen Then + dCurrInterfLen = dDT + End If + End If + If bInterf Then nCurrInterf += 1 + ' Rimozione eventuale preview completo in lavorazione + RemoveMachiningPreview(MachSplit2.m_nId) + Next + ' Verifico se taglio corrente è nuovo campione + If nCurrInterf > nMaxInterf Then + nMaxInterf = nCurrInterf + nInd = nI + m_dLastDT = dCurrInterfLen + End If + ' Rimozione eventuale preview completo in lavorazione + RemoveMachiningPreview(MachSplit.m_nId) + Next + Return nInd + End Function + + Private Function GetInterferenceWithOtherCut(nId As Integer, nId2 As Integer, nInterf2 As Integer) As Boolean + ' Se il secondo non ha interferenze, esco subito + If nInterf2 = FMI_TYPE.NONE Then Return False + ' Regione di taglio ridotta del primo + Dim nPvId As Integer = EgtGetFirstNameInGroup(nId, NAME_PREVIEW) + If EgtGetGroupObjs(nPvId) = 0 Then EgtGetInfo(nPvId, INFO_PV_ONPART_ID, nPvId) + Dim nRCutId As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPvId), NAME_PV_RCUT) + ' Se il secondo ha l'attacco che interferisce + If (nInterf2 And FMI_TYPE.LI) <> 0 Then + ' Recupero regione dell'attacco + Dim nPv2Id As Integer = EgtGetFirstNameInGroup(nId2, NAME_PREVIEW) + If EgtGetGroupObjs(nPv2Id) = 0 Then EgtGetInfo(nPv2Id, INFO_PV_ONPART_ID, nPv2Id) + Dim nRLiCut2Id As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPv2Id), NAME_PV_RLICUT) + ' Verifico se questa regione interferisce con quella del taglio di riferimento + If EgtSurfFrChunkSimpleClassify(nRCutId, 0, nRLiCut2Id, 0, 20 * EPS_SMALL) <> REGC.OUT Then Return True + End If + ' Se il secondo ha l'uscita che interferisce + If (nInterf2 And FMI_TYPE.LO) <> 0 Then + ' Recupero Id della regione dell'uscita + Dim nPv2Id As Integer = EgtGetFirstNameInGroup(nId2, NAME_PREVIEW) + If EgtGetGroupObjs(nPv2Id) = 0 Then EgtGetInfo(nPv2Id, INFO_PV_ONPART_ID, nPv2Id) + Dim nRLoCut2Id As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPv2Id), NAME_PV_RLOCUT) + ' Verifico se questa regione interferisce con quella del taglio di riferimento + If EgtSurfFrChunkSimpleClassify(nRCutId, 0, nRLoCut2Id, 0, 20 * EPS_SMALL) <> REGC.OUT Then Return True + End If + Return False + End Function + + Private Function MakeSeparatingCut(nCutId As Integer) As Boolean + EgtSetCurrMachining(nCutId) + Dim nLiPrev As Integer + EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev) + Dim nLoPrev As Integer + EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoPrev) + ' allungo + If nLiPrev = MCH_SAW_LI.OUT Then + EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT) + Else + EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT) + End If + If nLoPrev = MCH_SAW_LO.OUT Then + EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_OUT) + Else + EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_CENT) + End If + UpdateMachiningPreview(nCutId, True) + EgtSetOperationMode(nCutId, True) + EgtRemoveInfo(nCutId, INFO_MCH_USER_OFF) + Return True + End Function + + Private Function MoveRawParts(nCutId As Integer, vNewRaws As List(Of Integer)) As Boolean + ' Almeno 2 nuovi grezzi (dovrebbero essere solo 2) + If vNewRaws.Count() < 2 Then Return False + ' Privilegio il grezzo più piccolo (lo porto in seconda posizione per essere mosso per primo) + If GetSmallerRaw(vNewRaws(0), vNewRaws(1)) = 1 Then + Dim nTmp As Integer = vNewRaws(0) + vNewRaws(0) = vNewRaws(1) + vNewRaws(1) = nTmp + End If + ' Centri dei primi 2 grezzi + Dim ptCen0 As Point3d + If Not EgtGetRawPartCenter(vNewRaws(0), ptCen0) Then Return False + Dim ptCen1 As Point3d + If Not EgtGetRawPartCenter(vNewRaws(1), ptCen1) Then Return False + ' Direzione del taglio + EgtSetCurrMachining(nCutId) + Dim nEntId, nSub As Integer + If Not EgtGetMachiningGeometry(0, nEntId, nSub) Then Return False + Dim vtCutDir As Vector3d + EgtStartVector(nEntId, GDB_ID.ROOT, vtCutDir) + ' Distanza minima di spostamento + Dim dExtraL As Double = 0 + EgtMdbGetGeneralParam(MCH_GP.EXTRALONCUTREG, dExtraL) + Dim dMinMove As Double = m_dLastDT + dExtraL + 1 + ' Decido cosa muovere + Dim nDispId As Integer = EgtGetPhaseDisposition(EgtGetCurrPhase()) + Dim dDeltaX = ptCen1.x - ptCen0.x + Dim dDeltaY = ptCen1.y - ptCen0.y + If Math.Abs(dDeltaX) < Math.Abs(dDeltaY) Then + Dim vtMoveY As New Vector3d(0, dMinMove / Math.Abs(vtCutDir.x), 0) + If dDeltaY < 0 Then vtMoveY = -vtMoveY + If Not ExecMove(nDispId, vNewRaws, vtMoveY, dMinMove) Then + If Math.Abs(dDeltaX) > 0.2 Then + Dim vtMoveX As New Vector3d(dMinMove / Math.Abs(vtCutDir.y), 0, 0) + If dDeltaX < 0 Then vtMoveX = -vtMoveX + If Not ExecMove(nDispId, vNewRaws, vtMoveX, dMinMove) Then + Return False + End If + Else + Return False + End If + End If + Else + Dim vtMoveX As New Vector3d(dMinMove / Math.Abs(vtCutDir.y), 0, 0) + If dDeltaX < 0 Then vtMoveX = -vtMoveX + If Not ExecMove(nDispId, vNewRaws, vtMoveX, dMinMove) Then + If Math.Abs(dDeltaY) > 0.2 Then + Dim vtMoveY As New Vector3d(0, dMinMove / Math.Abs(vtCutDir.x), 0) + If dDeltaY < 0 Then vtMoveY = -vtMoveY + If Not ExecMove(nDispId, vNewRaws, vtMoveY, dMinMove) Then + Return False + End If + Else + Return False + End If + End If + End If + Return True + End Function + + Private Function TestMachiningCurrPhaseForStrict() As Boolean + ' Recupero l'indice della fase corrente + Dim nCurrPhase As Integer = EgtGetCurrPhase() + ' Preparo la lista delle lavorazioni + Dim MachSplitList As New List(Of SplitMach) + If Not CalculateSplitMachList(nCurrPhase, MachSplitList) Then Return False + ' Affondamento ridotto + Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, CurrentMachine.sMachIniFile) + ' Restringo o rialzo lavorazioni abilitate ma con interferenza + Dim bModified As Boolean = False + For Each Mach As SplitMach In MachSplitList + If Mach.m_bEnabled And Mach.m_nInterf <> FMI_TYPE.NONE Then + If AdjustMachining(Mach.m_nId, Mach.m_nInterf, dReducedDepth) Then + bModified = True + End If + End If + Next + Return bModified + End Function + + Private Function GetSmallerRaw(nRaw1Id As Integer, nRaw2Id As Integer) As Integer + ' Area del primo grezzo + Dim nRc1Id As Integer = EgtGetFirstNameInGroup(nRaw1Id, NAME_RAW_OUTLINE) + Dim dArea1 As Double = 0 + If Not EgtCurveAreaXY(nRc1Id, dArea1) Then Return 0 + ' Area del secondo grezzo + Dim nRc2Id As Integer = EgtGetFirstNameInGroup(nRaw2Id, NAME_RAW_OUTLINE) + Dim dArea2 As Double = 0 + If Not EgtCurveAreaXY(nRc2Id, dArea2) Then Return 0 + ' Confronto le aree + If dArea1 < dArea2 Then + Return 1 + Else + Return 2 + End If + + End Function + + Private Function ExecMove(nDispId As Integer, vNewRaws As List(Of Integer), + vtMove As Vector3d, dMinMove As Double) As Boolean + Dim vtMove2 As Vector3d = -vtMove + Dim rmData As New RawMoveData + If PutVacuumCupsOnRaw(vNewRaws(1), rmData) AndAlso + SafeMoveRawPart(vNewRaws(1), vtMove, dMinMove) Then + rmData.m_vtRawMove = vtMove + SaveOneMoveInfoInDisposition(nDispId, rmData) + Return True + ElseIf PutVacuumCupsOnRaw(vNewRaws(0), rmData) AndAlso + SafeMoveRawPart(vNewRaws(0), vtMove2, dMinMove) Then + rmData.m_vtRawMove = vtMove2 + SaveOneMoveInfoInDisposition(nDispId, rmData) + Return True + Else + Return False + End If + End Function + + Private Function SafeMoveRawPart(nRawId As Integer, ByRef vtMove As Vector3d, dMindist As Double) As Boolean + ' Se esce dalla tavola, movimento già annullato ed esco con errore + If Not EgtMoveRawPart(nRawId, vtMove) Then Return False + ' Se interferisce con altri grezzi, annullo movimento ed esco con errore + If Not VerifyRawWithOtherRaws(nRawId, dMindist) Then + EgtMoveRawPart(nRawId, -vtMove) + Return False + End If + ' Provo ad aggiungere un altro movimento + If EgtMoveRawPart(nRawId, vtMove) Then + If VerifyRawWithOtherRaws(nRawId, dMindist) Then + vtMove += vtMove + Else + EgtMoveRawPart(nRawId, -vtMove) + End If + End If + ' Provo ad aggiungere un movimento dimezzato + If EgtMoveRawPart(nRawId, 0.5 * vtMove) Then + If VerifyRawWithOtherRaws(nRawId, dMindist) Then + vtMove += 0.5 * vtMove + Else + EgtMoveRawPart(nRawId, -0.5 * vtMove) + End If + End If + ' Provo ad aggiunger un movimento 1/4 + If EgtMoveRawPart(nRawId, 0.25 * vtMove) Then + If VerifyRawWithOtherRaws(nRawId, dMindist) Then + vtMove += 0.25 * vtMove + Else + EgtMoveRawPart(nRawId, -0.25 * vtMove) + End If + End If + Return True + End Function + + Private Function VerifyRawWithOtherRaws(nRawId As Integer, dMindist As Double) As Boolean + ' Contorno del grezzo in esame + Dim nRcId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_OUTLINE) + If nRcId = GDB_ID.NULL Then Return False + ' Fase corrente + Dim nCurrPhase As Integer = EgtGetCurrPhase() + ' Recupero elenco dei contorni degli altri grezzi della fase indicata + Dim OthRawList As New List(Of Integer) + Dim nOthId As Integer = EgtGetFirstRawPart() + While nOthId <> GDB_ID.NULL + If EgtVerifyRawPartPhase(nOthId, nCurrPhase) Then + If nOthId <> nRawId Then + Dim nOthRcId As Integer = EgtGetFirstNameInGroup(nOthId, NAME_RAW_OUTLINE) + If nOthRcId <> GDB_ID.NULL Then OthRawList.Add(nOthRcId) + End If + End If + nOthId = EgtGetNextRawPart(nOthId) + End While + ' Box del grezzo in esame + Dim b3Raw As New BBox3d + EgtGetBBoxGlob(nRcId, GDB_BB.STANDARD, b3Raw) + b3Raw.Expand(dMindist) + ' Creo la curva offsettata della minima distanza (considero solo la prima, ovvero la più lunga) + Dim nCount As Integer = 0 + Dim nOffsId = EgtOffsetCurveAdv(nRcId, dMindist, OFF_TYPE.FILLET, nCount) + ' Verifico + Dim bInterf As Boolean = False + For Each nId As Integer In OthRawList + Dim b3OthRaw As New BBox3d + EgtGetBBoxGlob(nId, GDB_BB.STANDARD, b3OthRaw) + ' Se i box interferiscono + If b3Raw.OverlapsXY(b3OthRaw) Then + ' Verifico i contorni esterni + If EgtClosedCurveClassify(nOffsId, nId) <> CCREGC.OUT Then + bInterf = True + Exit For + End If + End If + Next + ' Cancello curve offset + For i = 0 To nCount - 1 + EgtErase(nOffsId + i) + Next + Return (Not bInterf) + End Function + +End Module \ No newline at end of file diff --git a/EgtStoneLib/VacuumCups.vb b/EgtStoneLib/VacuumCups.vb new file mode 100644 index 0000000..a0d8412 --- /dev/null +++ b/EgtStoneLib/VacuumCups.vb @@ -0,0 +1,766 @@ +Imports EgtUILib + +Module VacuumCups + ' Tipo manipolatore con ventosa (0=assente, 1=dietro, 2=laterale) + Private m_nVacType As Integer = 0 + ' Dati del manipolatore + Private m_nTempId As Integer = GDB_ID.NULL + Private m_nVacId As Integer = GDB_ID.NULL + Private m_nRefId As Integer = GDB_ID.NULL + ' utilizzati per gestire il posizionamento delle ventose + Private m_dPreferredRot As Double = 0 + Private m_dDripRefAng As Double = 0 + + ' Nome del gruppo temporaneo per le ventose + Private Const VACTMP_GRP As String = "VacTmp" + + Friend Function GetVacuumType() As Integer + Return m_nVacType + End Function + + Friend Function GetVacuumId() As Integer + Return m_nVacId + End Function + + Friend Function LoadVacuumCups() As Boolean + ' Leggo tipo manipolatore con ventosa + m_nVacType = 0 + EgtGetInfo(EgtGetHeadId(VACUUM_HEAD), KEY_VAC_TYPE, m_nVacType) + ' Cancello eventuali vecchie ventose + RemoveVacuumCups() + ' Identificativo ventose nella macchina + Dim nLayId As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), VACUUM_HEAD_LAYOUT) + If nLayId = GDB_ID.NULL Then Return False + ' Identificativo riferimento della testa nella macchina + Dim nT1Id As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), HEAD_FIRST_EXIT) + If nT1Id = GDB_ID.NULL Then Return False + ' Creo gruppo temporaneo in cui copiarli + m_nTempId = EgtCreateGroup(GDB_ID.ROOT) + If m_nTempId = GDB_ID.NULL Then Return False + EgtSetName(m_nTempId, VACTMP_GRP) + EgtSetLevel(m_nTempId, GDB_LV.TEMP) + ' Eseguo copia in globale + m_nVacId = EgtCopyGlob(nLayId, m_nTempId) + If m_nVacId = GDB_ID.NULL Then Return False + ' Angolo di rotazione preferito + EgtGetInfo( m_nVacId, KEY_VACLAY_PREFROT, m_dPreferredRot) + ' Direzione di riferimento per tagli Drip + 'EgtGetInfo( m_nVacId, KEY_VACLAY_DRIPREFDIR, m_dDripRefAng) + ' Nascondo il gruppo ma rendo visibili le curve di contorno delle ventose + EgtSetStatus(m_nVacId, GDB_ST.OFF) + Dim nId As Integer = EgtGetFirstInGroup(m_nVacId) + While nId <> GDB_ID.NULL + Select Case EgtGetType(nId) + Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO + EgtSetStatus(nId, GDB_ST.ON_) + Case Else + EgtSetStatus(nId, GDB_ST.OFF) + End Select + nId = EgtGetNext(nId) + End While + m_nRefId = EgtCopyGlob(nT1Id, m_nVacId) + If m_nRefId = GDB_ID.NULL Then Return False + EgtSetStatus(m_nRefId, GDB_ST.ON_) + Return True + End Function + + Friend Function RemoveVacuumCups() As Boolean + ' Cancello eventuali gruppi per ventose usati appena prima + EgtErase(m_nTempId) + m_nTempId = GDB_ID.NULL + m_nVacId = GDB_ID.NULL + m_nRefId = GDB_ID.NULL + ' Cancello eventuali vecchi gruppi per ventose + Dim nId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, VACTMP_GRP) + While nId <> GDB_ID.NULL + Dim nNextId As Integer = EgtGetNextName(nId, VACTMP_GRP) + EgtErase(nId) + nId = nNextId + End While + Return True + End Function + + Friend Function ResetVacuumCups() As Boolean + ' Ripristino posizione e rotazione originali + Dim frOriRef As New Frame3d + EgtFrame(EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), HEAD_FIRST_EXIT), GDB_ID.ROOT, frOriRef) + Dim frCurrRef As New Frame3d + EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef) + EgtMove(m_nVacId, frOriRef.Orig() - frCurrRef.Orig(), GDB_RT.GLOB) + frCurrRef.ToLoc(frOriRef) + Dim dLen, dAngVertDeg, dAngOrizzDeg As Double + frCurrRef.VersX().ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg) + EgtRotate(m_nVacId, frOriRef.Orig(), frOriRef.VersZ(), -dAngOrizzDeg, GDB_RT.GLOB) + ' Ripristino visualizzazione originale + Dim nId As Integer = EgtGetFirstInGroup(m_nVacId) + While nId <> GDB_ID.NULL + Select Case EgtGetType(nId) + Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO + EgtSetStatus(nId, GDB_ST.ON_) + Case Else + EgtSetStatus(nId, GDB_ST.OFF) + End Select + nId = EgtGetNext(nId) + End While + EgtSetStatus(m_nRefId, GDB_ST.ON_) + Return True + End Function + + Friend Function PutVacuumCupsOnRaw(nRawId As Integer, ByRef rmData As RawMoveData) As Boolean + ' Ripristino posizione originale ventose + ResetVacuumCups() + ' Box e baricentro del grezzo (riportato sopra al grezzo) + Dim b3Raw As New BBox3d + EgtGetRawPartBBox(nRawId, b3Raw) + Dim ptRawCen As Point3d + EgtGetRawPartCenter(nRawId, ptRawCen) + ptRawCen.z += b3Raw.DimZ() / 2 + ' Se non esiste, creo la regione del kerf del grezzo + Dim nKerfId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_KERF) + Dim nRKerfId = EgtGetFirstNameInGroup(nRawId, NAME_KERF_REGION) + If nRKerfId = GDB_ID.NULL Then + nRKerfId = EgtCreateSurfFlatRegion(nRawId, nKerfId) + ' se non sono riuscito a crearla, allora è nulla e posso uscire + If nRKerfId = GDB_ID.NULL Then Return False + EgtSetName(nRKerfId, NAME_KERF_REGION) + EgtSetMode(nRKerfId, GDB_MD.HIDDEN) + End If + ' Box e baricentro della regione di kerf + Dim b3Kerf As New BBox3d + EgtGetBBoxGlob(nRKerfId, GDB_BB.STANDARD, b3Kerf) + Dim ptKerfCen As Point3d + EgtCentroid(nRKerfId, GDB_ID.ROOT, ptKerfCen) + ' Eseguo ricerca + If FindVacuumCupsOnRaw(nRawId, ptRawCen, b3Kerf, ptKerfCen, nKerfId, nRKerfId, rmData) Then + Return True + End If + ' In caso di fallimento, provo riducendo con offset la regione di kerf + ' (così si simula la proiezione del centro sul MAT - medial axis transform) + Dim bOkFind As Boolean = False + Dim vOffset() As Double = {-450, -350, -250, -150} + For i As Integer = 0 To vOffset.Length() - 1 + Dim nRKerfOffsId = EgtCopy(nRKerfId, nRKerfId, GDB_POS.AFTER) + If EgtSurfFrOffset(nRKerfOffsId, vOffset(i), OFF_TYPE.FILLET) AndAlso + EgtCentroid(nRKerfOffsId, GDB_ID.ROOT, ptKerfCen) Then + Dim nOutOffsId As Integer = GetRegionOutLoop(nRKerfOffsId, nRawId) + bOkFind = FindVacuumCupsOnRaw(nRawId, ptRawCen, b3Kerf, ptKerfCen, nOutOffsId, nRKerfId, rmData) + EgtErase(nOutOffsId) + End If + EgtErase(nRKerfOffsId) + If bOkFind Then Return True + Next + Return False + End Function + + Friend Function PutVacuumCupsOnPart(nPartId As Integer, + ByRef rmData As RawMoveData, ByRef b3Part As BBox3d) As Boolean + ' Ripristino posizione originale ventose + ResetVacuumCups() + ' Verifico sia veramente un pezzo + If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return False + ' Cerco la direzione del primo taglio attivo da sotto + Dim nDripLayId As Integer = EgtGetFirstNameInGroup( nPartId, NAME_DRIPCUT) + Dim nDripLineId As Integer = EgtGetFirstInGroup( nDripLayId) + While nDripLineId <> GDB_ID.NULL + Dim nMchId As Integer = EgtGetOperationId( "DripSaw" & nDripLineId.ToString()) + Dim nMode As Integer + If EgtGetMode( nMchId, nMode) AndAlso nMode = GDB_MD.STD Then Exit While + nDripLineId = EgtGetNext( nDripLineId) + End While + Dim vtDir As New Vector3d + if EgtStartVector( nDripLineId, GDB_ID.ROOT, vtDir) Then + Dim dLen, dAngV, dAngH As Double + vtDir.ToSpherical( dLen, dAngV, dAngH) + Dim dOffsAng = dAngH - m_dDripRefAng + While dOffsAng - m_dPreferredRot >= 90 + dOffsAng -= 180 + End While + While dOffsAng - m_dPreferredRot <= -90 + dOffsAng += 180 + End While + m_dPreferredRot = dOffsAng + End If + ' Recupero la regione del pezzo + Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION) + Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId) + While nRegId <> GDB_ID.NULL + If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While + nRegId = EgtGetNext(nRegId) + End While + If nRegId = GDB_ID.NULL Then Return False + ' Box e baricentro del pezzo (sempre sopra) + EgtGetBBoxGlob(nRegId, GDB_BB.STANDARD, b3Part) + Dim ptPartCen As Point3d + EgtCentroid(nRegId, GDB_ID.ROOT, ptPartCen) + ' Calcolo il contorno esterno del pezzo + Dim nOutId As Integer = GetRegionOutLoop(nRegId, nGrpRegId) + If nOutId = GDB_ID.NULL Then Return False + ' Eseguo ricerca + If FindVacuumCupsOnRaw(nPartId, ptPartCen, b3Part, ptPartCen, nOutId, nRegId, rmData) Then + EgtErase(nOutId) + Return True + Else + EgtErase(nOutId) + End If + ' In caso di fallimento, provo riducendo con offset la regione di kerf + ' (così si simula la proiezione del centro sul MAT - medial axis transform) + Dim bOkFind As Boolean = False + Dim vOffset() As Double = {-450, -350, -250, -150} + For i As Integer = 0 To vOffset.Length() - 1 + Dim nRegOffsId As Integer = EgtCopy(nRegId, nRegId, GDB_POS.AFTER) + Dim ptRegOffsCen As Point3d + If EgtSurfFrOffset(nRegOffsId, vOffset(i), OFF_TYPE.FILLET) AndAlso + EgtCentroid(nRegOffsId, GDB_ID.ROOT, ptRegOffsCen) Then + Dim nOutOffsId As Integer = GetRegionOutLoop(nRegOffsId, nGrpRegId) + bOkFind = FindVacuumCupsOnRaw(nPartId, ptRegOffsCen, b3Part, ptPartCen, nOutOffsId, nRegId, rmData) + EgtErase(nOutOffsId) + End If + EgtErase(nRegOffsId) + If bOkFind Then Return True + Next + Return False + End Function + + Friend Function MyPutVacuumCupsOnPart(nPartId As Integer, + ByRef rmData As RawMoveData, ByRef b3Part As BBox3d) As Boolean + ' Ripristino posizione originale ventose + ResetVacuumCups() + ' Verifico sia veramente un pezzo + If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return False + + ' Recupero la regione del pezzo + Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION) + Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId) + While nRegId <> GDB_ID.NULL + If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While + nRegId = EgtGetNext(nRegId) + End While + If nRegId = GDB_ID.NULL Then Return False + + Dim nCount As Integer = 0 + ' recupero il contorno del pezzo + Dim nIdCurve As Integer = GetRegionOutLoop(nRegId, nGrpRegId) + If nIdCurve = GDB_ID.NULL OrElse nCount > 1 Then Return False + ' recuper il versore + Dim frFrame As New Frame3d + ' recupero le dimensioni del minimo rettangolo + Dim dLengthX As Double = 0 + Dim dLengthY As Double = 0 + EgtCurveMinAreaRectangleXY(nIdCurve, GDB_ID.ROOT, frFrame, dLengthX, dLengthY) + rmData.m_vtRect.x = dLengthX / 2 + rmData.m_vtRect.y = dLengthY / 2 + ' recupero il centro del rettangolo (nel piano XY) + Dim ptCetMinRect As Point3d = frFrame.Orig() + rmData.m_ptCenMinRect = ptCetMinRect + ' recupero la direzione ortogaonale al versore X + Dim vtOrtoDir As Vector3d = frFrame.VersY() + Dim vtDir As Vector3d = frFrame.VersX() + ' verifico che la componente su X sia nel verso dello tappeto (vtDirX.x<0) + If vtDir.x > 0 Then + vtDir.x = vtDir.x * (-1) + End If + rmData.m_vtOrtoDirX = vtOrtoDir + Dim dMyLen, dMyAngV, dMyAngH As Double + vtDir.ToSpherical(dMyLen, dMyAngV, dMyAngH) + ' recupero l'Id del lato più lungo + Dim MaxSideId As Integer = GetMaxSideId(nPartId) + ' ruoto il segmento + EgtRotate(MaxSideId, ptCetMinRect, Vector3d.Z_AX, dMyAngH) + ' recupero la direzione del lato più lungo + EgtMidVector(MaxSideId, vtDir) + rmData.m_vtDirX = vtDir + ' fisso l'angolo di deposito del pezzo + m_dPreferredRot = dMyAngH + ' controruoto il segmento + EgtRotate(MaxSideId, ptCetMinRect, Vector3d.Z_AX, -dMyAngH) + + ' ottengo l'angolo orizzotale del vettore direzione (dAngH) + 'Dim dLen, dAngV, dAngH As Double + 'vtDir.ToSpherical(dLen, dAngV, dAngH) + ' misuro il delta tra l'angolo calcolato e quello provilegiato per il taglio da sotto (sempre nullo) + 'Dim dOffsAng = dMyAngH - m_dDripRefAng + 'While dOffsAng - m_dPreferredRot >= 90 + ' dOffsAng -= 180 + 'End While + 'While dOffsAng - m_dPreferredRot <= -90 + ' dOffsAng += 180 + 'End While + 'm_dPreferredRot = dOffsAng + + ' Box e baricentro del pezzo (sempre sopra) + EgtGetBBoxGlob(nRegId, GDB_BB.STANDARD, b3Part) + Dim ptPartCen As Point3d + EgtCentroid(nRegId, GDB_ID.ROOT, ptPartCen) + ' Calcolo il contorno esterno del pezzo + Dim nOutId As Integer = GetRegionOutLoop(nRegId, nGrpRegId) + If nOutId = GDB_ID.NULL Then Return False + ' Eseguo ricerca + If FindVacuumCupsOnRaw(nPartId, ptPartCen, b3Part, ptPartCen, nOutId, nRegId, rmData) Then + EgtErase(nOutId) + Return True + Else + EgtErase(nOutId) + End If + ' In caso di fallimento, provo riducendo con offset la regione di kerf + ' (così si simula la proiezione del centro sul MAT - medial axis transform) + Dim bOkFind As Boolean = False + Dim vOffset() As Double = {-450, -350, -250, -150} + For i As Integer = 0 To vOffset.Length() - 1 + Dim nRegOffsId As Integer = EgtCopy(nRegId, nRegId, GDB_POS.AFTER) + Dim ptRegOffsCen As Point3d + If EgtSurfFrOffset(nRegOffsId, vOffset(i), OFF_TYPE.FILLET) AndAlso + EgtCentroid(nRegOffsId, GDB_ID.ROOT, ptRegOffsCen) Then + Dim nOutOffsId As Integer = GetRegionOutLoop(nRegOffsId, nGrpRegId) + bOkFind = FindVacuumCupsOnRaw(nPartId, ptRegOffsCen, b3Part, ptPartCen, nOutOffsId, nRegId, rmData) + EgtErase(nOutOffsId) + End If + EgtErase(nRegOffsId) + If bOkFind Then Return True + Next + Return False + End Function + + Private Function FindVacuumCupsOnRaw(nRawId As Integer, ptRawCen As Point3d, + b3Kerf As BBox3d, ptKerfCen As Point3d, nOutlineId As Integer, nRKerfId As Integer, + ByRef rmData As RawMoveData) As Boolean + ' Cerco migliore configurazione di ventose per prendere il grezzo + Const MAX_SEL As Integer = 20 + For nI As Integer = 1 To MAX_SEL + ' Recupero la configurazione di ventose nI-esima + Dim sCups() As String = Nothing + Dim sCups2() As String = Nothing + If Not GetVacuumCupSelection(nI, sCups, sCups2) Then Return False + ' Determino validità soluzioni della configurazione + Dim vtMove As New Vector3d + Dim ptRotCen As New Point3d + Dim dRotAngDeg As Double = 0 + Dim vtMove2 As New Vector3d + Dim ptRotCen2 As New Point3d + Dim dRotAngDeg2 As Double = 0 + ' verifico con il primo elenco di ventose + Dim dDist = TestVacuumCupSelection(sCups, b3Kerf, ptKerfCen, nOutlineId, nRKerfId, vtMove, ptRotCen, dRotAngDeg) + Dim dDist2 = TestVacuumCupSelection(sCups2, b3Kerf, ptKerfCen, nOutlineId, nRKerfId, vtMove2, ptRotCen2, dRotAngDeg2) + If dDist > INFINITO - 1 And dDist2 > INFINITO - 1 Then Continue For + If dDist2 < dDist Then + sCups = sCups2 + vtMove = vtMove2 + ptRotCen = ptRotCen2 + dRotAngDeg = dRotAngDeg2 + End If + ' Eseguo il movimento + EgtMove(m_nVacId, vtMove, GDB_RT.GLOB) + EgtRotate(m_nVacId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB) + ' Visualizzo le ventose + For nJ As Integer = 0 To sCups.Length() - 1 + Dim nCupId = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ)) + EgtSetStatus(nCupId, GDB_ST.ON_) + Next + ' Calcolo delta posizione (rispetto all'origine delle ventose) + Dim frCurrRef As New Frame3d + EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef) + Dim vtDelta As Vector3d = frCurrRef.Orig() - ptRawCen + ' correggo le coordinate (x,y) considerando il centro del minimo rettangolo + Dim vtOffsetCenter As Vector3d = ptRawCen - rmData.m_ptCenMinRect + Dim zDelta As Double = vtDelta.z + vtDelta = vtDelta + vtOffsetCenter + ' reimposto il valore della z + vtDelta.z = zDelta + ' Assegno dati noti al movimento del grezzo + rmData.m_nId = nRawId + rmData.m_vtRawMove = Vector3d.NULL() + rmData.m_vtDelta = vtDelta + rmData.m_dAngRotDeg = dRotAngDeg + Dim sVal As String = String.Empty + For Each sCup As String In sCups + If String.IsNullOrEmpty(sVal) Then + sVal &= sCup + Else + sVal &= "," & sCup + End If + Next + rmData.m_sCups = sVal + Return True + Next + Return False + End Function + + Private Function GetVacuumCupSelection(nInd As Integer, ByRef sCups() As String, ByRef sCups2() As String) As Boolean + ' Recupero elenco ventose nella soluzione + Dim sSel As String = KEY_VACLAY_SEL & nInd.ToString() + Dim sVal As String = String.Empty + ' recupero la selezione "nInd" + If Not EgtGetInfo(m_nVacId, sSel, sVal) Then Return False + ' verifico se esiste più di una configurazione: V1,V2/V5,V6 + If sVal.IndexOf("/") >= 0 Then + Dim sSplit() As String = sVal.Split("/".ToCharArray) + If sSplit.Length() >= 2 Then + ' slavo la prima selezione: v1,V2 + sCups = sSplit(0).Split(",".ToCharArray) + ' salvo la seconda selezione: V5,V6 + sCups2 = sSplit(1).Split(",".ToCharArray) + ElseIf sSplit.Length() >= 1 Then + sCups = sSplit(0).Split(",".ToCharArray) + sCups2 = Nothing + Else + ' nessuna definizione assciata: / + sCups = Nothing + sCups2 = Nothing + End If + Else + ' definizione di una sola selezione: V7,V8 + sCups = sVal.Split(",".ToCharArray) + sCups2 = Nothing + End If + Return True + End Function + + Private Function GetVacRotAxisSteps(ByRef vAngRot As List(Of Double)) As Boolean + ' Recupero l'asse rotante della testa ventosa + Dim nRotAxId As Integer = EgtGetParent(EgtGetHeadId(VACUUM_HEAD)) + ' Verifico se contiene info con STEPS + Dim sSteps As String = "" + If Not EgtGetInfo(nRotAxId, KEY_ROTVAC_STEPS, sSteps) Then Return False + ' Leggo gli step previsti + Dim vStep() As String = sSteps.Split(",".ToCharArray) + For Each sStep As String In vStep + Dim dStep As Double = 0 + If StringToDouble(sStep, dStep) Then + vAngRot.Add(dStep) + End If + Next + Return True + End Function + + Private Function TestVacuumCupSelection(sCups() As String, b3Raw As BBox3d, ptRawCen As Point3d, nOutlineId As Integer, nRawRegId As Integer, + ByRef vtMove As Vector3d, ByRef ptRotCen As Point3d, ByRef dRotAngDeg As Double) As Double + ' Se definizione mancante, scarto soluzione + If IsNothing(sCups) Then Return INFINITO + ' Ne calcolo il box + Dim b3Vac As New BBox3d + For nJ As Integer = 0 To sCups.Length() - 1 + ' recupero l'Id della camera (V_nJ) + Dim nCupId = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ)) + Dim b3Cup As New BBox3d + ' se la costruzione del Box va a buon fine allora lo aggiungo all'inisieme (per generare il Box complessivo) + If EgtGetBBoxGlob(nCupId, GDB_BB.STANDARD, b3Cup) Then b3Vac.Add(b3Cup) + Next + ' se non ho generato un Box esco + If b3Vac.IsEmpty() Then Return INFINITO + ' Se box maggiore di quello del pezzo, scarto soluzione + If b3Vac.Radius() > b3Raw.Radius() Then Return INFINITO + ' Determino il movimento per portare il set di camere sopra al pezzo + vtMove = ptRawCen - b3Vac.Center() + b3Vac.Move(vtMove) + ' Determino la rotazione, allineando il lato lungo delle ventose con quello del grezzo + ptRotCen = b3Vac.Center() + 'Dim frMinRect As New Frame3d + 'If EgtCurveMinAreaRectangleXY(nOutlineId, GDB_ID.ROOT, frMinRect) Then + ' Dim dLen, dAngVertDeg, dAngOrizzDeg As Double + ' frMinRect.VersX().ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg) + ' dRotAngDeg = dAngOrizzDeg + ' If b3Vac.DimY() > b3Vac.DimX() + EPS_SMALL Then dRotAngDeg -= 90 + ' Dim dAngDelta As Double = If(Math.Abs(b3Vac.DimY() - b3Vac.DimX()) < 10 * EPS_SMALL, 90, 180) + ' While dRotAngDeg - m_dPreferredRot >= dAngDelta / 2 + ' dRotAngDeg -= dAngDelta + ' End While + ' While dRotAngDeg - m_dPreferredRot <= -dAngDelta / 2 + ' dRotAngDeg += dAngDelta + ' End While + 'Else + ' dRotAngDeg = 0 + ' If (b3Vac.DimX() >= b3Vac.DimY() And b3Raw.DimX() < b3Raw.DimY()) Or + ' (b3Vac.DimX() < b3Vac.DimY() And b3Raw.DimX() >= b3Raw.DimY()) Then + ' dRotAngDeg = m_dPreferredRot + ' End If + 'End If + + ' la ventosa DEVE sempre essere allineata con il lato più lungo del pezzo + dRotAngDeg = m_dPreferredRot + + ' cosrtuisco un array con gli Identificativi delle ventose + Dim nCups(sCups.Length() - 1) As Integer + For nJ As Integer = 0 To sCups.Length() - 1 + nCups(nJ) = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ)) + Next + ' Angoli di prova + Dim vAngRot As New List(Of Double) + ' Se asse rotante ventosa a step + If GetVacRotAxisSteps(vAngRot) Then + ' Ordino secondo distanza angolare crescente da direzione di allineamento (modulo 180 deg) + Dim dRotRefDeg As Double = dRotAngDeg + vAngRot.Sort(Function(P, Q) + Dim dDiffP = Math.Abs(P - dRotRefDeg) + If Math.Abs(dDiffP - 180) < 10 * EPS_ANG_SMALL Then dDiffP = 1 + Dim dDiffQ = Math.Abs(Q - dRotRefDeg) + If Math.Abs(dDiffQ - 180) < 10 * EPS_ANG_SMALL Then dDiffQ = 1 + Return CInt(dDiffP - dDiffQ) + End Function) + ' Annullo la rotazione di allineamento + dRotAngDeg = 0 + ' altrimenti in continuo + Else + ' Assegno più valori di ricerca e conservo angolo di allineamento + vAngRot.AddRange({0, +5, -5, +12.5, -12.5, +25, -25, +45, -45}) + End If + + ' Eseguo verifica delle ventose rispetto al grezzo + Dim bVacOk As Boolean = False + For i As Integer = 0 To vAngRot.Count() - 1 + If TestVacuumCups(nCups, nRawRegId, vtMove, ptRotCen, dRotAngDeg + vAngRot(i)) Then + dRotAngDeg += vAngRot(i) + bVacOk = True + Exit For + End If + Next + If Not bVacOk Then Return INFINITO + ' Recupero riferimento della testa ventose + Dim frCurrRef As New Frame3d + EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef) + Dim ptRef As Point3d = frCurrRef.Orig() + ' Applico movimento e rotazione al punto + ptRef.Move(vtMove) + ptRef.Rotate(ptRotCen, Vector3d.Z_AX(), dRotAngDeg) + ' Ne calcolo la distanza dal centro della tavola + Dim b3Tab As New BBox3d + EgtGetTableArea(1, b3Tab) + Dim dDist As Double = Point3d.DistXY(ptRef, b3Tab.Center()) + Return dDist + End Function + + Private Function TestVacuumCups(nCups() As Integer, nRawRegId As Integer, + vtMove As Vector3d, ptRotCen As Point3d, dRotAngDeg As Double) As Boolean + ' Eseguo verifica delle ventose rispetto al grezzo + Dim bVacOk As Boolean = True + For nJ As Integer = 0 To nCups.Length() - 1 + ' recupero l'id della ventosa corrente + Dim nCupId = nCups(nJ) + ' Eseguo rototraslazione delle ventose per verificare se sono contenute nel grezzo + EgtMove(nCupId, vtMove, GDB_RT.GLOB) + EgtRotate(nCupId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB) + ' Confronto le regioni + If EgtSurfFrChunkSimpleClassify(nRawRegId, 0, nCupId, 0) <> REGC.IN2 Then bVacOk = False + ' Annullo rototraslazione + EgtRotate(nCupId, ptRotCen, Vector3d.Z_AX(), -dRotAngDeg, GDB_RT.GLOB) + EgtMove(nCupId, -vtMove, GDB_RT.GLOB) + ' Se verifica fallita, esco dal ciclo + If Not bVacOk Then Exit For + Next + Return bVacOk + End Function + + Friend Function SaveOneMoveInfo(nId As Integer, rmData As RawMoveData) As Boolean + ' Assegno le informazioni + EgtSetInfo(nId, "Id", rmData.m_nId) + EgtSetInfo(nId, "Mv", rmData.m_vtRawMove) + EgtSetInfo(nId, "Rr", rmData.m_dRawAngRotDeg) + EgtSetInfo(nId, "Dt", rmData.m_vtDelta) + EgtSetInfo(nId, "Ad", rmData.m_dAngRotDeg) + EgtSetInfo(nId, "Vc", rmData.m_sCups) + EgtSetInfo(nId, "Vt", GetVacuumType()) + Return True + End Function + + Friend Function RemoveOneMoveInfo(nId As Integer) As Boolean + ' Rimuovo le informazioni + EgtRemoveInfo(nId, "Id") + EgtRemoveInfo(nId, "Mv") + EgtRemoveInfo(nId, "Rr") + EgtRemoveInfo(nId, "Dt") + EgtRemoveInfo(nId, "Ad") + EgtRemoveInfo(nId, "Vc") + EgtRemoveInfo(nId, "Vt") + Return True + End Function + + Friend Function SaveOneMoveInfoInDisposition(nDispId As Integer, rmData As RawMoveData) As Boolean + ' Se movimento e rotazione trascurabili, inutile salvare + If rmData.m_vtRawMove.IsSmall() AndAlso Math.Abs(rmData.m_dRawAngRotDeg) < EPS_ANG_SMALL Then Return True + ' Creo il gruppo + Dim nRpmId As Integer = EgtCreateGroup(nDispId) + If nRpmId = GDB_ID.NULL Then Return False + EgtSetName(nRpmId, "Rpm" & rmData.m_nId.ToString()) + ' Assegno le informazioni + SaveOneMoveInfo(nRpmId, rmData) + Return True + End Function + + Friend Function SaveMoveInfoInDisposition(nDispId As Integer, rmList As List(Of RawMoveData)) As Boolean + ' Verifico DispId + If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False + ' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati + For Each rmData As RawMoveData In rmList + If Not SaveOneMoveInfoInDisposition(nDispId, rmData) Then Return False + Next + Return True + End Function + + Friend Function GetMoveInfoInDisposition(nDispId As Integer, ByRef rmList As List(Of RawMoveData)) As Boolean + ' Verifico DispId + If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False + ' Recupero i gruppi con i dati + Dim nRpmId As Integer = EgtGetFirstNameInGroup(nDispId, "Rpm*") + While nRpmId <> GDB_ID.NULL + ' Recupero le informazioni + Dim rmData As New RawMoveData + EgtGetInfo(nRpmId, "Id", rmData.m_nId) + EgtGetInfo(nRpmId, "Mv", rmData.m_vtRawMove) + EgtGetInfo(nRpmId, "Rr", rmData.m_dRawAngRotDeg) + EgtGetInfo(nRpmId, "Dt", rmData.m_vtDelta) + EgtGetInfo(nRpmId, "Ad", rmData.m_dAngRotDeg) + EgtGetInfo(nRpmId, "Vc", rmData.m_sCups) + EgtGetInfo(nRpmId, "Vt", GetVacuumType()) + ' se non già presenti, le inserisco nella lista + If FindRawMoveData(rmData.m_nId, rmList) = -1 Then + rmList.Add(rmData) + End If + ' Cerco un altro gruppo + nRpmId = EgtGetNextName(nRpmId, "Rpm*") + End While + Return True + End Function + + Friend Function FindRawMoveData(nRawId As Integer, ByRef rmList As List(Of RawMoveData)) As Integer + ' Cerco in lista record con dati del grezzo indicato + Dim nInd As Integer = -1 + For i As Integer = 0 To rmList.Count() - 1 + If rmList(i).m_nId = nRawId Then + nInd = i + Exit For + End If + Next + Return nInd + End Function + + Private Function AddRawMoveData(nRawId As Integer, ByRef rmList As List(Of RawMoveData)) As Integer + ' Cerco in lista record con dati del grezzo indicato + Dim nInd As Integer = -1 + For i As Integer = 0 To rmList.Count() - 1 + If rmList(i).m_nId = nRawId Then + nInd = i + Exit For + End If + Next + ' Se trovato + If nInd <> -1 Then + ' Se con movimenti trascurabili e non alla fine, lo sposto alla fine + If rmList(nInd).m_vtRawMove.IsSmall() AndAlso Math.Abs(rmList(nInd).m_dRawAngRotDeg) < EPS_ANG_SMALL AndAlso nInd <> rmList.Count() - 1 Then + rmList.Add(rmList(nInd)) + rmList.RemoveAt(nInd) + nInd = rmList.Count() - 1 + End If + ' Se non trovato, lo accodo + Else + rmList.Add(New RawMoveData(nRawId)) + nInd = rmList.Count() - 1 + End If + Return nInd + End Function + + Friend Function AddRawMoveData(nRawId As Integer, vtMove As Vector3d, ByRef rmList As List(Of RawMoveData)) As Integer + ' Recupero o creo record con dati del grezzo indicato + Dim nInd As Integer = AddRawMoveData(nRawId, rmList) + If nInd = -1 Then Return -1 + ' Aggiorno i valori + rmList(nInd).m_vtRawMove += vtMove + Return nInd + End Function + + Friend Function AddRawMoveData(nRawId As Integer, dRawAngRotDeg As Double, ByRef rmList As List(Of RawMoveData)) As Integer + ' Recupero o creo record con dati del grezzo indicato + Dim nInd As Integer = AddRawMoveData(nRawId, rmList) + If nInd = -1 Then Return -1 + ' Aggiorno i valori + rmList(nInd).m_dRawAngRotDeg += dRawAngRotDeg + Return nInd + End Function + + Friend Function AddRawMoveData(rmData As RawMoveData, ByRef rmList As List(Of RawMoveData)) As Integer + ' Recupero o creo record con dati del grezzo indicato + Dim nInd As Integer = AddRawMoveData(rmData.m_nId, rmList) + If nInd = -1 Then Return -1 + ' Aggiorno i valori (tengo conto di quanto già ruotato il pezzo) + Dim vtDeltaRot As New Vector3d(rmData.m_vtDelta) + vtDeltaRot.Rotate(Vector3d.Z_AX(), -rmList(nInd).m_dRawAngRotDeg) + rmList(nInd).m_vtDelta = vtDeltaRot + rmList(nInd).m_dAngRotDeg = rmData.m_dAngRotDeg - rmList(nInd).m_dRawAngRotDeg + rmList(nInd).m_sCups = rmData.m_sCups + Return nInd + End Function + + Friend Sub RemoveRawMoveData(nRawId As Integer, ByRef rmList As List(Of RawMoveData)) + ' Cerco in lista record con dati del grezzo indicato + Dim nInd As Integer = -1 + For i As Integer = 0 To rmList.Count() - 1 + If rmList(i).m_nId = nRawId Then + nInd = i + Exit For + End If + Next + ' Se trovato, lo elimino + If nInd >= 0 Then + rmList.RemoveAt(nInd) + End If + End Sub + + Friend Function SaveRemoveByHandInDisposition(nDispId As Integer, bRemoveByHand As Boolean) As Boolean + ' Verifico DispId + If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False + ' Imposto flag + EgtSetInfo(nDispId, "Rbh", bRemoveByHand) + Return True + End Function + + Friend Function GetRemoveByHandInDisposition(nDispId As Integer) As Boolean + ' Verifico DispId + If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False + ' Leggo flag + Dim bRemoveByHand As Boolean = False + EgtGetInfo(nDispId, "Rbh", bRemoveByHand) + Return bRemoveByHand + End Function + + Friend Function SaveMovePartsOnAuxTable(nDispId As Integer, bMovePartsOnAuxTab As Boolean) As Boolean + ' Verifico DispId + If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False + ' Imposto flag + EgtSetInfo(nDispId, "Pat", bMovePartsOnAuxTab) + Return True + End Function + +End Module + +' in precedenza era di tipo friend ed interno al modulo sopra, portato fuori per poter salvare in ogni pezzo queste info +Public Class RawMoveData + + Public m_nId As Integer + Public m_vtRawMove As Vector3d + Public m_dRawAngRotDeg As Double + Public m_vtDelta As Vector3d + Public m_dAngRotDeg As Double + Public m_sCups As String + ' vettore centro-vertice on alto a sinistra MinimoRettangolo + Public m_vtRect As New Vector3d + ' versore del lato più lungo nel sistema assoluto + Public m_vtDirX As New Vector3d + Public m_vtOrtoDirX As New Vector3d + ' centro del rettangolo minimo + Public m_ptCenMinRect As New Point3d + + Sub New() + m_nId = GDB_ID.NULL + m_vtRawMove = Vector3d.NULL() + m_dRawAngRotDeg = 0 + m_vtDelta = Vector3d.NULL() + m_dAngRotDeg = 0 + m_sCups = String.Empty + End Sub + + Sub New(nId As Integer) + m_nId = nId + m_vtRawMove = Vector3d.NULL() + m_dRawAngRotDeg = 0 + m_vtDelta = Vector3d.NULL() + m_dAngRotDeg = 0 + m_sCups = String.Empty + End Sub +End Class \ No newline at end of file diff --git a/EgtStoneLib/VeinMatchingWindow.xaml b/EgtStoneLib/VeinMatchingWindow.xaml new file mode 100644 index 0000000..f724aab --- /dev/null +++ b/EgtStoneLib/VeinMatchingWindow.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + +