Files
trimming/NewTrimming.lua
T
Riccardo Elitropi 5dd7acad75 Trimming 3.1a1 :
- Primo Commit
2026-01-19 11:31:08 +01:00

54 lines
2.0 KiB
Lua

-- NewTrimming.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_CREATING_NEW_TRIMMING = 'Error in Creating New Trimming : '
-- Recupero il Part corrente
local nCurrPartId = EgtGetCurrPart()
if nCurrPartId == nil then
EgtOutBox( ERROR_CREATING_NEW_TRIMMING .. 'Current Part not Found', 'Error', 'ERROR', 'OK')
return
end
-- Chiedo all'utente le Tolleranze e le Salvo come Info nel Layer di Trimming
local vsVal = EgtDialogBox( 'New Trimming', { 'Linear Tolerance', '0.05'},
{ 'Angular Tolerance', '15.0'},
{ 'Surface Angular Tolerance', '30.0'})
if not vsVal or #vsVal ~= 3 then return end
-- Creo il Layer di Trimming all'interno del Part corrente e lo rendo corrente
local nCurrLayerId = GlobVar.CreateTrimmingLayer( nCurrPartId)
if nCurrLayerId == GDB_ID.NULL then
EgtOutBox( ERROR_CREATING_NEW_TRIMMING .. 'Defining Layer failed', 'Error', 'ERROR', 'OK')
return
end
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
local dLinTol = tonumber( vsVal[1])
local dAngTol = tonumber( vsVal[2])
local dAngFaceTol = tonumber( vsVal[3])
KEY_LIN_TOL = 'LinTol'
KEY_ANG_TOL = 'AngTol'
KEY_SURF_ANG_TOL = 'SurfAngTol'
bOk = EgtSetInfo( nCurrLayerId, KEY_LIN_TOL, dLinTol) and
EgtSetInfo( nCurrLayerId, KEY_ANG_TOL, dAngTol) and
EgtSetInfo( nCurrLayerId, KEY_SURF_ANG_TOL, dAngFaceTol)
if not bOk then
EgtOutBox( ERROR_CREATING_NEW_TRIMMING .. 'Saving Tolerances failed', 'Error', 'ERROR', 'OK')
EgtErase( nCurrLayerId)
return
end
-- Cancello tutti i Layer Temporanei ( Quindi di Stored o di Edit)
local vIdToErase = GlobVar.GetAllEditOrStoredLayer( nCurrPartId, nCurrLayerId)
if vIdToErase ~= nil and #vIdToErase ~= 1 then EgtErase( vIdToErase) end
-- Aggiorno la Grafica
EgtDraw()