diff --git a/Designing/WinLib/WinCalculate.lua b/Designing/WinLib/WinCalculate.lua index e30335c..2847825 100644 --- a/Designing/WinLib/WinCalculate.lua +++ b/Designing/WinLib/WinCalculate.lua @@ -42,6 +42,19 @@ function WinCalculate.SetCalcPreview( bValue) s_bCalcPreview = bValue end +local s_bCalcHardwareKit = false +function WinCalculate.SetCalcHardwareKit( bValue) + s_bCalcHardwareKit = bValue +end + +local s_bCalcHardwarePosition = false +function WinCalculate.SetCalcHardwarePosition( bValue) + s_bCalcHardwarePosition = bValue +end + +local OutputKitList = {} +local OutputPositionList = {} + --------------------------------------------------------------------- -- funzione che copia la info di chiave sInfo da nSou a nDest local function CopyInfo( nDest, nSou, sInfo, Default) @@ -4959,9 +4972,11 @@ function WinCalculate.AddHardwareForSash( nFrameId, bOnlyRequest) -- creo file di richiesta ferramenta local sNow = os.date( '_%Y_%m_%d_%H_%M_%S', os.time()) local sInputFile = 'a:\\InputBatch\\Input' .. sNow .. '.txt' - local sAGBOutputFile = 'C:\\AGB3000NG\\OutputBatch\\Output' .. sNow .. '.txt' + local sAGBOutputKitFile = 'C:\\AGB3000NG\\OutputBatch\\Output' .. sNow .. '.txt' + local sAGBOutputPositionFile = 'C:\\AGB3000NG\\OutputBatch\\OutputPosition' .. sNow .. '.txt' local sAGBOutputLavFile = 'C:\\AGB3000NG\\OutputBatch\\OutputLav' .. sNow .. '.txt' - local sOutputFile = 'a:\\OutputBatch\\Output' .. sNow .. '.txt' + local sOutputKitFile = 'a:\\OutputBatch\\Output' .. sNow .. '.txt' + local sOutputPositionFile = 'a:\\OutputBatch\\OutputPosition' .. sNow .. '.txt' local sOutputLavFile = 'a:\\OutputBatch\\OutputLav' .. sNow .. '.txt' -- Apro file Input in scrittura local fhInput = io.open( sInputFile, 'w') @@ -4970,9 +4985,16 @@ function WinCalculate.AddHardwareForSash( nFrameId, bOnlyRequest) return false end - local sText = 'OUTPUTKIT=' .. sAGBOutputFile .. '\n' .. - 'S_NAME=' .. nFavourite .. '\n' .. + local sText = 'S_NAME=' .. nFavourite .. '\n' .. 'RECORDID=15A' .. '\n' + if s_bCalcHardwareKit then + sText = sText .. 'EXTINFO=ON\n' .. + 'OUTPUTKIT=' .. sAGBOutputKitFile .. '\n' + + end + if s_bCalcHardwarePosition then + sText = sText .. 'OUTPUTARTICLEPOSITION=' .. sAGBOutputPositionFile .. '\n' + end -- recupero il tipo di apertura local nOpeningType = WIN_OPENING_TYPES.NULL @@ -5051,25 +5073,24 @@ function WinCalculate.AddHardwareForSash( nFrameId, bOnlyRequest) return sInputFile end - -- attendo scrittura output + -- attendo scrittura output lavorazioni local nWait = 0 - while not EgtExistsFile( sOutputFile) and nWait < 20 do + while not EgtExistsFile( sOutputLavFile) and nWait < 1000 do nWait = nWait + 1 - EgtPause( 500) + EgtPause( 10, true) end - EgtPause( 500) + EgtPause( 10, true) - -- Apro file Output in lettura - local fhOutput = io.open( sOutputLavFile, 'r') - if not fhOutput then + -- Apro file OutputLav in lettura + local fhOutputLav = io.open( sOutputLavFile, 'r') + if not fhOutputLav then EgtOutLog( 'Error opening file ' .. sOutputLavFile) return false end local nFrameAreaId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_AREA .. '*') local nHdwFrameLayerId = EgtGetFirstNameInGroup( nFrameAreaId, WIN_HDW_FRAME) - local sOutputLine = fhOutput:lines('l') - for sMach in fhOutput:lines('l') do + for sMach in fhOutputLav:lines('l') do local MachParams = EgtSplitString( sMach, ';') local sPart = MachParams[3] local nSashIndex = tonumber( MachParams[4]) @@ -5248,8 +5269,47 @@ function WinCalculate.AddHardwareForSash( nFrameId, bOnlyRequest) end end - -- Chiudo file Output in lettura - fhOutput:close() + -- Chiudo file OutputLav in lettura + fhOutputLav:close() + + if s_bCalcHardwareKit then + + local OutputKit = {} + -- Apro file OutputKit in lettura + local fhOutputKit = io.open( sOutputKitFile, 'r') + if not fhOutputKit then + EgtOutLog( 'Error opening file ' .. sOutputKitFile) + return false + end + local nKitLineIndex = 1 + for sLine in fhOutputKit:lines('l') do + local KitParams = EgtSplitString( sLine, ';') + OutputKit[nKitLineIndex] = KitParams + nKitLineIndex = nKitLineIndex + 1 + end + table.insert( OutputKitList, OutputKit) + -- Chiudo file OutputKit in lettura + fhOutputKit:close() + end + if s_bCalcHardwarePosition then + + local OutputPosition = {} + -- Apro file OutputPosition in lettura + local fhOutputPosition = io.open( sOutputPositionFile, 'r') + if not fhOutputPosition then + EgtOutLog( 'Error opening file ' .. sOutputPositionFile) + return false + end + local nPositionLineIndex = 1 + for sLine in fhOutputPosition:lines('l') do + local PositionParams = EgtSplitString( sLine, ';') + OutputPosition[nPositionLineIndex] = PositionParams + nPositionLineIndex = nPositionLineIndex + 1 + end + table.insert( OutputPositionList, OutputPosition) + -- Chiudo file OutputPosition in lettura + fhOutputPosition:close() + end -- disegno la ferramenta if s_bCalcSolid then @@ -5259,11 +5319,184 @@ function WinCalculate.AddHardwareForSash( nFrameId, bOnlyRequest) DrawSashHardware( SashList[i].nAreaId, nFrameId, nAuxLayerId) end end + +end + +--------------------------------------------------------------------- +-- funzione che crea stringa per richiesta hardware AGB +function WinCalculate.GetAGBSashDescription( nFrameId) + -- cerco ed indicizzo ante del serramento + local SashList = {} + SearchSash( nFrameId, SashList) + + -- ordino per X e Y + local function compareXY(a,b) + if abs( a.ptCenter:getX() - b.ptCenter:getX()) < GEO.EPS_SMALL then + return a.ptCenter:getY() < b.ptCenter:getY() + else + return a.ptCenter:getX() < b.ptCenter:getX() + end + end + table.sort( SashList, compareXY) + + -- correggo nomi Frame del telaio in base all'ordinamento delle ante + for nIndex = 1, #SashList do + for nFrameIndex = 1, #SashList[nIndex].Frame do + local nFrameId = SashList[nIndex].Frame[nFrameIndex] + local sName = EgtGetName( nFrameId) + EgtSetName( nFrameId, nIndex .. '.' .. sName) + end + end + + -- recupero preferito della ferramenta + --local nFavourite = EgtGetInfo( nFrameId, WIN_HDW_FAVOURITE) + --if bOnlyRequest then + nFavourite = WDG.HDWFAVOURITE + --end + if not nFavourite or nFavourite == WIN_HDW_NULL then + EgtOutLog('Warning! No hardware favourite set!') + return + end + local sHandle = EgtGetInfo( nFrameId, WIN_HDW_HANDLE) + if bOnlyRequest then + sHandle = WDG.HDWHANDLE + end + if not sHandle then + EgtOutLog('Warning! No hardware handle set!') + return + end + + local sText = 'S_NAME=' .. nFavourite .. '\n' .. + 'RECORDID=15A' .. '\n' + + -- recupero il tipo di apertura + local nOpeningType = WIN_OPENING_TYPES.NULL + if #SashList > 0 then + nOpeningType = EgtGetInfo( SashList[1].nAreaId, WIN_OPENING_TYPE, 'i') + end + -- recupero se scorrevole + local bSlide = EgtGetInfo( nFrameId, WIN_SLIDE_WINDOW, 'b') or false + + if bSlide then + -- le dimensioni per alzante scorrevole sono quelle del telaio + local nOutlineLayId = EgtGetFirstInGroup( nFrameId, WIN_AREAOUTLINE) + local nBottomId = EgtGetFirstNameInGroup( nOutlineLayId, WIN_BOTTOM) + local dMet = EgtCurveLength( nBottomId) + local nLeftId = EgtGetFirstNameInGroup( nOutlineLayId, WIN_LEFT) + local dHet = EgtCurveLength( nLeftId) + sText = sText .. 'MET=' .. tostring( dMet) .. '\n' + sText = sText .. 'HET=' .. tostring( dHet) .. '\n' + + else + if #SashList >= 1 and abs( SashList[1].LHeight - SashList[1].RHeight) < GEO.EPS_SMALL then + sText = sText .. 'HBB=' .. tostring( SashList[1].LHeight) .. '\n' + else + for nSashIndex = 1, #SashList do + if nSashIndex == 1 then + sText = sText .. 'HBB_sx=' .. tostring( SashList[nSashIndex].LHeight) .. '\n' + else + sText = sText .. 'HBB_' .. tostring( nSashIndex - 1) .. 'B=' .. tostring( SashList[nSashIndex].LHeight) .. '\n' + end + if nSashIndex == #SashList then + sText = sText .. 'HBB_dx=' .. tostring( SashList[nSashIndex].RHeight) .. '\n' + else + sText = sText .. 'HBB_' .. tostring( nSashIndex) .. '=' .. tostring( SashList[nSashIndex].RHeight) .. '\n' + end + end + end + + if #SashList == 1 then + sText = sText .. 'LBB=' .. tostring( SashList[1].BWidth) .. '\n' + if SashList[1].BCArrow then + sText = sText .. 'FRECCIA_1=' .. tostring( SashList[1].BCArrow) .. '\n' + end + else + for nSashIndex = 1, #SashList do + sText = sText .. 'LBB' .. nSashIndex .. '=' .. tostring( SashList[nSashIndex].BWidth) .. '\n' + if SashList[nSashIndex].BCArrow then + sText = sText .. 'FRECCIA_' .. nSashIndex .. '=' .. tostring( SashList[nSashIndex].BCArrow) .. '\n' + end + end + end + end + + sText = sText .. 'FINESTRAPORTAFINESTRA=Finestra' .. '\n' .. + 'Q=1' .. '\n' + + -- opzione manoserramento ( non per vasistas altrimenti sovrascrive l'opzione) + if nOpeningType ~= WIN_OPENING_TYPES.TILTONLY_TOP then + sText = sText .. 'MANOSERRAMENTO=' .. sHandle .. '\n' + end + + local vOptions = EgtGetInfo( nFrameId, WIN_HDW_OPTIONS, 'vs') or {} + for i = 1, #vOptions do + sText = sText .. vOptions[i] .. '\n' + end + return sText +end + +--------------------------------------------------------------------- +-- funzione che recupera le opzioni dell'hardware +function WinCalculate.GetHardwareOptions( nAreaId) + local sAGBSashDescription = WinCalculate.GetAGBSashDescription( nAreaId) + -- creo file di richiesta ferramenta + local sNow = os.date( '_%Y_%m_%d_%H_%M_%S', os.time()) + local sInputFile = 'a:\\InputBatch\\Input' .. sNow .. '.txt' + local sInputOptFile = 'a:\\InputBatch\\Input' .. sNow .. '.opt' + -- Apro file Input in scrittura + local fhInput = io.open( sInputFile, 'w') + if not fhInput then + EgtOutLog( 'Error opening file ' .. sInputFile) + return false + end + + local sText = 'S_NAME=' .. nFavourite .. '\n' .. + 'RECORDID=15A' .. '\n' .. + 'only_options=on' .. '\n' .. + sAGBSashDescription .. '\n' .. + 'RUN' + -- Scrittura nuova linea + fhInput:write( sText .. '\n') + + -- Chiudo file + fhInput:close() + + if bOnlyRequest then + return sInputFile + end + + -- attendo scrittura output lavorazioni + local nWait = 0 + while not EgtExistsFile( sInputOptFile) and nWait < 1000 do + nWait = nWait + 1 + EgtPause( 10, true) + end + + EgtPause( 10, true) + + -- Apro file OutputKit in lettura + local fhOutputKit = io.open( sOutputKitFile, "rb") + if not fhOutputKit then + EgtOutLog( 'Error opening file ' .. sOutputKitFile) + return false + end + local content = SouFh:read( "*all") + -- Chiudo file OutputKit in lettura + fhOutputKit:close() + + return content end --------------------------------------------------------------------- -- funzione che aggiunge l'hardware function WinCalculate.AddHardware( nAreaId) + OutputKitList = {} + OutputPositionList = {} + WinCalculate.AddHardwareRec( nAreaId) + return OutputKitList, OutputPositionList +end + +function WinCalculate.AddHardwareRec( nAreaId) -- verifico il tipo local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i') local nSplitLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_SPLIT) @@ -5279,7 +5512,7 @@ function WinCalculate.AddHardware( nAreaId) local nChildAreaId = EgtGetFirstNameInGroup( nAreaId, WIN_AREA .. '*') while nChildAreaId do -- lancio verifica di quell'area - WinCalculate.AddHardware( nChildAreaId) + WinCalculate.AddHardwareRec( nChildAreaId) nChildAreaId = EgtGetNextName( nChildAreaId, WIN_AREA .. '*') end end diff --git a/Designing/WinLib/WinManageProject.lua b/Designing/WinLib/WinManageProject.lua index ecadebb..5a83ad9 100644 --- a/Designing/WinLib/WinManageProject.lua +++ b/Designing/WinLib/WinManageProject.lua @@ -105,20 +105,20 @@ local function GetSashTypes( tSashes, vOpeningTypes) if bSlideWindow then if #tSashes == 2 then if vOpeningTypes[1] == WIN_OPENING_TYPES.FIXED then - return { WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE} + return { WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE}, 'Dx' elseif vOpeningTypes[2] == WIN_OPENING_TYPES.FIXED then - return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED} + return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED}, 'Sx' else -- TODO individuare parametro per disinguerle - return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE_BACK} + return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE_BACK}, 'Sx' end else if vOpeningTypes[1] == WIN_OPENING_TYPES.FIXED then - return { WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED} + return { WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED}, 'Sx' elseif vOpeningTypes[2] == WIN_OPENING_TYPES.FIXED then - return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE} + return { WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_FIXED, WIN_SASHTYPES.SLIDE_MOVABLE}, 'Sx' else - return { WIN_SASHTYPES.SLIDE_MOVABLE_BACK, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE_BACK} + return { WIN_SASHTYPES.SLIDE_MOVABLE_BACK, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE, WIN_SASHTYPES.SLIDE_MOVABLE_BACK}, 'Sx' end end end @@ -126,29 +126,29 @@ local function GetSashTypes( tSashes, vOpeningTypes) -- casi standard if #tSashes == 2 then if tSashes[1][JWD_HAS_HANDLE] then - return { WIN_SASHTYPES.ACTIVE, WIN_SASHTYPES.INACTIVE} + return { WIN_SASHTYPES.ACTIVE, WIN_SASHTYPES.INACTIVE}, 'Sx' else - return { WIN_SASHTYPES.INACTIVE, WIN_SASHTYPES.ACTIVE} + return { WIN_SASHTYPES.INACTIVE, WIN_SASHTYPES.ACTIVE}, 'Dx' end elseif #tSashes == 3 then if tSashes[1][JWD_HAS_HANDLE] then - return { WIN_SASHTYPES.ACTIVE, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.INACTIVE_OUT} + return { WIN_SASHTYPES.ACTIVE, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.INACTIVE_OUT}, 'Sx' elseif tSashes[2][JWD_HAS_HANDLE] then if vOpeningTypes[2] == WIN_OPENING_TYPES.TURNONLY_LEFT or vOpeningTypes[2] == WIN_OPENING_TYPES.TILTTURN_LEFT then - return { WIN_SASHTYPES.ACTIVE_OUT, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.INACTIVE} + return { WIN_SASHTYPES.ACTIVE_OUT, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.INACTIVE}, 'Sx' else - return { WIN_SASHTYPES.INACTIVE, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.ACTIVE_OUT} + return { WIN_SASHTYPES.INACTIVE, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.ACTIVE_OUT}, 'Dx' end else - return { WIN_SASHTYPES.INACTIVE_OUT, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.ACTIVE} + return { WIN_SASHTYPES.INACTIVE_OUT, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.ACTIVE}, 'Dx' end else if tSashes[2][JWD_HAS_HANDLE] then - return { WIN_SASHTYPES.ACTIVE_OUT, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.INACTIVE_OUT} + return { WIN_SASHTYPES.ACTIVE_OUT, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.INACTIVE_OUT}, 'Sx' else - return { WIN_SASHTYPES.INACTIVE_OUT, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.ACTIVE_OUT} + return { WIN_SASHTYPES.INACTIVE_OUT, WIN_SASHTYPES.INACTIVE_IN, WIN_SASHTYPES.ACTIVE_IN, WIN_SASHTYPES.ACTIVE_OUT}, 'Dx' end end end @@ -201,14 +201,28 @@ local function ConvertTableToGeometry( AreaTable, nParentId) -- anta singola if #tSashes == 1 then - local nAreaId = WinCreate.AddSash( nParentId, vJoints, WIN_SASHTYPES.NULL, GetOpeningType( tSashes[1][JWD_OPENING_TYPE])) + local nOpeningType = GetOpeningType( tSashes[1][JWD_OPENING_TYPE]) + local nAreaId = WinCreate.AddSash( nParentId, vJoints, WIN_SASHTYPES.NULL, nOpeningType) -- aggiungo ferramenta sull'anta + if nOpeningType == WIN_OPENING_TYPES.TURNONLY_LEFT or + nOpeningType == WIN_OPENING_TYPES.TILTTURN_LEFT or + nOpeningType == WIN_OPENING_TYPES.TILTONLY_TOP or + nOpeningType == WIN_OPENING_TYPES.COPLANARSLIDE_LEFT or + nOpeningType == WIN_OPENING_TYPES.LIFTSLIDE_LEFT then + EgtSetInfo( nAreaId, WIN_HDW_HANDLE, 'Sx') + elseif nOpeningType == WIN_OPENING_TYPES.TURNONLY_RIGHT or + nOpeningType == WIN_OPENING_TYPES.TILTTURN_RIGHT or + nOpeningType == WIN_OPENING_TYPES.TILTONLY_BOTTOM or + nOpeningType == WIN_OPENING_TYPES.COPLANARSLIDE_RIGHT or + nOpeningType == WIN_OPENING_TYPES.LIFTSLIDE_RIGHT then + EgtSetInfo( nAreaId, WIN_HDW_HANDLE, 'Dx') + end WinCreate.AddHardware( nAreaId, AreaTable[JWD_HARDWARE]) -- bottomrail WinCreate.AddBottomRail( nAreaId, nBottomRailNbr) -- analizzo sottaree ConvertTableToGeometry( AreaTable[JWD_AREA_LIST][1], nAreaId) - + -- ante multiple else -- aggiungo la ferramenta sull'area parent @@ -222,8 +236,9 @@ local function ConvertTableToGeometry( AreaTable, nParentId) vOpeningTypes[i] = GetOpeningType( tSashes[i][JWD_OPENING_TYPE]) end table.remove( vDimensions) - local vSashTypes = GetSashTypes( tSashes, vOpeningTypes) - + local vSashTypes, sHandleSide = GetSashTypes( tSashes, vOpeningTypes) + EgtSetInfo( nParentId, WIN_HDW_HANDLE, sHandleSide) + -- aggiungo gli split local vSplitAreas = WinCreate.AddSplits( nParentId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.PERCENTAGE, vDimensions, 1, WIN_SPLITTYPES.FRENCH) diff --git a/Designing/WinProject.lua b/Designing/WinProject.lua index 4e9b0f1..0706646 100644 --- a/Designing/WinProject.lua +++ b/Designing/WinProject.lua @@ -253,7 +253,7 @@ _G.WinCalculate_RecalcSolids = WinCalculate_RecalcSolids ---------------------------------------------------------------------------------- local function WinCalculate_AddHardware() - WinCalculate.AddHardware( WDG.FRAMEID) + WDG.HARDWAREKIT_LIST, WDG.HARDWAREPOSITION_LIST = WinCalculate.AddHardware( WDG.FRAMEID) end _G.WinCalculate_AddHardware = WinCalculate_AddHardware @@ -358,3 +358,22 @@ local function WinGetGlassesList() end end _G.WinGetGlassesList = WinGetGlassesList + +---------------------------------------------------------------------------------- +local function WinCalculate_SetCalcHardwareKit() + WinCalculate.SetCalcHardwareKit( WDG.VALUE) +end +_G.WinCalculate_SetCalcHardwareKit = WinCalculate_SetCalcHardwareKit + +---------------------------------------------------------------------------------- +local function WinCalculate_SetCalcHardwarePosition() + WinCalculate.SetCalcHardwarePosition( WDG.VALUE) +end +_G.WinCalculate_SetCalcHardwarePosition = WinCalculate_SetCalcHardwarePosition + +---------------------------------------------------------------------------------- +local function WinCalculate_GetHardwareOptions() + WDG.HARDWAREOPTIONS = WinCalculate.GetHardwareOptions( WDG.AREAID) +end +_G.WinCalculate_GetHardwareOptions = WinCalculate_GetHardwareOptions +