-- EndEditSyncLines.lua by Egalware s.r.l. 2026/01/05 require( 'EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( false) -- Carico le costanti di Trimming EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') local GlobVar = require( 'TrimmingLib') -- Costante di Errore local ERROR_EDIT_SYNC_CURVES = 'Error in Edit Sync Curves : ' -- Recupero il Part e Layer di Trimming corrente ( o di riferimento) local nCurrPartId = EgtGetCurrPart() local nCurrLayerId = GlobVar.GetTrimmingLayerRefId( EgtGetCurrLayer()) if not GlobVar.IsTrimmingLayer( nCurrLayerId) then EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK') return end -- Recupero il Layer di Edit delle curve di Sincronizzazione, se non esiste, errore local nLayerEditSyncId = GlobVar.GetCurrentEditSyncCurvesLayer( nCurrPartId) if not nLayerEditSyncId or nLayerEditSyncId == GDB_ID.NULL then EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'No Edit Layer created', 'Error', 'ERROR', 'OK') return end -- Se il Layer di Salvataggio non esiste lo Creo, altrimenti lo Svuoto local nLayerStoredSyncId = GlobVar.GetCurrentStoredCurvesLayer( nCurrPartId) if not nLayerStoredSyncId or nLayerStoredSyncId == GDB_ID.NULL then nLayerStoredSyncId = GlobVar.CreateSyncStoredCurvesLayer( nCurrPartId, nCurrLayerId) if not nLayerStoredSyncId or nLayerStoredSyncId == GDB_ID.NULL then EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'Defining Part failed', 'Error', 'ERROR', 'OK') return end else EgtEmptyGroup( nLayerStoredSyncId) end -- Rialloco le Curve del Layer di Edit in quest'ultimo local vIdToRelocate = {} local nId = EgtGetFirstInGroup( nLayerEditSyncId) while nId do -- Verifico che sia una curva prima di inserirla local nType = EgtGetType( nId) if nType == GDB_TY.CRV_COMPO or nType == GDB_TY.CRV_BEZ or nType == GDB_TY.CRV_ARC or nType == GDB_TY.CRV_LINE then table.insert( vIdToRelocate, nId) end nId = EgtGetNext( nId) end for i = 1, #vIdToRelocate do EgtRelocateGlob( vIdToRelocate[i], nLayerStoredSyncId) end -- Cancello il Layer di Edit, metto il Focus sul Layer di Selezione ( Cancellando eventuali Superfici Ruled) e rendo Visibile il Layer di Salvataggio EgtErase( nLayerEditSyncId) EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId) local vIdToErase = {} nId = EgtGetFirstNameInGroup( nCurrLayerId, RULED_BZ_NAME) while nId do table.insert( vIdToErase, nId) nId = EgtGetNextName( nId, RULED_BZ_NAME) end EgtErase( vIdToErase) EgtSetStatus( nCurrLayerId, GDB_ST.ON) EgtSetStatus( nLayerStoredSyncId, GDB_ST.ON) EgtOutBox( 'Sync Curves correctly saved', 'Edit Sync', 'INFO', 'OK') -- Aggiorno la Grafica EgtDraw()