-- ResetSurfChange.lua by Egalware s.r.l. 2026/04/22 require( 'EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( false) -- Carico le costanti di Trimming EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') local GlobVar = require( 'TrimmingLib') -- Costante di Errore local ERROR_REST_SURF_CHANGE = 'Error in Reset Surf Change : ' -- 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_REST_SURF_CHANGE .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK') return end -- verifico che esista il layer temporaneo con la nuova superficie e i nuovi bordi local nEditSurfLayer = GlobVar.GetCurrentEditSurfLayer( nCurrPartId, nCurrLayerId) if nEditSurfLayer == nil or nEditSurfLayer == GDB_ID.NULL then EgtOutBox( ERROR_REST_SURF_CHANGE .. 'No Temp Surface Regolarized to delete', 'Error', 'ERROR', 'OK') return end EgtDeselectAll() -- cancello tutto quello che c'è in quel layer e ripristino la visibilità dei bordi e della superficie originale EgtErase(nEditSurfLayer) local vIdEdges = {} local nId = EgtGetFirstInGroup( nCurrLayerId) while nId do -- verifico che sia una Curva e che sia di Bordo if EgtGetName( nId) == EDGES_NAME then table.insert( vIdEdges, nId) end nId = EgtGetNext( nId) end -- Se nel gruppo di trim ho esattamente 2 curve di bordo le rendo visibili if #vIdEdges == 2 then EgtSetStatus( vIdEdges[1], GDB_ST.ON) EgtSetStatus( vIdEdges[2], GDB_ST.ON) end -- verifico ci sia la superficie local nSurf = GDB_ID.NULL nId = EgtGetFirstInGroup(nCurrLayerId) while nId do if EgtGetType(nId) == GDB_TY.SRF_BEZ then nSurf = nId end nId = EgtGetNext( nId) end if nSurf ~= GDB_ID.NULL then EgtSetStatus( nSurf, GDB_ST.ON) end -- Verifico che esista il Layer di Edit per le curve di Sincronizzazione local nLayerEditSyncId = GlobVar.GetCurrentEditSyncCurvesLayer( nCurrPartId, nCurrLayerId) if nLayerEditSyncId == nil or nLayerEditSyncId == GDB_ID.NULL then -- EgtOutBox( ERROR_REST_SURF_CHANGE .. 'Click Edit SyncLines before trying to reduce twist', 'Error', 'ERROR', 'OK') -- return end -- recupero le linee di Sync selezionate e le riporto al colore standard local vSyncSel = EgtGetInfo(nCurrLayerId, KEY_SYNC_LINES_REGOLARIZATION, "vs") -- verifico che siano selezionate due curve nel layer delle Sync Lines if #vSyncSel == 2 then for i,nId in pairs( vSyncSel) do if EgtGetName(nId) == SYNC_LINE_NAME then EgtSetColor(nId, SYNC_LINE_COLOR) end end end -- cancello l'info nel layer di trimming EgtRemoveInfo(nCurrLayerId, KEY_SYNC_LINES_REGOLARIZATION) EgtDraw()