Files
trimming/DeleteOrientationLines.lua
Daniele Bariletti 4add39ca11 Trimming :
- migliorata gestione info per orienting lines.
- corretta gestione della main guide scelta in orienting lines.
- per orienting lines adesso non vengono usati angoli di default ma quelli delle isocurve passate.
2026-05-22 10:39:24 +02:00

125 lines
4.4 KiB
Lua

-- DeleteTrimming.lua by Egalware s.r.l. 2026/05/12
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Carico le costanti di Trimming
EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua')
local GlobVar = require( 'TrimmingLib')
-- Costante di Errore
local ERROR_DELETING_ORIENTING_LINES = 'Error in Deleting Orienting Lines : '
-- Recupero il Part e il Layer corrente di Trimming
local nCurrPartId = EgtGetCurrPart()
local nCurrLayerId = EgtGetCurrLayer()
local nTrimmingLayerId = nil
-- Se il Layer corrente è di Trimming, memorizzo il suo Id
if GlobVar.IsTrimmingLayer( nCurrLayerId) then nTrimmingLayerId = nCurrLayerId
-- Se invece è un altro Layer, recupero il Layer di Trimmatura a cui si riferisce
else nTrimmingLayerId = GlobVar.GetTrimmingLayerRefId( nCurrLayerId) end
if nTrimmingLayerId == nil or nTrimmingLayerId == GDB_ID.NULL then
EgtOutBox( ERROR_DELETING_ORIENTING_LINES.. 'No Trimming Machinining Layer Found', 'Error', 'ERROR', 'OK')
return
end
-- Verifico che il Layer corrente sia di Orienting Curves
if not GlobVar.IsOrientationCurvesLayer( nCurrLayerId) then
EgtOutBox( ERROR_DELETING_ORIENTING_LINES.. 'No Orienting Lines Layer Found', 'Error', 'ERROR', 'OK')
return
end
-- Chiedo all'Utente la conferma per eliminare il Layer di Orienting Lines corrente
local bDelete = EgtOutBox( 'Do you want to delete the current Orienting Orienting Layer ?', 'Deleting', 'QUESTION', 'YESNO')
if not bDelete then return end
-- Elimino dalle curve di bordo le info
-- recupero le linee di bordo
local vIdEdges = {}
nId = EgtGetFirstInGroup( nTrimmingLayerId)
while nId do
-- verifico che sia una Curva e che sia di Bordo
if EgtGetName( nId) == EDGES_NAME then
-- Verifico che sia una Curva
local nType = EgtGetType( nId)
if nType ~= GDB_TY.CRV_LINE and nType ~= GDB_TY.CRV_ARC and nType ~= GDB_TY.CRV_BEZ and nType ~= GDB_TY.CRV_COMPO then
EgtOutBox( ERROR_DELETING_ORIENTING_LINES .. 'Invalid Border Curves', 'Error', 'ERROR', 'OK')
return
end
table.insert( vIdEdges, nId)
end
nId = EgtGetNext( nId)
end
if #vIdEdges ~= 2 then
EgtOutBox( ERROR_DELETING_ORIENTING_LINES .. 'Not 2 Border Curves detected', 'Error', 'ERROR', 'OK')
return
end
-- Layer di Orienting ( da togliere dalla lista)
local vOrientingLayerId = EgtGetInfo( vIdEdges[1], MCH_TRIMMING.OR_LAYER, 'vi')
local nPos = 0
for key, value in pairs(vOrientingLayerId) do
if value == nCurrLayerId then
nPos = key
break
end
end
if #vOrientingLayerId > 1 then
table.remove(vOrientingLayerId, nPos)
EgtSetInfo( vIdEdges[1], MCH_TRIMMING.OR_LAYER, vOrientingLayerId)
EgtSetInfo( vIdEdges[2], MCH_TRIMMING.OR_LAYER, vOrientingLayerId)
else
EgtRemoveInfo(vIdEdges[1], MCH_TRIMMING.OR_LAYER)
EgtRemoveInfo(vIdEdges[2], MCH_TRIMMING.OR_LAYER)
end
-- elimino i Vettori rappresentativi
-- Interpolation Start
local vOrientingISId = EgtGetInfo( vIdEdges[1], MCH_TRIMMING.OR_IS, 'vi')
if #vOrientingISId > 1 then
table.remove( vOrientingISId, nPos)
EgtSetInfo( vIdEdges[1], MCH_TRIMMING.OR_IS, vOrientingISId)
EgtSetInfo( vIdEdges[2], MCH_TRIMMING.OR_IS, vOrientingISId)
else
EgtRemoveInfo(vIdEdges[1], MCH_TRIMMING.OR_IS)
EgtRemoveInfo(vIdEdges[2], MCH_TRIMMING.OR_IS)
end
-- Start
local vOrientingSId = EgtGetInfo( vIdEdges[1], MCH_TRIMMING.OR_S, 'vi')
if #vOrientingSId > 1 then
table.remove( vOrientingSId, nPos)
EgtSetInfo( vIdEdges[1], MCH_TRIMMING.OR_S, vOrientingSId)
EgtSetInfo( vIdEdges[2], MCH_TRIMMING.OR_S, vOrientingSId)
else
EgtRemoveInfo(vIdEdges[1], MCH_TRIMMING.OR_S)
EgtRemoveInfo(vIdEdges[2], MCH_TRIMMING.OR_S)
end
-- End
local vOrientingEId = EgtGetInfo( vIdEdges[1], MCH_TRIMMING.OR_E, 'vi')
if #vOrientingEId > 1 then
table.remove( vOrientingEId, nPos)
EgtSetInfo( vIdEdges[1], MCH_TRIMMING.OR_E, vOrientingEId)
EgtSetInfo( vIdEdges[2], MCH_TRIMMING.OR_E, vOrientingEId)
else
EgtRemoveInfo(vIdEdges[1], MCH_TRIMMING.OR_E)
EgtRemoveInfo(vIdEdges[2], MCH_TRIMMING.OR_E)
end
-- Interpolation End
local vOrientingIEId = EgtGetInfo( vIdEdges[1], MCH_TRIMMING.OR_IE, 'vi')
if #vOrientingIEId > 1 then
table.remove( vOrientingIEId, nPos)
EgtSetInfo( vIdEdges[1], MCH_TRIMMING.OR_IE, vOrientingIEId)
EgtSetInfo( vIdEdges[2], MCH_TRIMMING.OR_IE, vOrientingIEId)
else
EgtRemoveInfo(vIdEdges[1], MCH_TRIMMING.OR_IE)
EgtRemoveInfo(vIdEdges[2], MCH_TRIMMING.OR_IE)
end
-- Elimino il Layer
EgtErase( nCurrLayerId)
-- Aggiorno la Grafica
EgtDraw()