Imports EgtUILib Imports EgtWPFLib5 Public Class CompoWindowVM Inherits VMBase #Region "FIELDS & PROPERTIES" Enum CompoPageOpt As Integer LIST PARAM End Enum Friend Const NUM_VAR As Integer = 10 Private Const LUA_CMP_VARS As String = "CMP" Private Const LUA_CMP_DRAW As String = "CMP_Draw" Private Const INFO_VAR As String = "Var" Friend Const INFO_CMP As String = "CMP" Private Const INFO_ID As String = "ID" Friend Const LUA_CMP_INDEX As String = LUA_CMP_VARS & ".Ind" Friend Const LUA_CMP_INTERNAL As String = LUA_CMP_VARS & ".Int" Friend Const LUA_REMOVEHOLE As String = "RemoveHole" Friend Const LUA_CMP_WITHINT As String = LUA_CMP_VARS & ".WithInt" Friend Event m_CloseWindow(bDialogResult As Boolean) Friend m_SelCompoFamily As CompoItem = Nothing Friend m_SelCompo As CompoItem = Nothing Friend m_SelInternalCompo As CompoItem = Nothing Friend m_bSelAlzAndFront As Boolean = False Friend m_bSelInternalCompo As Boolean = False Private m_sCompoDir As String = String.Empty Friend m_bDrawOk As Boolean = False ' Trf Data Private m_bTrfData As Boolean = False Friend ReadOnly Property bTrfData As Boolean Get Return m_bTrfData End Get End Property ' Csv Data Private m_bCsvData As Boolean = False Friend ReadOnly Property bCsvData As Boolean Get Return m_bCsvData End Get End Property Private m_CompoPage As CompoPageOpt Public Property CompoPage As CompoPageOpt Get Return m_CompoPage End Get Set(value As CompoPageOpt) m_CompoPage = value If value = CompoPageOpt.LIST Then CompoWindowMap.refCompoListPageVM.InitCompoListPage() Else CompoWindowMap.refCompoParamPageVM.InitCompoParamPage() End If NotifyPropertyChanged("CompoPageControl") End Set End Property ' utilizzato per forzare il cambio pagina senza passare dall'inizializzazione della componente Public Sub SetCompoPage(PageOpt As CompoPageOpt) If PageOpt = CompoPageOpt.LIST Then m_CompoPage = CompoPageOpt.LIST Else m_CompoPage = CompoPageOpt.PARAM End If NotifyPropertyChanged("CompoPageControl") End Sub Private m_CompoListPageV As CompoListPageV Private m_CompoParamPageV As CompoParamPageV Public ReadOnly Property CompoPageControl As ContentControl Get If m_CompoPage = CompoPageOpt.LIST Then Return m_CompoListPageV Else Return m_CompoParamPageV End If End Get End Property Private m_CompoManagerV As CompoManagerV Public ReadOnly Property CompoManagerV As CompoManagerV Get Return m_CompoManagerV End Get End Property #Region "Messages" Public ReadOnly Property TitleMsg As String Get Return EgtMsg(MSG_DRAWPAGEUC + 5) ' Disegno Parametrico End Get End Property #End Region ' Messages #End Region ' FIELDS & PROPERTIES #Region "CONSTRUCTOR" Sub New() ' Avvio l'inizializzazione della mappa passandogli il riferimento al CompoWindowVM CompoWindowMap.BeginInit(Me) ' Creo pagina CompoList m_CompoListPageV = New CompoListPageV m_CompoListPageV.DataContext = New CompoListPageVM ' Creo pagina CompoParam m_CompoParamPageV = New CompoParamPageV m_CompoParamPageV.DataContext = New CompoParamPageVM ' creo pagina CompoManager m_CompoManagerV = New CompoManagerV m_CompoManagerV.DataContext = New CompoManagerVM ' Inizializzo e visualizzo per default la CompoListPage CompoWindowMap.refCompoListPageVM.InitCompoListPage() CompoPage = CompoPageOpt.LIST ' Recupero path cartella che contiene i componenti GetMainPrivateProfileString("Compo", "CompoDir", "", m_sCompoDir) ' Abilitazione lavorazioni da sotto da chiave CompoWindowMap.refCompoParamPageVM.Drip_IsEnabled = OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption( KEY_OPT.UNDER_CUT) And Not String.IsNullOrWhiteSpace( CurrentMachine.sCurrDripSaw) CompoWindowMap.refCompoListPageVM.Drip_IsEnabled = OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption( KEY_OPT.UNDER_CUT) And Not String.IsNullOrWhiteSpace( CurrentMachine.sCurrDripSaw) ' Abilitazione TrfData m_bTrfData = OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.TRF_IMPORT) And (GetMainPrivateProfileInt(S_COMPO, K_TRFDATA, 0) <> 0) ' Abilitazione CsvData m_bCsvData = Not m_bTrfData And (GetMainPrivateProfileInt(S_COMPO, K_CSVDATA, 0) <> 0) End Sub #End Region ' CONSTRUCTOR #Region "METHODS" Friend Function MakePreview(ByRef sMsg As String) As Boolean If Not EgtLuaExecLine(LUA_CMP_DRAW & "(true)") Then sMsg = EgtMsg(91689) ' Error in component execution m_bDrawOk = False Else EgtLuaGetGlobStringVar(LUA_CMP_VARS & ".MSG", sMsg) Dim nErr As Integer = 0 EgtLuaGetGlobIntVar(LUA_CMP_VARS & ".ERR", nErr) m_bDrawOk = (nErr = 0) End If AdjustFlatPart(EgtGetFirstPart()) Return m_bDrawOk End Function Friend Function ExecCompoFile() As Boolean Dim sPath As String = String.Empty ' Verifico se componente interno o normale e costruisco path completa del componente If IsNothing(m_SelInternalCompo) Then sPath = m_sCompoDir & "\" & m_SelCompo.LuaPath Else sPath = m_sCompoDir & "\" & m_SelInternalCompo.LuaPath End If ' Carico il file Return EgtLuaExecFile(sPath) End Function Friend Sub UpdateView() ' verifico ci sia un componente corrente If IsNothing(m_SelCompo) Then Return End If ' aggiorno le variabili dalla griglia CompoWindowMap.refCompoParamPageVM.UpdateVariables() ' ricalcolo il disegno Dim sMsg As String = String.Empty MakePreview(sMsg) CompoWindowMap.refCompoParamPageVM.SetOutputMessage(sMsg, If(m_bDrawOk, MSG_TYPE.INFO, MSG_TYPE.ERROR_)) ' aggiorno visualizzazione EgtSetView(VT.TOP, False) EgtZoom(ZM.ALL) End Sub Friend Function MakeInsert(ByVal nNbr As Integer, sName As String) As Boolean ' Passo al contesto corrente EgtSetCurrentContext(CompoWindowMap.refCompoSceneHostV.CompoScene.GetCtx()) ' Cancello layer regioni per selezione buchi Dim Pz As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) Dim SelectRegion As Integer = EgtGetFirstNameInGroup(Pz, "SelectRegion") EgtErase(SelectRegion) ' Cancello layer etichette, quotatura,ausiliario e box EgtErase(EgtGetFirstNameInGroup(Pz, "LayAux")) EgtErase(EgtGetFirstNameInGroup(Pz, "Etichette")) EgtErase(EgtGetFirstNameInGroup(Pz, "Quotature")) EgtErase(EgtGetFirstNameInGroup(Pz, "Box")) ' Cancello layer etichette dei componenti interni (buchi) Dim nHLId As Integer = EgtGetFirstNameInGroup(Pz, "HoleLabels") While nHLId <> GDB_ID.NULL EgtErase(nHLId) nHLId = EgtGetFirstNameInGroup(Pz, "HoleLabels") End While ' Attivo visualizzazione misura Dim nRegLayId As Integer = EgtGetFirstNameInGroup(Pz, NAME_REGION) Dim nId As Integer = EgtGetFirstInGroup(nRegLayId) While nId <> GDB_ID.NULL If EgtGetType(nId) = GDB_TY.EXT_TEXT Then EgtSetStatus(nId, GDB_ST.ON_) End If nId = EgtGetNext(nId) End While ' Calcolo dimensione ingombro Pezzo tramite OutLoop Dim nOutLoopLayer = EgtGetFirstNameInGroup(Pz, NAME_OUTLOOP) Dim b3Part As New BBox3d EgtGetBBoxGlob(nOutLoopLayer, GDB_BB.STANDARD, b3Part) ' Muovo la regione in Z per evitare problemi in visualizzazione EgtMove(nRegLayId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB) ' Se pezzo con dati TRF If m_bTrfData Then ' Nome da dati Trf Dim nTextId = EgtGetFirstInGroup(nRegLayId) While nTextId <> GDB_ID.NULL If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then Dim sText As String = CompoWindowMap.refCompoManagerVM.sTrfOrderCode & "-" & CompoWindowMap.refCompoManagerVM.sTrfOrderDesc Dim sText2 As String = CompoWindowMap.refCompoManagerVM.sTrfMatCode & "-" & CompoWindowMap.refCompoManagerVM.sTrfSurfCode Dim sText3 As String = LenToString(b3Part.DimX(), 0) & " x " & LenToString(b3Part.DimY(), 0) & " x " & LenToString(CompoWindowMap.refCompoManagerVM.dTrfThickness, 0) Dim dRatio As Double = Math.Max(b3Part.DimX(), b3Part.DimY()) / Math.Min(b3Part.DimX(), b3Part.DimY()) If dRatio < 5 Then sText = sText & "
" & sText2 & "
" & sText3 Else sText = sText & " " & sText2 & " " & sText3 End If EgtModifyText(nTextId, sText) Dim ptCen As Point3d EgtCenterPoint(nTextId, ptCen) Dim b3Text As New BBox3d EgtGetBBoxGlob(nTextId, GDB_BB.STANDARD, b3Text) Dim dCoeff As Double = Math.Min(b3Part.DimX() / b3Text.DimX(), b3Part.DimY() / b3Text.DimY()) / 1.25 If dCoeff < 1 Then EgtScale(nTextId, New Frame3d(ptCen), dCoeff, dCoeff, dCoeff) End If Exit While End If nTextId = EgtGetNext(nTextId) End While ' Info di pezzo da dati Trf EgtSetInfo(Pz, "OC", CompoWindowMap.refCompoManagerVM.sTrfOrderCode) EgtSetInfo(Pz, "OD", CompoWindowMap.refCompoManagerVM.sTrfOrderDesc) EgtSetInfo(Pz, "PC", CompoWindowMap.refCompoManagerVM.sTrfPartCode) EgtSetInfo(Pz, "MT", CompoWindowMap.refCompoManagerVM.sTrfMatCode) EgtSetInfo(Pz, "SRF", CompoWindowMap.refCompoManagerVM.sTrfSurfCode) EgtSetInfo(Pz, "L", DoubleToString(b3Part.DimX(), 1)) EgtSetInfo(Pz, "W", DoubleToString(b3Part.DimY(), 1)) EgtSetInfo(Pz, "T", CompoWindowMap.refCompoManagerVM.dTrfThickness) EgtSetInfo(Pz, "V1", DoubleToString(b3Part.DimX(), 1)) EgtSetInfo(Pz, "V2", DoubleToString(b3Part.DimY(), 1)) ' Se altrimenti pezzo con dati Csv ElseIf m_bCsvData Then ' Nome del pezzo EgtSetName( Pz, CompoWindowMap.refCompoManagerVM.sCsvName) ' Dati Csv EgtSetInfo( Pz, INFO_CSV_PART, CompoWindowMap.refCompoManagerVM.sCsvName) EgtSetInfo( Pz, INFO_CSV_ORD, CompoWindowMap.refCompoManagerVM.sCsvOrder) EgtSetInfo( Pz, INFO_CSV_DIST, CompoWindowMap.refCompoManagerVM.sCsvList) EgtSetInfo( Pz, INFO_CSV_MAT, CurrentMachine.CurrMat.sName) EgtSetInfo( Pz, INFO_CSV_V1, DoubleToString( b3Part.DimX(), 1)) EgtSetInfo( Pz, INFO_CSV_V2, DoubleToString( b3Part.DimY(), 1)) ' Se definito nome lo inserisco nel testo If Not String.IsNullOrWhiteSpace( CompoWindowMap.refCompoManagerVM.sCsvName) Then Dim nTextId = EgtGetFirstInGroup(nRegLayId) While nTextId <> GDB_ID.NULL If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then Dim sText As String = String.Empty EgtTextGetContent(nTextId, sText) Dim sNewText = CompoWindowMap.refCompoManagerVM.sCsvName & "
" & sText EgtModifyText(nTextId, sNewText) Exit While End If nTextId = EgtGetNext(nTextId) End While End If ' Altrimenti pezzo con dati normali Else ' Se definito nome lo inserisco nel testo If Not String.IsNullOrWhiteSpace(sName) Then Dim nTextId = EgtGetFirstInGroup(nRegLayId) While nTextId <> GDB_ID.NULL If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then Dim sText As String = String.Empty EgtTextGetContent(nTextId, sText) Dim sNewText = sName & "
" & sText EgtModifyText(nTextId, sNewText) Exit While End If nTextId = EgtGetNext(nTextId) End While End If End If ' Eventuale testo per indicare il sopra (solo nel caso di rettangolo) If CompoWindowMap.refCompoManagerVM.Top_Visibility = Visibility.Visible And CompoWindowMap.refCompoManagerVM.TopIsChecked Then AddTopToPartRegion( nRegLayId) End If ' Scrivo testi per nesting SideEntityControlVM.WriteSideAngleForNest(CompoWindowMap.refCompoSceneHostV.CompoScene.GetCtx()) ' Imposto colore testi EstCalc.SetTextColor( nRegLayId) ' Esporto il pezzo in un file temporaneo Dim sTmpFile As String = OmagOFFICEMap.refMainWindowVM.MainWindowM.sTempDir & "\FlatPartCompo.Nge" If Not EgtSaveObjToFile(1, sTmpFile, NGE.BIN) Then Return False End If ' Passo al contesto principale EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) ' Recupero flag per inserimento diretto in grezzo (altrimenti in parcheggio) Dim bDirect As Boolean = (GetMainPrivateProfileInt(S_NEST, K_DIRECT, 0) <> 0) ' Elimino eventuali precedenti pezzi vuoti EgtEraseEmptyParts() If My.Computer.FileSystem.FileExists(sTmpFile) Then ' eseguo inserimento For i As Integer = 1 To nNbr ' Inserisco il pezzo EgtInsertFile(sTmpFile) ' Ne recupero l'Id Dim nId2 As Integer = EgtGetLastPart() ' Aggiusto per lavorazioni AdjustFlatPart(nId2) ' Se dati Trf assegno nome univoco If m_bTrfData Then EgtSetInfo(nId2, "CsvPart", CompoWindowMap.refCompoManagerVM.sTrfOrderCode & "-" & nId2.ToString()) ' Inserisco in parcheggio EstCalc.StoreOnePart(nId2, True) ' Aggiungo riferimento e lo inserisco in VeinMatching VeinMatching.SetRefOnPart(nId2) VeinMatching.AddPart(nId2, True) ' Se richiesto posizionamento diretto, lo eseguo If bDirect Then If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then ' Eventuale notifica al VeinMatching VeinMatching.OnInsertPartInRaw(nId2) End If End If Next ' Cancello il file My.Computer.FileSystem.DeleteFile(sTmpFile) End If ' Aggiorno ambiente principale EgtZoom(ZM.ALL) Return True End Function Friend Function MakeMultipleInsert(ByVal nNbr As Integer, sName As String) As Boolean Dim InsertColor As Color3d = CompoColor(IniFile.m_sIniFile) ' Imposto il contesto corrente EgtSetCurrentContext(CompoWindowMap.refCompoSceneHostV.CompoScene.GetCtx()) Dim Pz As Integer = -1 Dim NxtPz As Integer = -1 ' Cancello layer regioni per selezione buchi Pz = EgtGetFirstGroupInGroup(GDB_ID.ROOT) ' identificativo univoico del gruppo di pezzi, se più di un pezzo Dim sGUICode As String = String.Empty While Pz <> -1 ' imposto il contesto corrente EgtSetCurrentContext(CompoWindowMap.refCompoSceneHostV.CompoScene.GetCtx()) ' cerco un altro pezzo nell'elenco NxtPz = EgtGetNextPart(Pz) Dim SelectRegion As Integer = EgtGetFirstNameInGroup(Pz, "SelectRegion") EgtErase(SelectRegion) ' Cancello layer etichette, quotatura,ausiliario e box EgtErase(EgtGetFirstNameInGroup(Pz, "LayAux")) EgtErase(EgtGetFirstNameInGroup(Pz, "Etichette")) EgtErase(EgtGetFirstNameInGroup(Pz, "Quotature")) EgtErase(EgtGetFirstNameInGroup(Pz, "Box")) ' Cancello layer etichette dei componenti interni (buchi) Dim nHLId As Integer = EgtGetFirstNameInGroup(Pz, "HoleLabels") While nHLId <> GDB_ID.NULL EgtErase(nHLId) nHLId = EgtGetFirstNameInGroup(Pz, "HoleLabels") End While ' Attivo visualizzazione misura Dim nRegLayId As Integer = EgtGetFirstNameInGroup(Pz, NAME_REGION) Dim nId As Integer = EgtGetFirstInGroup(nRegLayId) While nId <> GDB_ID.NULL If EgtGetType(nId) = GDB_TY.EXT_TEXT Then EgtSetStatus(nId, GDB_ST.ON_) End If nId = EgtGetNext(nId) End While ' Calcolo dimensione ingombro Pezzo tramite OutLoop Dim nOutLoopLayer = EgtGetFirstNameInGroup(Pz, NAME_OUTLOOP) Dim b3Part As New BBox3d EgtGetBBoxGlob(nOutLoopLayer, GDB_BB.STANDARD, b3Part) ' Muovo la regione in Z per evitare problemi in visualizzazione EgtMove(nRegLayId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB) ' Se pezzo con dati TRF If m_bTrfData Then ' Nome da dati Trf Dim nTextId = EgtGetFirstInGroup(nRegLayId) While nTextId <> GDB_ID.NULL If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then Dim sText As String = CompoWindowMap.refCompoManagerVM.sTrfOrderCode & "-" & CompoWindowMap.refCompoManagerVM.sTrfOrderDesc Dim sText2 As String = CompoWindowMap.refCompoManagerVM.sTrfMatCode & "-" & CompoWindowMap.refCompoManagerVM.sTrfSurfCode Dim sText3 As String = LenToString(b3Part.DimX(), 0) & " x " & LenToString(b3Part.DimY(), 0) & " x " & LenToString(CompoWindowMap.refCompoManagerVM.dTrfThickness, 0) Dim dRatio As Double = Math.Max(b3Part.DimX(), b3Part.DimY()) / Math.Min(b3Part.DimX(), b3Part.DimY()) If dRatio < 5 Then sText = sText & "
" & sText2 & "
" & sText3 Else sText = sText & " " & sText2 & " " & sText3 End If EgtModifyText(nTextId, sText) Dim ptCen As Point3d EgtCenterPoint(nTextId, ptCen) Dim b3Text As New BBox3d EgtGetBBoxGlob(nTextId, GDB_BB.STANDARD, b3Text) Dim dCoeff As Double = Math.Min(b3Part.DimX() / b3Text.DimX(), b3Part.DimY() / b3Text.DimY()) / 1.25 If dCoeff < 1 Then EgtScale(nTextId, New Frame3d(ptCen), dCoeff, dCoeff, dCoeff) Exit While End If nTextId = EgtGetNext(nTextId) End While ' Info di pezzo da dati Trf EgtSetInfo(Pz, "OC", CompoWindowMap.refCompoManagerVM.sTrfOrderCode) EgtSetInfo(Pz, "OD", CompoWindowMap.refCompoManagerVM.sTrfOrderDesc) EgtSetInfo(Pz, "PC", CompoWindowMap.refCompoManagerVM.sTrfPartCode) EgtSetInfo(Pz, "MT", CompoWindowMap.refCompoManagerVM.sTrfMatCode) EgtSetInfo(Pz, "SRF", CompoWindowMap.refCompoManagerVM.sTrfSurfCode) EgtSetInfo(Pz, "L", DoubleToString(b3Part.DimX(), 1)) EgtSetInfo(Pz, "W", DoubleToString(b3Part.DimY(), 1)) EgtSetInfo(Pz, "T", CompoWindowMap.refCompoManagerVM.dTrfThickness) EgtSetInfo(Pz, "V1", DoubleToString(b3Part.DimX(), 1)) EgtSetInfo(Pz, "V2", DoubleToString(b3Part.DimY(), 1)) ' Se altrimenti pezzo con dati Csv ElseIf m_bCsvData Then ' Nome del pezzo EgtSetName(Pz, CompoWindowMap.refCompoManagerVM.sCsvName) ' Dati Csv EgtSetInfo(Pz, INFO_CSV_PART, CompoWindowMap.refCompoManagerVM.sCsvName) EgtSetInfo(Pz, INFO_CSV_ORD, CompoWindowMap.refCompoManagerVM.sCsvOrder) EgtSetInfo(Pz, INFO_CSV_DIST, CompoWindowMap.refCompoManagerVM.sCsvList) EgtSetInfo(Pz, INFO_CSV_MAT, CurrentMachine.CurrMat.sName) EgtSetInfo(Pz, INFO_CSV_V1, DoubleToString(b3Part.DimX(), 1)) EgtSetInfo(Pz, INFO_CSV_V2, DoubleToString(b3Part.DimY(), 1)) ' Se definito nome lo inserisco nel testo If Not String.IsNullOrWhiteSpace(CompoWindowMap.refCompoManagerVM.sCsvName) Then Dim nTextId = EgtGetFirstInGroup(nRegLayId) While nTextId <> GDB_ID.NULL If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then Dim sText As String = String.Empty EgtTextGetContent(nTextId, sText) Dim sNewText = CompoWindowMap.refCompoManagerVM.sCsvName & "
" & sText EgtModifyText(nTextId, sNewText) Exit While End If nTextId = EgtGetNext(nTextId) End While End If ' Altrimenti pezzo con dati normali Else ' Se definito nome lo inserisco nel testo If Not String.IsNullOrWhiteSpace(sName) Then Dim nTextId = EgtGetFirstInGroup(nRegLayId) While nTextId <> GDB_ID.NULL If EgtGetType(nTextId) = GDB_TY.EXT_TEXT Then Dim sText As String = String.Empty EgtTextGetContent(nTextId, sText) Dim sNewText = sName & "
" & sText EgtModifyText(nTextId, sNewText) Exit While End If nTextId = EgtGetNext(nTextId) End While End If End If ' Eventuale testo per indicare il sopra (solo nel caso di rettangolo) If CompoWindowMap.refCompoManagerVM.Top_Visibility = Visibility.Visible And CompoWindowMap.refCompoManagerVM.TopIsChecked Then AddTopToPartRegion(nRegLayId) End If ' Scrivo testi per nesting SideEntityControlVM.WriteSideAngleForNest(CompoWindowMap.refCompoSceneHostV.CompoScene.GetCtx()) ' Imposto colore testi EstCalc.SetTextColor(nRegLayId) ' Imposto il colore del pezzo inserito nel progetto EgtSetColor(nRegLayId, InsertColor) Dim EntId As Integer = EgtGetFirstInGroup(nRegLayId) While EntId <> GDB_ID.NULL If EgtGetType(EntId) = GDB_TY.SRF_FRGN Then EgtSetColor(EntId, InsertColor) EntId = EgtGetNext(EntId) End While ' Esporto il pezzo in un file temporaneo Dim sTmpFile As String = OmagOFFICEMap.refMainWindowVM.MainWindowM.sTempDir & "\FlatPartCompo.Nge" If Not EgtSaveObjToFile(Pz, sTmpFile, NGE.BIN) Then Return False End If ' Passo al contesto principale EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) ' Recupero flag per inserimento diretto in grezzo (altrimenti in parcheggio) Dim bDirect As Boolean = (GetMainPrivateProfileInt(S_NEST, K_DIRECT, 0) <> 0) ' Elimino eventuali precedenti pezzi vuoti EgtEraseEmptyParts() ' Area dei nuovi pezzi Dim dNewArea As Double = 0 If nNbr > 1 Then sGUICode = System.Guid.NewGuid.ToString End If ' Se esiste il file del pezzo If My.Computer.FileSystem.FileExists(sTmpFile) Then ' eseguo inserimento For i As Integer = 1 To nNbr ' Inserisco il pezzo EgtInsertFile(sTmpFile) ' Ne recupero l'Id Dim nId2 As Integer = EgtGetLastPart() ' Aggiusto per lavorazioni EgtAdjustFlatPart(nId2) ' Se dati Trf assegno nome univoco If m_bTrfData Then EgtSetInfo(nId2, "CsvPart", CompoWindowMap.refCompoManagerVM.sTrfOrderCode & "-" & nId2.ToString()) ' Aggiorno l'area dei nuovi pezzi dNewArea += GeomCalc.GetPartArea(nId2) ' assegno l'identificatico del pezzo, se esiste If Not String.IsNullOrEmpty(sGUICode) Then Dim sPreGuid As String = EstCalc.CreatePreGuidCode(nId2) EgtSetInfo(nId2, INFO_REFGROUP, sPreGuid & sGUICode) End If ' muovo il pezzo nella prima posizione di parcheggio libera EstCalc.StoreOnePart(nId2, True) ' Aggiungo riferimento e lo inserisco in VeinMatching VeinMatching.SetRefOnPart(nId2) VeinMatching.AddPart(nId2, True) ' Se richiesto posizionamento diretto, lo eseguo If bDirect Then If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then ' Eventuale notifica al VeinMatching VeinMatching.OnInsertPartInRaw(nId2) End If End If '' ------------------------ AGGIUNGO PEZZO NEL VEINMATCH ---------------------------------- '' verifico che il pezzo sia un Piano Cucina o un Piano Bagno o un'Aletta 'Dim sCMP As String = String.Empty 'EgtGetInfo(nId2, "CMP", sCMP) 'If sCMP.StartsWith("PCucina") Or sCMP.StartsWith("PBagno") Or sCMP.StartsWith("AlzFront") Then ' ' Aggiungo riferimento e lo inserisco in VeinMatching ' VeinMatching.SetRefOnPart(nId2) ' VeinMatching.AddPart(nId2, True) ' ' Se richiesto posizionamento diretto, lo eseguo ' If bDirect Then ' If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then ' ' Eventuale notifica al VeinMatching ' VeinMatching.OnInsertPartInRaw(nId2) ' End If ' End If 'End If '' ------------------------ AGGIUNGO PEZZO NEL VEINMATCH ---------------------------------- Next ' Cancello il file My.Computer.FileSystem.DeleteFile(sTmpFile) End If ' passo al pezzo successivo Pz = NxtPz End While ' Aggiorno ambiente principale EgtZoom(ZM.ALL) Return True End Function Friend Sub Close(bDialogResult As Boolean) RaiseEvent m_CloseWindow(bDialogResult) End Sub #End Region ' METHODS End Class