diff --git a/CAMAuto/CreateMachGroups.lua b/CAMAuto/CreateMachGroups.lua index 8b5d337..185d266 100644 --- a/CAMAuto/CreateMachGroups.lua +++ b/CAMAuto/CreateMachGroups.lua @@ -79,11 +79,13 @@ local function GetInfoPieces() local idFrame = EgtGetFirstNameInGroup( EgtGetFirstNameInGroup( PARTS[i].id, 'GeoRaw'), 'AuxFrame') PARTS[i].frame = EgtFR( idFrame) + -- recupero flag di Flip + PARTS[i].Flip = EgtGetInfo( PARTS[i].id, 'FLIP', 'b') or false + -- recupero offset per posizionamento PARTS[i].DispOffsets = {} PARTS[i].DispOffsets.Phase1 = {} PARTS[i].DispOffsets.Phase2 = {} - local bInsertedAllOffs = PartData.GetDispOffsetFromNotes( PARTS, i) -- recupero info profili @@ -140,6 +142,15 @@ local function AlignRawsToTable( PiecesInMachGroup) for i = 1, #PiecesInMachGroup do -- allineo il pezzo all'interno del grezzo local dRotX, dRotY, dRotZ = GetFixedAxesRotABCFromFrame( PiecesInMachGroup[i].frame) + if PiecesInMachGroup[i].Flip then + dRotZ = dRotZ + 180 + end + while dRotZ > 181 do + dRotZ = dRotZ - 360 + end + while dRotZ < -181 do + dRotZ = dRotZ + 360 + end -- se devo ruotare if abs( dRotZ) > GEO.EPS_ANG_SMALL then EgtRotatePartInRawPart( PiecesInMachGroup[i].id, Z_AX(), -dRotZ) @@ -210,64 +221,64 @@ end -- raggruppamento con vincoli ( lunghezza / numero pezzi) local function GroupParts( PartsList, sOptimisationType) -- TIPI DI OTTIMIZZAZIONE (sOptimisationType) - -- 'PIECE' : pezzo singolo - -- 'WINDOW' : ottimizza finestra - -- 'FULL_LIST': ottimizza progetto + -- 'PIECE' : pezzo singolo + -- 'WINDOW' : ottimizza finestra + -- 'FULL_LIST': ottimizza progetto - local Groups = {} - local Used = {} + local Groups = {} + local Used = {} - for i = 1, #PartsList do - if not Used[i] then - local Group = {} + for i = 1, #PartsList do + if not Used[i] then + local Group = {} - -- Add the main part - table.insert( Group, PartsList[i]) - Used[i] = true + -- Add the main part + table.insert( Group, PartsList[i]) + Used[i] = true - -- se non è ottimizzazione pezzo singolo, cerco altri pezzi che possono essere lavorati nella stessa macchinata - if sOptimisationType ~= 'PIECE' then - -- cerca un altro pezzo compatibile - while true do - local nBestIndex = nil - local nBestScore = -1 + -- se non è ottimizzazione pezzo singolo, cerco altri pezzi che possono essere lavorati nella stessa macchinata + if sOptimisationType ~= 'PIECE' then + -- cerca un altro pezzo compatibile + while true do + local nBestIndex = nil + local nBestScore = -1 - for j = 1, #PartsList do - if not Used[j] then - local bCanBeGrouped = not( sOptimisationType == 'WINDOW' and PartsList[i].sWindow ~= PartsList[j].sWindow) - -- se possono essere raggruppati per tipo di ottimizzazione + for j = 1, #PartsList do + if not Used[j] then + local bCanBeGrouped = not( sOptimisationType == 'WINDOW' and PartsList[i].sWindow ~= PartsList[j].sWindow) + -- se possono essere raggruppati per tipo di ottimizzazione + if bCanBeGrouped then + local VirtualList = WinLib.TableCopyDeep( Group) + table.insert( VirtualList, PartsList[j]) + bCanBeGrouped = WinData.VerifyPieces( VirtualList) + -- se possono effettivamente essere messi nella stessa macchinata if bCanBeGrouped then - local VirtualList = WinLib.TableCopyDeep( Group) - table.insert( VirtualList, PartsList[j]) - bCanBeGrouped = WinData.VerifyPieces( VirtualList) - -- se possono effettivamente essere messi nella stessa macchinata - if bCanBeGrouped then - -- il punteggio è sempre calcolato rispetto al primo pezzo del gruppo - local nScore = CalculateSimilarity( PartsList[i], PartsList[j]) - if nScore > nBestScore then - nBestScore = nScore - nBestIndex = j - end + -- il punteggio è sempre calcolato rispetto al primo pezzo del gruppo + local nScore = CalculateSimilarity( PartsList[i], PartsList[j]) + if nScore > nBestScore then + nBestScore = nScore + nBestIndex = j end end end end - - if not nBestIndex then - break - end - - -- Add the best matching part - table.insert( Group, PartsList[nBestIndex]) - Used[nBestIndex] = true end + + if not nBestIndex then + break + end + + -- Add the best matching part + table.insert( Group, PartsList[nBestIndex]) + Used[nBestIndex] = true end + end - table.insert( Groups, Group) - end - end + table.insert( Groups, Group) + end + end - return Groups + return Groups end diff --git a/CAMAuto/LuaLibs/MachiningLib.lua b/CAMAuto/LuaLibs/MachiningLib.lua index 977f0a6..0a46983 100644 --- a/CAMAuto/LuaLibs/MachiningLib.lua +++ b/CAMAuto/LuaLibs/MachiningLib.lua @@ -1,4 +1,4 @@ --- MachiningLib.lua by Egalware s.r.l. 2024/06/17 +-- MachiningLib.lua by Egalware s.r.l. 2024/08/06 -- Libreria ricerca lavorazioni per serramenti -- Tabella per definizione modulo @@ -415,13 +415,23 @@ function MachiningLib.AddOperation( OperationToInsert) nErr, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nOperationId, false) elseif OperationToInsert.AuxiliaryData.bHeadProfile then + local nInnerLeftId = EgtGetFirstNameInGroup( OperationToInsert.AuxiliaryData.nGeoId, 'InnerLeft') + local b3MachLeft = EgtGetBBoxGlob( nInnerLeftId, GDB_BB.STANDARD) + local nInnerRightId = EgtGetFirstNameInGroup( OperationToInsert.AuxiliaryData.nGeoId, 'InnerRight') + local b3MachRight = EgtGetBBoxGlob( nInnerRightId, GDB_BB.STANDARD) if OperationToInsert.AuxiliaryData.bProfilingLeft then - local nInnerLeftId = EgtGetFirstNameInGroup( OperationToInsert.AuxiliaryData.nGeoId, 'InnerLeft') - b3MachEncumbrance = EgtGetBBoxGlob( nInnerLeftId, GDB_BB.STANDARD) + if b3MachLeft:getMin():getX() < b3MachRight:getMin():getX() then + b3MachEncumbrance = b3MachLeft + else + b3MachEncumbrance = b3MachRight + end else - local nInnerRightId = EgtGetFirstNameInGroup( OperationToInsert.AuxiliaryData.nGeoId, 'InnerRight') - b3MachEncumbrance = EgtGetBBoxGlob( nInnerRightId, GDB_BB.STANDARD) - end + if b3MachLeft:getMin():getX() < b3MachRight:getMin():getX() then + b3MachEncumbrance = b3MachRight + else + b3MachEncumbrance = b3MachLeft + end + end else local nClId = EgtGetFirstNameInGroup( nOperationId, 'CL') local ptMin = EgtGetInfo( nClId, 'MMIN', 'p') diff --git a/CAMAuto/LuaLibs/PartData.lua b/CAMAuto/LuaLibs/PartData.lua index 4c3ab3a..81481c0 100644 --- a/CAMAuto/LuaLibs/PartData.lua +++ b/CAMAuto/LuaLibs/PartData.lua @@ -91,4 +91,4 @@ if #PARTS == 0 then end ------------------------------------------------------------------------------------------------------------- -return PartData \ No newline at end of file +return PartData diff --git a/Designing/WinConst.lua b/Designing/WinConst.lua index 5741fe7..91148d9 100644 --- a/Designing/WinConst.lua +++ b/Designing/WinConst.lua @@ -326,6 +326,7 @@ WIN_PRC_NTOOLS = 'NTOOLS' WIN_PRC_TOOL_NAME = 'TOOL_NAME' WIN_PRC_OFFL = 'OFFL' WIN_PRC_OFFR = 'OFFR' +WIN_PRC_FLIP = 'FLIP' WIN_PRC_OFFY_1 = 'OFFY_1' WIN_PRC_OFFZ_1 = 'OFFZ_1' WIN_PRC_OFFY_2 = 'OFFY_2' diff --git a/Designing/WinLib/WinCalculate.lua b/Designing/WinLib/WinCalculate.lua index c781bcd..c175cd5 100644 --- a/Designing/WinLib/WinCalculate.lua +++ b/Designing/WinLib/WinCalculate.lua @@ -1460,6 +1460,7 @@ local function CreatePartProfile( nPartId, nOutlineId, dDim, nBottomRail) end -- recupero le info di pinzaggio dal profilo di estrusione + CopyInfo( nPartId, nProfileId, WIN_PRC_FLIP, 0) CopyInfo( nPartId, nProfileId, WIN_PRC_OFFY_1, 0) CopyInfo( nPartId, nProfileId, WIN_PRC_OFFZ_1, 0) CopyInfo( nPartId, nProfileId, WIN_PRC_OFFY_2, 0) diff --git a/ManCreateWindow.lua b/ManCreateWindow.lua index cbd4ee1..c2fc0ca 100644 --- a/ManCreateWindow.lua +++ b/ManCreateWindow.lua @@ -1,4 +1,4 @@ --- ManCreateWindow.lua by Egalware s.r.l. 2026/07/27 +-- ManCreateWindow.lua by Egalware s.r.l. 2026/08/07 -- Creazione serramento 3d da descrizione JWD require( 'EgtBase') @@ -47,6 +47,21 @@ else if not sOpenFilePath then return end + -- backup + local sDir, sName, sExt = EgtSplitPath( sOpenFilePath) + local sBackDir = sDir .. 'bak\\' + if EgtExistsDirectory( sBackDir) then + EgtEmptyDirectory( sBackDir) + else + EgtCreateDirectory( sBackDir) + end + local vFiles = EgtFindAllFiles( sDir .. '*.*') or {} + for i = 1, #vFiles do + local sFileToMove = sDir .. vFiles[i] + EgtRenameFile( sDir .. vFiles[i], sBackDir .. vFiles[i]) + end + -- copio il file selezionato + EgtCopyFile( sBackDir .. sName .. sExt, sOpenFilePath) end end diff --git a/ManPrepMachGroups.lua b/ManPrepMachGroups.lua index 860bb68..ef44b48 100644 --- a/ManPrepMachGroups.lua +++ b/ManPrepMachGroups.lua @@ -14,12 +14,46 @@ if not nAreaId then return end +-- dati generali del progetto +local sWinPath = EgtGetCurrFilePath() +local sDir = EgtSplitPath( sWinPath) + -- rimuovo eventuali macchinate già presenti -local nMachId = EgtGetFirstMachGroup() -while nMachId do - local nCurrMachId = nMachId - nMachId = EgtGetNextMachGroup( nMachId) - EgtRemoveMachGroup(nCurrMachId) +local nMGrpId = EgtGetFirstMachGroup() +while nMGrpId do + local nCurrMGrpId = nMGrpId + local sMGrpName = EgtGetMachGroupName( nMGrpId) + nMGrpId = EgtGetNextMachGroup( nMGrpId) + -- cancello eventuali file generati dalla macchinata + local sMGrpFile = sDir .. sMGrpName .. '.bwe' + if EgtExistsFile( sMGrpFile) then + local nOrigCtx = EgtGetContext() + local nCtx = EgtCreateContext() + if nCtx and EgtOpenFile( sMGrpFile) then + local nMgId = EgtGetFirstInGroup( EgtGetFirstNameInGroup( GDB_ID.ROOT, 'MachBase') or GDB_ID.NULL) + if nMgId then + local sNcName = EgtGetInfo( nMgId, 'NcName') + if sNcName then + local _, sSpecName, _ = EgtSplitPath( sNcName) + local vFiles = EgtFindAllFiles( sDir .. sSpecName .. '*.*') or {} + for i = 1, #vFiles do + local sFileToErase = sDir .. vFiles[i] + EgtEraseFile( sFileToErase) + end + end + end + end + EgtDeleteContext( nCtx) + EgtSetContext( nOrigCtx) + end + -- cancello tutti i file del direttorio con il nome della macchinata + local vFiles = EgtFindAllFiles( sDir .. sMGrpName .. '.*') or {} + for i = 1, #vFiles do + local sFileToErase = sDir .. vFiles[i] + EgtEraseFile( sFileToErase) + end + -- cancello la macchinata + EgtRemoveMachGroup( nCurrMGrpId) end -- scrivo parametri di comando (OPT_TYPE = PIECE, WINDOW, FULL_LIST) diff --git a/ManProcOneMachGroup.lua b/ManProcOneMachGroup.lua index ffa19c0..d8a708d 100644 --- a/ManProcOneMachGroup.lua +++ b/ManProcOneMachGroup.lua @@ -46,6 +46,29 @@ if not vRes or #vRes < 1 then end local sMGrpName = EgtReplaceString( vRes[1], ' [===]', '') +-- cancello eventuali file generati dalla macchinata +local sMGrpFile = sDir .. sMGrpName .. '.bwe' +if EgtExistsFile( sMGrpFile) then + local nOrigCtx = EgtGetContext() + local nCtx = EgtCreateContext() + if nCtx and EgtOpenFile( sMGrpFile) then + local nMgId = EgtGetFirstInGroup( EgtGetFirstNameInGroup( GDB_ID.ROOT, 'MachBase') or GDB_ID.NULL) + if nMgId then + local sNcName = EgtGetInfo( nMgId, 'NcName') + if sNcName then + local _, sSpecName, _ = EgtSplitPath( sNcName) + local vFiles = EgtFindAllFiles( sDir .. sSpecName .. '*.*') or {} + for i = 1, #vFiles do + local sFileToErase = sDir .. vFiles[i] + EgtEraseFile( sFileToErase) + end + end + end + end + EgtDeleteContext( nCtx) + EgtSetContext( nOrigCtx) +end + -- cancello tutti i file del direttorio con il nome della macchinata local vFiles = EgtFindAllFiles( sDir .. sMGrpName .. '.*') or {} for i = 1, #vFiles do diff --git a/Version.lua b/Version.lua index 7598936..2f6d21c 100644 --- a/Version.lua +++ b/Version.lua @@ -1,6 +1,6 @@ --- Version.lua by Egaltech s.r.l. 2026/07/27 +-- Version.lua by Egaltech s.r.l. 2026/08/07 -- Gestione della versione di Window NAME = 'Window' -VERSION = '3.1g3' +VERSION = '3.1h1' MIN_EXE = '3.1g1'