Window 3.1h1 :

- aggiunta gestione flip pezzi per lavorare in prima fase interno invece di esterno
- aggiunta cancellazione di tutti i vecchi file risultato in modalità manuale.
This commit is contained in:
Dario Sassi
2026-08-07 11:55:06 +02:00
parent 740fbf6658
commit c8ec5c73ad
9 changed files with 155 additions and 60 deletions
+56 -45
View File
@@ -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
+16 -6
View File
@@ -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')
+1 -1
View File
@@ -91,4 +91,4 @@ if #PARTS == 0 then
end
-------------------------------------------------------------------------------------------------------------
return PartData
return PartData
+1
View File
@@ -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'
+1
View File
@@ -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)
+16 -1
View File
@@ -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
+39 -5
View File
@@ -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)
+23
View File
@@ -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
+2 -2
View File
@@ -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'