-- AutoNewTrimming.lua by Egalware s.r.l. 2026/01/05 require( 'EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( false) -- Carico le costanti di Trimming EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') require( 'Constants') -- Costante di Errore local ERROR_CREATING_NEW_TRIMMING = 'Error in Creating New Trimming : ' local WARNING_CREATING_NEW_TRIMMING = 'Warning in Creating New Trimming : ' -- Se Part di Trimming non presente, lo creo local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART_NAME) if not nPartId then nPartId = EgtGroup( GDB_ID.ROOT) if nPartId == nil or nPartId == GDB_ID.NULL or not EgtSetName( nPartId, PART_NAME) then EgtOutBox( ERROR_CREATING_NEW_TRIMMING .. 'Defining Part failed', 'Error', 'ERROR', 'OK') return end end -- Definisco un Layer temporaneo per l'inserimento delle possibili geometrie local nTmpLayerId = EgtGroup( nPartId) -- Chiedo all'utente le Tolleranze e le geometrie di ricerca automatica local vsVal = EgtDialogBox( 'New Auto Trimming', { 'Surface Layer Id', '9'}, { 'Linear Shape Tolerance', '1.0'}, { 'Angular Shape Tolerance', '30.0'}, { 'Linear Tolerance', '0.05'}, { 'Edge Linear Tolerance', '0.05'}, { 'Angular Tolerance', '15.0'}, { 'Surface Angular Tolerance', '30.0'}, { 'Circles', 'CK:1'}) if not vsVal or #vsVal ~= 8 then EgtErase( nLayerSelId) return end local nSurfLayerId = tonumber( vsVal[1]) local dShapeLinTol = tonumber( vsVal[2]) local dShapeAngTol = tonumber( vsVal[3]) local dLinTol = tonumber( vsVal[4]) local dEdgeLinTol = tonumber( vsVal[5]) local dAngTol = tonumber( vsVal[6]) local dAngFaceTol = tonumber( vsVal[7]) local bCircle = vsVal[8] -- Ricerco le Geometrie local vsEntities = {} if bCircle then table.insert( vsEntities, "circle") end local bOk = EgtTrimmingAutoSearch( nTmpLayerId, nSurfLayerId, dShapeLinTol, dShapeAngTol, dLinTol, dEdgeLinTol, dAngTol, dAngFaceTol, vsEntities) if not bOk then EgtErase( nTmpLayerId) EgtOutBox( ERROR_CREATING_NEW_TRIMMING .. 'Detecting Shapes Failed', 'Error', 'ERROR', 'OK') return end -- Se nel nuovo Layer non ho inserito nulla, allora non sono state trovate geometrie compatibili local nNewId = {} local nId = EgtGetFirstInGroup( nTmpLayerId) if not nId then EgtErase( nTmpLayerId) EgtOutBox( WARNING_CREATING_NEW_TRIMMING .. 'No Geometry found', 'Warning', 'WARNING', 'OK') return end -- Sposto tutte le Geometrie ripartizionandole in nuovi Layer di Trimming