Imports EgtUILib Imports System.IO Module CompoMatch ' restituisce il nome dell'assegnazione eseguito nel file Matching.lua e resetta l'assegnazione Friend Function CalcCompoMatching(sCompoDir As String, DoorNumber As Integer, sTemplate As String, ByRef sFrameTemplate As String) As Boolean ' Path del lua da utilizzare Dim sLuaPath As String = sCompoDir & "\Matching.lua" ' Verifico esistenza file Matching nel direttorio passato If Not File.Exists(sLuaPath) Then EgtOutLog("Matching error: missing file (" & sLuaPath & ")") Return False End If ' Parsing EgtLuaExecFile(sLuaPath) ' Assegno valori ai parametri per lua EgtLuaSetGlobIntVar("STU.DoorNumber", DoorNumber) EgtLuaSetGlobStringVar("STU.CompoPath", sCompoDir) EgtLuaSetGlobStringVar("STU.Template", If(IsNothing(sTemplate), "", sTemplate)) ' Chiamo funzione di Matching tra componente di anta e componente di telaio If Not EgtLuaCallFunction("STU.Matching") Then EgtOutLog("Matching error: STU.Matching") Return False End If ' Recupero il componente di telaio, già nello script lua verifico che il nome del file esista, altrimenti restituisco una stringa vuota EgtLuaGetGlobStringVar("STU.OutTemplate", sFrameTemplate) EgtLuaResetGlobVar("STU") Return True End Function ' richiamo lo script Matching.lua e lo carico con tutte le variabili necessaerie al calcolo del posizionamento delle componenti Friend Function LoadCompoParam(CurrCompo As Compo, sDoor As String) As Boolean ' Path del lua da utilizzare Dim sLuaPath As String = CurrCompo.CompoType.Path & "\Matching.lua" ' Verifico esistenza file Matching nel direttorio passato If Not File.Exists(sLuaPath) Then EgtOutLog("Matching error: missing file (" & sLuaPath & ")") Return False End If ' Parsing EgtLuaExecFile(sLuaPath) ' Assegno valori ai parametri per lua Dim CurrAssembly As Assembly = Map.refAssemblyPageVM.CurrAssembly Dim nDoorNbr As Integer = 1 Int32.TryParse(CurrAssembly.DoorNumber, nDoorNbr) EgtLuaSetGlobIntVar("STU.DoorNumber", nDoorNbr) ' indica se è la prima o la seconda anta selezionata EgtLuaSetGlobStringVar("STU.Door", sDoor) EgtLuaSetGlobStringVar("STU.CompoPath", CurrCompo.CompoType.Path) EgtLuaSetGlobStringVar("STU.Template", CurrCompo.refJambCompo.TemplateSelItem) EgtLuaSetGlobStringVar("STU.InCompoTypeName", CurrCompo.CompoType.DDFName) EgtLuaSetGlobStringVar("STU.InCompoTypeNameRef", CurrCompo.refJambCompo.CompoType.DDFName) ' eventualmente passo anche il valore del parametri "side" se è definito nella componente For Each ItemParam In CurrCompo.CompoParamList If ItemParam.DDFName = "side" AndAlso TypeOf ItemParam Is ComboBoxParam Then Dim CombPar As ComboBoxParam = DirectCast(ItemParam, ComboBoxParam) For IndexItemList = 0 To CombPar.ItemList.Count - 1 ' dal parametro scritto nella grafica ricavo il valore del ddf If CombPar.ItemList(IndexItemList) = CombPar.SelItem Then If IndexItemList <= (CombPar.ItemListDDF.Count - 1) Then EgtLuaSetGlobStringVar("STU.Side", CombPar.ItemListDDF(IndexItemList)) End If Exit For End If Next End If Next Dim bExterior As Boolean = CurrAssembly.Exterior EgtLuaSetGlobBoolVar("STU.Exterior", bExterior) Dim dLightUp As Double StringToDouble(CurrAssembly.LightUp, dLightUp) EgtLuaSetGlobNumVar("STU.LightUp", dLightUp) Dim dLightBottom As Double StringToDouble(CurrAssembly.LightBottom, dLightBottom) EgtLuaSetGlobNumVar("STU.LightBottom", dLightBottom) Dim dLightHinge As Double StringToDouble(CurrAssembly.LightHinge, dLightHinge) EgtLuaSetGlobNumVar("STU.LightHinge", dLightHinge) Dim dLightLock As Double StringToDouble(CurrAssembly.LightLock, dLightLock) EgtLuaSetGlobNumVar("STU.LightLock", dLightLock) Dim dOverlapHinge As Double StringToDouble(CurrAssembly.OverlapHinge, dOverlapHinge) EgtLuaSetGlobNumVar("STU.OverlapHinge", dOverlapHinge) Dim dOverlapLock As Double StringToDouble(CurrAssembly.OverlapLock, dOverlapLock) EgtLuaSetGlobNumVar("STU.OverlapLock", dOverlapLock) Dim dOverlapTop As Double StringToDouble(CurrAssembly.OverlapTop, dOverlapTop) EgtLuaSetGlobNumVar("STU.OverlapTop", dOverlapTop) Dim dThicknessHead As Double StringToDouble(CurrAssembly.ThicknessHead, dThicknessHead) EgtLuaSetGlobNumVar("STU.ThicknessHead", dThicknessHead) Dim dThicknessJamb As Double StringToDouble(CurrAssembly.Thickness, dThicknessJamb) EgtLuaSetGlobNumVar("STU.ThicknessJamb", dThicknessJamb) Dim dDeltaT As Double StringToDouble(CurrAssembly.DeltaThickness, dDeltaT) EgtLuaSetGlobNumVar("STU.DeltaThickness", dDeltaT) Dim dDeltaBottom As Double StringToDouble(CurrAssembly.DeltaBottom, dDeltaBottom) EgtLuaSetGlobNumVar("STU.DeltaBottom", dDeltaBottom) Dim dDepthBottom As Double StringToDouble(CurrAssembly.DepthBottom, dDepthBottom) EgtLuaSetGlobNumVar("STU.DepthBottom", dDepthBottom) Dim dThicknessBottom As Double StringToDouble(CurrAssembly.ThicknessBottom, dThicknessBottom) EgtLuaSetGlobNumVar("STU.ThicknessBottom", dThicknessBottom) Dim dOverlapBottom As Double StringToDouble(CurrAssembly.OverlapBottom, dOverlapBottom) EgtLuaSetGlobNumVar("STU.OverlapBottom", dOverlapBottom) Dim dThicknessDoor As Double Dim dHeightDoor As Double If Map.refPartPageVM.CurrPart.TypePart.Contains("DO_") Then If Not IsNothing(Map.refPartPageVM.CurrPart) Then EgtLuaSetGlobStringVar("STU.SelDoor", Map.refPartPageVM.CurrPart.TypePart) StringToDouble(Map.refPartPageVM.CurrPart.Thickness, dThicknessDoor) StringToDouble(Map.refPartPageVM.CurrPart.Height, dHeightDoor) ElseIf CurrAssembly.ListPartDoorOfDoor.Count > 0 Then StringToDouble(CurrAssembly.ListPartDoorOfDoor(0).Door.Thickness, dThicknessDoor) StringToDouble(CurrAssembly.ListPartDoorOfDoor(0).Door.Height, dHeightDoor) End If Else Dim LocalDoor As Part = Map.refAssemblyPageVM.ReserchPartDoor("DO_1").Door If Not IsNothing(LocalDoor) Then If Map.refAssemblyPageVM.CurrAssembly.DoorNumber <> "1" Then If Map.refPartPageVM.CurrPart.TypePart.Contains("FT_") AndAlso CurrCompo.OtherDoor Then LocalDoor = Map.refAssemblyPageVM.ReserchPartDoor("DO_2").Door ElseIf Map.refPartPageVM.CurrPart.TypePart.Contains("FB_") AndAlso Not CurrCompo.OtherDoor Then LocalDoor = Map.refAssemblyPageVM.ReserchPartDoor("DO_2").Door End If End If EgtLuaSetGlobStringVar("STU.SelDoor", LocalDoor.TypePart) StringToDouble(LocalDoor.Thickness, dThicknessDoor) StringToDouble(LocalDoor.Height, dHeightDoor) ElseIf CurrAssembly.ListPartDoorOfDoor.Count > 0 Then StringToDouble(CurrAssembly.ListPartDoorOfDoor(0).Door.Thickness, dThicknessDoor) StringToDouble(CurrAssembly.ListPartDoorOfDoor(0).Door.Height, dHeightDoor) End If End If EgtLuaSetGlobNumVar("STU.ThicknessDoor", dThicknessDoor) EgtLuaSetGlobNumVar("STU.HeightDoor", dHeightDoor) Dim dDoor1Width As Double = 0.0 'StringToDouble(CurrAssembly.GetArrayPartDoor(0).Door.Width, dDoor1Width) If Not IsNothing(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1")) Then StringToDouble(Map.refAssemblyManagerVM.ReserchPartDoor("DO_1").Door.Width, dDoor1Width) EgtLuaSetGlobStringVar("STU.Swing", Map.refAssemblyManagerVM.ReserchPartDoor("DO_1").Door.SwingAlias.Name) End If EgtLuaSetGlobNumVar("STU.Door1Width", dDoor1Width) Dim dDoor2Width As Double = 0.0 'StringToDouble(CurrAssembly.GetArrayPartDoor(1).Door.Width, dDoor2Width) If Not IsNothing(Map.refAssemblyManagerVM.ReserchPartDoor("DO_2")) Then StringToDouble(Map.refAssemblyManagerVM.ReserchPartDoor("DO_2").Door.Width, dDoor2Width) End If EgtLuaSetGlobNumVar("STU.Door2Width", dDoor2Width) Return True End Function ' asseganto un parametro restituisce il valore da associare allo stesso parametro sul jamb Friend Function CalcCompoParamValue(sInParamName As String, sInParamValue As String, ByRef sOutParamValue As String, ByRef IsEnable As Boolean, ByRef sSelDoor As String, Optional ByRef sConfigurationCompo As String = "Graphic parameters1", Optional ByRef sConfigurationCompoRef As String = "Graphic parameters1") As Boolean ' Assegno dati parametro EgtLuaSetGlobStringVar("STU.InParamName", sInParamName) EgtLuaSetGlobStringVar("STU.SelDoor", sSelDoor) EgtLuaSetGlobStringVar("STU.ConfigDefault", sConfigurationCompo) EgtLuaSetGlobStringVar("STU.ConfigDefaultRef", sConfigurationCompoRef) Dim dInParamValue As Double StringToDouble(sInParamValue, dInParamValue) EgtLuaSetGlobNumVar("STU.InParamValue", dInParamValue) ' Calcolo equivalente parametro in telaio If Not EgtLuaCallFunction("STU.CalcParam") Then EgtOutLog("Error in STU.CalcParam") Return False End If ' Recupero nuovo valore Dim dVal As Double EgtLuaGetGlobNumVar("STU.OutParamValue", dVal) sOutParamValue = DoubleToString(dVal, 4) ' Recupero stato di visualizzazione EgtLuaGetGlobBoolVar("STU.IsEnable", IsEnable) Return True End Function ' restituisce una variabile boolena (utilizzata nella prorpietà ReadOnly) Friend Function CalcCompoParamVisibility(sInParamName As String, ByRef IsEnable As Boolean) As Boolean ' Assegno dati parametro EgtLuaSetGlobStringVar("STU.InParamName", sInParamName) ' Calcolo equivalente parametro in telaio If Not EgtLuaCallFunction("STU.VisibilityParam") Then EgtOutLog("Error in STU.VisibilityParam") Return False End If ' Recupero stato di visualizzazione EgtLuaGetGlobBoolVar("STU.IsEnable", IsEnable) Return True End Function Friend Function ResetSTU() As Boolean EgtLuaResetGlobVar("STU") Return True End Function #Region "HARDWAREMANAGER" ' carico il file Tabella.lua per la ricerca dei nomi delle geometrie Friend Function LoadTableGeometry() As Boolean EgtLuaCreateGlobTable("HMD") Dim sLuaPath As String = IniFile.m_CompoDir & "\TabellaLua.lua" ' Verifico esistenza file Matching nel direttorio passato If Not File.Exists(sLuaPath) Then EgtOutLog("Matching error: missing file (" & sLuaPath & ")") Return False End If ' Parsing If Not EgtLuaExecFile(sLuaPath) Then EgtOutLog("Matching error: executing file (" & sLuaPath & ")") Return False End If Return True End Function ' utilizzato nell'HardwareManger per l'assegnazoine del nome della geometria Friend Function ReserchInTable(sNameHardware As String, sNameParamLua As String, ByRef sNameGeometry As String) As Boolean ' Assegno dati parametro EgtLuaSetGlobStringVar("HMD.HardwareName", sNameHardware) EgtLuaSetGlobStringVar("HMD.Parameter", sNameParamLua) If Not EgtLuaCallFunction("HMD.RicercaNellaTabella") Then EgtOutLog("Error in HMD.RicercaNellaTabella") Return False End If ' Recupero stato di visualizzazione EgtLuaGetGlobStringVar("HMD.GeometryName", sNameGeometry) Return True End Function ' pulisce l'elenco dei parametri caricati nello script Friend Function ResetCompoParam() As Boolean EgtLuaResetGlobVar("HMD") Return True End Function #End Region ' HardwareManager End Module