Trimming 3.1a1 :
- Primo Commit
@@ -0,0 +1,69 @@
|
||||
-- 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
|
||||
@@ -0,0 +1,110 @@
|
||||
-- CalcBezier.lua by Egalware s.r.l. 2026/01/05
|
||||
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( true)
|
||||
|
||||
-- Carico le costanti di Trimming
|
||||
EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua')
|
||||
local GlobVar = require( 'TrimmingLib')
|
||||
-- Costante di Errore
|
||||
local ERROR_BEZIER_CREATION = 'Error in Ruled Bezier Creation : '
|
||||
|
||||
-- Recupero il Part e il Layer di Trimming con le relative Info
|
||||
local nCurrPartId = EgtGetCurrPart()
|
||||
local nCurrLayerId = GlobVar.GetTrimmingLayerRefId( EgtGetCurrLayer())
|
||||
if not GlobVar.IsTrimmingLayer( nCurrLayerId) then
|
||||
EgtOutBox( ERROR_BEZIER_CREATION .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
local dLinTol = EgtGetInfo( nCurrLayerId, KEY_LIN_TOL, 'd')
|
||||
local dAngTol = EgtGetInfo( nCurrLayerId, KEY_ANG_TOL, 'd')
|
||||
local dAngFaceTol = EgtGetInfo( nCurrLayerId, KEY_SURF_ANG_TOL, 'd')
|
||||
local bOk = ( dLinTol ~= nil and dAngTol ~= nil and dAngFaceTol ~= nil)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_BEZIER_CREATION .. 'No Trimming Machining created', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Rimuovo tutte le entità che sono Superfici di Bezier Ruled
|
||||
local vIdToErase = {}
|
||||
local nId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
while nId do
|
||||
local sName = EgtGetName( nId)
|
||||
if sName == RULED_BZ_NAME then table.insert( vIdToErase, nId) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
EgtErase( vIdToErase)
|
||||
|
||||
-- Recupero gli Edges per la creazione della Superficie di Bezier Ruled
|
||||
-- ( ed eventuali Punti di Sincronizzazione se presenti nel Layer di Salvataggio )
|
||||
local vIdEdges = {}
|
||||
local vIdSyncLines = {}
|
||||
local nLayerStoredSyncId = GlobVar.GetCurrentStoredCurvesLayer( nCurrPartId)
|
||||
if nLayerStoredSyncId and nLayerStoredSyncId ~= GDB_ID.NULL then
|
||||
-- Recupero gli Id delle Linee di sincronizzazione
|
||||
nId = EgtGetFirstInGroup( nLayerStoredSyncId)
|
||||
while nId do
|
||||
local sName = EgtGetName( nId)
|
||||
local nType = EgtGetType( nId)
|
||||
if sName ~= EDGES_NAME and ( nType == GDB_TY.CRV_COMPO or nType == GDB_TY.CRV_BEZ or nType == GDB_TY.CRV_LINE or nType == GDB_TY.CRV_ARC) then
|
||||
EgtSetName( nId, SYNC_LINE_NAME)
|
||||
table.insert( vIdSyncLines, nId)
|
||||
end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
-- Rendo Visibile il Layer di Trimming corrente
|
||||
bOk = bOk and EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
end
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_BEZIER_CREATION .. 'Borders Curves not found', 'Error', 'ERROR', 'OK')
|
||||
EgtErase( nLayerSyncId)
|
||||
return
|
||||
end
|
||||
|
||||
-- Recupero le Curve di Bordo dal Layer di Trimming corrente
|
||||
nId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
while nId do
|
||||
if EgtGetName( nId) == EDGES_NAME then table.insert( vIdEdges, nId) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
|
||||
-- Scorro a Coppie le curve di bordo presenti nel gruppo
|
||||
for i = 1, #vIdEdges, 2 do
|
||||
-- Recupero l'Indice dei Due Edges
|
||||
local nEdge1Id = vIdEdges[i]
|
||||
local nEdge2Id = vIdEdges[i+1]
|
||||
-- Se non ho esattamente un due Edges, allora non è possibile definire la Bezier Ruled
|
||||
if not nEdge1Id or not nEdge2Id then
|
||||
EgtOutBox( ERROR_BEZIER_CREATION .. 'Not 2 Curves detected', 'Error', 'ERROR', 'OK')
|
||||
EgtErase( nLayerSyncId)
|
||||
return
|
||||
end
|
||||
|
||||
-- Calcolo la Superficie di Bezier Ruled
|
||||
-- [ Per ora non passo superfici di riferimento per eventuale Invert()]
|
||||
local nSurfBzId = EgtTrimmingGetRuledBezier( nCurrLayerId, {}, nEdge1Id, nEdge2Id, dLinTol, vIdSyncLines)
|
||||
if nSurfBzId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_BEZIER_CREATION .. 'Creating Bezier Surf failed', 'Error', 'ERROR', 'OK')
|
||||
EgtErase( nSyncLayerId)
|
||||
return
|
||||
end
|
||||
|
||||
-- Assegno Colore e Name
|
||||
bOk = EgtSetColor( nSurfBzId, RULED_BZ_COLOR) and EgtSetName( nSurfBzId, RULED_BZ_NAME)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_BEZIER_CREATION .. 'Assign Surf Bezier Properties failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Nascondo le superfici di Selezione e metto il Focus sul Layer di Selezione
|
||||
nId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
while nId do
|
||||
if EgtGetName( nId) == SELECTION_SURF_NAME then EgtSetStatus( nId, GDB_ST.OFF) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,169 @@
|
||||
-- CalcBezierEdges.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_EDGE_CREATION = 'Error in Edges Creation : '
|
||||
|
||||
-- Recupero il Part e Layer di Trimming corrente
|
||||
local nCurrPartId = EgtGetCurrPart()
|
||||
local nCurrLayerId = EgtGetCurrLayer()
|
||||
if not GlobVar.IsTrimmingLayer( nCurrLayerId) then
|
||||
EgtOutBox( ERROR_EDGE_CREATION .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Recupero le Tolleranze Impostate
|
||||
local dLinTol = EgtGetInfo( nCurrLayerId, KEY_LIN_TOL, 'd')
|
||||
local dAngTol = EgtGetInfo( nCurrLayerId, KEY_ANG_TOL, 'd')
|
||||
local dAngFaceTol = EgtGetInfo( nCurrLayerId, KEY_SURF_ANG_TOL, 'd')
|
||||
local bOk = ( dLinTol ~= nil and dAngTol ~= nil and dAngFaceTol ~= nil)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDGE_CREATION .. 'No Trimming Machining created', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
local dEdgeLinTol = EgtGetInfo( nCurrLayerId, KEY_LIN_TOL_EDGES, 'd')
|
||||
local dEdgeThick = EgtGetInfo( nCurrLayerId, KEY_THICK_EDGES, 'd')
|
||||
|
||||
-- Determino il Tipo di Estrazione degli Edges
|
||||
local dLinTolForEdges = dLinTol
|
||||
local dThickForEdges = 5.0
|
||||
if dEdgeLinTol then dLinTolForEdges = dEdgeLinTol end
|
||||
if dEdgeThick then dThickForEdges = dEdgeThick end
|
||||
local vsVal = EgtDialogBox( 'Edge Extraction', { 'Type', 'CB:*Extract Edges,Edges from Normals'},
|
||||
{ 'Linear Tolerance', tostring( dLinTolForEdges)},
|
||||
{ 'Thickness', tostring( dThickForEdges)})
|
||||
if not vsVal or #vsVal ~= 3 then return end
|
||||
|
||||
-- Rendo invisibili gli altri Layer di Trimmatura e tutti i Layer Temporanei
|
||||
-- NB. Il focus va sul Layer corrente
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
nId = EgtGetFirstInGroup( nCurrPartId)
|
||||
while nId do
|
||||
if nId ~= nCurrLayerId and
|
||||
( GlobVar.IsTrimmingLayer( nId) or GlobVar.IsEditOrStoredLayer( nId)) then EgtSetStatus( nId, GDB_ST.OFF) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
|
||||
-- Rimuovo Tutte le Entità ad Eccezione delle Superfici Selezionate ( nel caso Le rendo Visibili)
|
||||
-- [NB. La Selezione cancella tutti i risutati fatti fino ad adesso]
|
||||
local vIdToErase = {}
|
||||
local nId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
while nId do
|
||||
local sName = EgtGetName( nId)
|
||||
if sName ~= SELECTION_SURF_NAME then table.insert( vIdToErase, nId)
|
||||
else EgtSetStatus( nId, GDB_ST.ON) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
EgtErase( vIdToErase)
|
||||
|
||||
-- Se Esiste un Layer di Edit o di Stored, lo Rimuovo
|
||||
local vEditOrStoredLayerIds = GlobVar.GetAllEditOrStoredLayer( nCurrPartId, nCurrLayerId)
|
||||
if vEditOrStoredLayerIds ~= nil and #vEditOrStoredLayerIds ~= 0 then EgtErase( nLayerEditId) end
|
||||
|
||||
-- Scorro le superfici di Selezione presenti e recupero il vettore di Selezione {nSurf, nFace}
|
||||
local vSel = {}
|
||||
local nSelSurfId = EgtGetFirstNameInGroup( nCurrLayerId, SELECTION_SURF_NAME)
|
||||
while nSelSurfId do
|
||||
-- Verifico che sia una Superficie TriMesh o Bezier
|
||||
local nType = EgtGetType( nSelSurfId)
|
||||
if nType ~= GDB_TY.SRF_BEZ and nType ~= GDB_TY.SRF_MESH then
|
||||
EgtOutBox( ERROR_RAW_EDGE_CREATION .. 'Invalid Surface Selected. The Surface must be a TriMesh or a Bezier', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
table.insert( vSel, { nSelSurfId, -1})
|
||||
nSelSurfId = EgtGetNextName( nSelSurfId, SELECTION_SURF_NAME)
|
||||
end
|
||||
-- Se non ho superfici di Selezione errore
|
||||
if #vSel == 0 then
|
||||
EgtOutBox( ERROR_RAW_EDGE_CREATION .. 'No Selected Surf', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
local nFirstId, nCount
|
||||
|
||||
--------------------------------- Estrazione degli Edges ---------------------------------
|
||||
if vsVal[1] == 'Extract Edges' then
|
||||
-- Recupero la tolleranza lineare per l'estrazione degli Edges
|
||||
dEdgeLinTol = tonumber( vsVal[2])
|
||||
-- La memorizzo come Info per recuperla successivamente
|
||||
EgtSetInfo( nCurrLayerId, KEY_LIN_TOL_EDGES, dEdgeLinTol)
|
||||
-- Recupero i Bordi
|
||||
bOk, nFirstId, nCount = EgtTrimmingGetBorders( nCurrLayerId, vSel, dEdgeLinTol, dAngTol)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDGE_CREATION .. 'Error in Computing Edges', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
-- Assegno Colore e Name
|
||||
for i = 0, nCount - 1 do
|
||||
bOk = EgtSetColor( nFirstId + i, EDGES_COLOR) and
|
||||
EgtSetName( nFirstId + i, EDGES_NAME)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDGE_CREATION .. 'Assign Raw Edges Properties failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------- Calcolo Edges per normali ---------------------------------
|
||||
else
|
||||
-- Recupero la tolleranza lineare per l'estrazione degli Edges e la Thickness
|
||||
dEdgeLinTol = tonumber( vsVal[2])
|
||||
local dThickness = tonumber( vsVal[3])
|
||||
-- Le Memorizzo per recuperale successivamente
|
||||
EgtSetInfo( nCurrLayerId, KEY_LIN_TOL_EDGES, dEdgeLinTol)
|
||||
EgtSetInfo( nCurrLayerId, KEY_THICK_EDGES, dEdgeThick)
|
||||
-- Calcolo i Bordi
|
||||
bOk, nFirstId, nCount = EgtTrimmingGetBordersByNormals( nCurrLayerId, vSel, dEdgeLinTol, dAngTol, dThickness)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDGE_CREATION .. 'Error in Computing Edges', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
-- Assegno Colore e Name
|
||||
for i = 0, nCount - 1 do
|
||||
bOk = EgtSetColor( nFirstId + i, EDGES_COLOR) and
|
||||
EgtSetName( nFirstId + i, EDGES_NAME)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDGE_CREATION .. 'Assign Raw Edges Properties failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
end
|
||||
-- Se più di due curve, definisco dei nuovi Layer di Trimming
|
||||
if nCount > 2 then
|
||||
for i = 2, nCount - 1, 2 do
|
||||
-- Definisco un nuovo Layer di trimming
|
||||
local nNewTrimmingLayer = GlobVar.CreateTrimmingLayer( nCurrPartId)
|
||||
if nCurrLayerId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_CREATING_NEW_TRIMMING .. 'Defining Layer failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
-- Copio proprietà
|
||||
bOk = EgtSetInfo( nNewTrimmingLayer, KEY_LIN_TOL, dLinTol) and
|
||||
EgtSetInfo( nNewTrimmingLayer, KEY_ANG_TOL, dAngTol) and
|
||||
EgtSetInfo( nNewTrimmingLayer, KEY_SURF_ANG_TOL, dAngFaceTol) and
|
||||
EgtSetInfo( nNewTrimmingLayer, KEY_LIN_TOL_EDGES, dEdgeLinTol)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_CREATING_NEW_TRIMMING .. 'Saving Tolerances failed', 'Error', 'ERROR', 'OK')
|
||||
EgtErase( nNewTrimmingLayer)
|
||||
return
|
||||
end
|
||||
-- Copio tutte le entità di tale gruppo ( ad eccezzione delle curve)
|
||||
local nOldId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
while nOldId do
|
||||
local sName = EgtGetName( nOldId)
|
||||
if sName ~= EDGES_NAME then
|
||||
local nNewId = EgtCopyGlob( nOldId, nNewTrimmingLayer)
|
||||
end
|
||||
nOldId = EgtGetNext( nOldId)
|
||||
end
|
||||
EgtRelocate( nFirstId + i, nNewTrimmingLayer)
|
||||
EgtRelocate( nFirstId + i + 1, nNewTrimmingLayer)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Aggiorno la Grafica
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,39 @@
|
||||
-- DeleteTrimming.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_DELETING_TRIMMING = 'Error in Deleting New Trimming : '
|
||||
|
||||
-- Chiedo all'Utente la conferma per eliminare il Layer di Trimming corrente ed eventuali gruppi temporanei
|
||||
local bDelete = EgtOutBox( 'Do you want to delete the current Trimming machining ?', 'Deleting', 'QUESTION', 'YESNO')
|
||||
if not bDelete then return end
|
||||
|
||||
-- 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_TRIMMING.. 'No Trimming Machinining Layer Found', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Recupero tutti i layer di Edit e di Stored associati a tale Layer di Trimmatura
|
||||
local vLayerIdToErase = GlobVar.GetAllEditOrStoredLayer( nCurrPartId, nTrimmingLayerId)
|
||||
|
||||
-- Elimino tutti i Layer ricavati
|
||||
EgtErase( nTrimmingLayerId)
|
||||
EgtErase( vLayerIdToErase)
|
||||
|
||||
-- Aggiorno la Grafica
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,143 @@
|
||||
-- EditBezierBorders.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_CURVE = 'Error in Edit Borders : '
|
||||
|
||||
-- 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_CURVE .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Creo un Layer di Edit ( o Recupero quello corrente) per le curve di Bordo
|
||||
local nLayerEditId = GlobVar.GetCurrentEditLayer( nCurrPartId)
|
||||
if not nLayerEditId or nLayerEditId == GDB_ID.NULL then
|
||||
nLayerEditId = GlobVar.CreateEditCurvesLayer( nCurrPartId, nCurrLayerId)
|
||||
else
|
||||
local bClear = EgtOutBox( 'Do you want to delete the edit Layer ?', 'Edit', 'QUESTION', 'YESNO')
|
||||
if bClear then
|
||||
EgtErase( nLayerEditId)
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
EgtDraw()
|
||||
end
|
||||
return
|
||||
end
|
||||
if not nLayerEditId or nLayerEditId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Error in creating Edit Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Recupero le Info
|
||||
local dLinTol = EgtGetInfo( nCurrLayerId, KEY_LIN_TOL, 'd')
|
||||
local dAngTol = EgtGetInfo( nCurrLayerId, KEY_ANG_TOL, 'd')
|
||||
local dAngFaceTol = EgtGetInfo( nCurrLayerId, KEY_SURF_ANG_TOL, 'd')
|
||||
local bOk = ( dLinTol ~= nil and dAngTol ~= nil and dAngFaceTol ~= nil)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'No Trimming Machining created', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Rendo Invisibili gli altri Layer di Trimming
|
||||
nId = EgtGetFirstInGroup( nCurrPartId)
|
||||
while nId do
|
||||
if GlobVar.IsTrimmingLayer( nId) then
|
||||
-- Se altro Layer di Trimming, allora diventa invisibile
|
||||
if nId ~= nCurrLayerId then EgtSetStatus( nId, GDB_ST.OFF)
|
||||
-- Se Layer di Trimming corrente, lascio visibili solo le Superfici di Selezione
|
||||
else
|
||||
local nObjId = EgtGetFirstInGroup( nId)
|
||||
while nObjId do
|
||||
local sName = EgtGetName( nObjId)
|
||||
if sName ~= SELECTION_SURF_NAME then EgtSetStatus( nObjId, GDB_ST.OFF) end
|
||||
nObjId = EgtGetNext( nObjId)
|
||||
end
|
||||
end
|
||||
end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
|
||||
-- Copio Gli Edge di Bezier nel gruppo di Edit ( l'utente vede sia la Surf che gli Edge)
|
||||
local nId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
local vnBzCrvId = {}
|
||||
while nId do
|
||||
local sName = EgtGetName( nId)
|
||||
if sName == EDGES_NAME then table.insert( vnBzCrvId, EgtCopyGlob( nId, nLayerEditId))
|
||||
-- Rendo Visibili eventuali Superfici di Selezione
|
||||
elseif sName == SELECTION_SURF_NAME then EgtSetStatus( nId, GDB_ST.ON) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
-- Se non ho trovato curve, errore
|
||||
if #vnBzCrvId == 0 then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'No Borders found', 'Error', 'ERROR', 'OK')
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
EgtErase( nLayerEditId)
|
||||
return
|
||||
end
|
||||
-- ??? EgtSetStatus( nCurrLayerId, GDB_ST.OFF)
|
||||
|
||||
-- Imposto come Layer corrente quello di Edit
|
||||
EgtSetCurrPartLayer( nCurrPartId, nLayerEditId)
|
||||
|
||||
-- Imposto visibili Tutti gli Oggetti nel Layer di Edit
|
||||
local nEditObjId = EgtGetFirstInGroup( nLayerEditId)
|
||||
while nEditObjId do
|
||||
EgtSetStatus( nEditObjId, GDB_ST.ON)
|
||||
nEditObjId = EgtGetNext( nEditObjId)
|
||||
end
|
||||
|
||||
-- Chiedo la tipologia di riconoscimento per le due curve di bordo
|
||||
local vsVal = EgtDialogBox( 'Edit Edges', { 'Type', 'CB:*Automatic,Manual,Thickness'},
|
||||
{ 'Thickness', '0.0'},
|
||||
{ 'Thickness Tolerance', '0.0'})
|
||||
if not vsVal or #vsVal ~= 3 then return end
|
||||
local dThick = 0.
|
||||
local dThickTol = 0.
|
||||
-- Se Modalità Manuale, esco
|
||||
if vsVal[1] == 'Manual' then EgtDraw() return end
|
||||
-- Se Modalità Thickness, recupero lo Spessore e la Tolleranza
|
||||
if vsVal[1] == 'Thickness' then
|
||||
dThick = tonumber( vsVal[2])
|
||||
dThickTol = tonumber( vsVal[3])
|
||||
end
|
||||
|
||||
-- Recupero le Curve di Bordo ( rimuovendo le copie fatte precedentemente)
|
||||
local nFirstId, nCount
|
||||
bOk, nFirstId, nCount = EgtTrimmingGetFinalBorders( nLayerEditId, vnBzCrvId, dLinTol, dAngTol, {}, dThick, dThickTol)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Error in Computing Edges', 'Error', 'ERROR', 'OK')
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
EgtErase( nLayerEditId)
|
||||
return
|
||||
end
|
||||
|
||||
-- Assegno Colore e Name e cancello le copie create precedentemente
|
||||
nId = EgtGetFirstInGroup( nLayerEditId)
|
||||
local vIdToErase = {}
|
||||
while nId do
|
||||
if nId < nFirstId then
|
||||
table.insert( vIdToErase, nId)
|
||||
else
|
||||
bOk = EgtSetColor( nId, EDGES_COLOR) and EgtSetName( nId, EDGES_NAME)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Assign Raw Edges Properties failed', 'Error', 'ERROR', 'OK')
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
EgtErase( nLayerEditId)
|
||||
return
|
||||
end
|
||||
end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
EgtErase( vIdToErase)
|
||||
|
||||
-- Aggiorno la Grafica
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,145 @@
|
||||
-- EditSyncLines.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 le Info
|
||||
local dLinTol = EgtGetInfo( nCurrLayerId, KEY_LIN_TOL, 'd')
|
||||
local dAngTol = EgtGetInfo( nCurrLayerId, KEY_ANG_TOL, 'd')
|
||||
local dAngFaceTol = EgtGetInfo( nCurrLayerId, KEY_SURF_ANG_TOL, 'd')
|
||||
local bOk = ( dLinTol ~= nil and dAngTol ~= nil and dAngFaceTol ~= nil)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'No Trimming Machining created', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Creo un Layer di Edit per le curve di Sincronizzazione ( o recupero quello corrente)
|
||||
local nLayerEditSyncId = GlobVar.GetCurrentEditSyncCurvesLayer( nCurrPartId)
|
||||
if not nLayerEditSyncId or nLayerEditSyncId == GDB_ID.NULL then
|
||||
nLayerEditSyncId = GlobVar.CreateEditSyncCurvesLayer( nCurrPartId, nCurrLayerId)
|
||||
else
|
||||
local bClear = EgtOutBox( 'Do you want to delete the edit Layer ?', 'Edit', 'QUESTION', 'YESNO')
|
||||
if bClear then
|
||||
EgtErase( nLayerEditSyncId)
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
EgtDraw()
|
||||
end
|
||||
return
|
||||
end
|
||||
if not nLayerEditSyncId or nLayerEditSyncId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'Error in creating Edit Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Rendo Invisibili gli altri Layer di Trimming
|
||||
nId = EgtGetFirstInGroup( nCurrPartId)
|
||||
while nId do
|
||||
if GlobVar.IsTrimmingLayer( nId) and nId ~= nCurrLayerId then EgtSetStatus( nId, GDB_ST.OFF) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
|
||||
-- Se Esiste il Layer di Sistema con le Curve di Sincronizzazione già salvate, allora le Copio da quest'Ultimo
|
||||
local nLayerSaveSyncId = GlobVar.GetCurrentStoredCurvesLayer( nCurrPartId)
|
||||
if nLayerSaveSyncId and nLayerSaveSyncId ~= GDB_ID.NULL then
|
||||
local nId = EgtGetFirstInGroup( nLayerSaveSyncId)
|
||||
while nId do
|
||||
EgtCopyGlob( nId, nLayerEditSyncId)
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
-- In Caso contrario Le Calcolo
|
||||
else
|
||||
-- Recupero le Curve di Bordo correnti e da esse estraggo quelle di Sincronizzazione
|
||||
local vIdEdges = {}
|
||||
nId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
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_EDIT_SYNC_CURVES .. 'Invalid Curve Selected', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
table.insert( vIdEdges, nId)
|
||||
end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
-- Se nel gruppo di Edit delle curve non ne ho esattamente 2 di bordo, errore
|
||||
if #vIdEdges ~= 2 then
|
||||
EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'Not 2 Border Curves detected', 'Error', 'ERROR', 'OK')
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
EgtErase( nLayerEditSyncId)
|
||||
return
|
||||
end
|
||||
-- Le inserisco nel Leyer di Edit Sync
|
||||
local nEdge1Id = EgtCopyGlob( vIdEdges[1], nLayerEditSyncId)
|
||||
local nEdge2Id = EgtCopyGlob( vIdEdges[2], nLayerEditSyncId)
|
||||
if not nEdge1Id or not nEdge2Id then
|
||||
EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'Not 2 Border Curves detected', 'Error', 'ERROR', 'OK')
|
||||
EgtErase( nLayerEditSyncId)
|
||||
end
|
||||
-- Calcolo le Curve di Sincronizzazione
|
||||
local nFirstId, nCount
|
||||
bOk, nFirstId, nCount = EgtTrimmingGetSurfBzSyncPoints( nLayerEditSyncId, nEdge1Id, nEdge2Id, dLinTol)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'Error in Computing Sync Lines', 'Error', 'ERROR', 'OK')
|
||||
EgtErase( nLayerEditSyncId)
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
return
|
||||
end
|
||||
|
||||
-- Chiedo quanti valori di Curve di Sincronizzazione devo Visualizzare e le Tolleranze
|
||||
local nSkimmingFactor = EgtGetInfo( nCurrLayerId, KEY_SKIMMING_FACTOR, 'i')
|
||||
local dSkimAngTol = EgtGetInfo( nCurrLayerId, KEY_SKIMMING_FACTOR_ANG_TOL, 'd')
|
||||
if not nSkimmingFactor or nSkimmingFactor < 0. then nSkimmingFactor = SKIMMING_FACTOR end
|
||||
if not dSkimAngTol or dSkimAngTol < 0. then dSkimAngTol = SKIMMING_ANG_TOL end
|
||||
local vsVal = EgtDialogBox( 'Seletion', { 'Skimming Factor', tostring( nSkimmingFactor)},
|
||||
{ 'Angular Tolerance', tostring( dSkimAngTol)})
|
||||
if not vsVal or #vsVal ~= 2 then
|
||||
EgtErase( nLayerEditSyncId)
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
return
|
||||
end
|
||||
nSkimmingFactor = tonumber( vsVal[1])
|
||||
dSkimAngTol = tonumber( vsVal[2])
|
||||
EgtSetInfo( nCurrLayerId, KEY_SKIMMING_FACTOR, nSkimmingFactor)
|
||||
EgtSetInfo( nCurrLayerId, KEY_SKIMMING_FACTOR_ANG_TOL, dSkimAngTol)
|
||||
local vIdSyncLines = {}
|
||||
for i = 0, nCount - 1 do table.insert( vIdSyncLines, nFirstId + i) end
|
||||
if not EgtTrimmingSkimSyncPoints( nEdge1Id, nEdge2Id, vIdSyncLines, dLinTol, dSkimAngTol, nSkimmingFactor) then
|
||||
EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'Error in Computing Sync Lines', 'Error', 'ERROR', 'OK')
|
||||
EgtErase( nLayerEditSyncId)
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
end
|
||||
|
||||
-- Assegno Colore e Name
|
||||
nId = EgtGetFirstInGroup( nLayerEditSyncId)
|
||||
while nId do
|
||||
if nId >= nFirstId then
|
||||
EgtSetColor( nId, SYNC_LINE_COLOR)
|
||||
EgtSetName( nId, SYNC_LINE_NAME)
|
||||
end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
end
|
||||
|
||||
-- Imposto il gruppo di Edit Corrente
|
||||
EgtSetCurrPartLayer( nCurrPartId, nLayerEditSyncId)
|
||||
|
||||
-- Aggiorno la Grafica
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,64 @@
|
||||
-- EndEditBezierBorders.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_CURVE = 'Error in Edit Borders : '
|
||||
|
||||
-- Recupero Part, Layer di Edit e di Trimming corrente
|
||||
local nCurrPartId = EgtGetCurrPart()
|
||||
local nTmpLayerId = EgtGetCurrLayer()
|
||||
if not nTmpLayerId or nTmpLayerId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Not a valid Current Editing Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
local nCurrLayerId = nil
|
||||
if GlobVar.IsTrimmingLayer( nTmpLayerId) then nCurrLayerId = nTmpLayerId
|
||||
else nCurrLayerId = GlobVar.GetTrimmingLayerRefId( nTmpLayerId) end
|
||||
if not nCurrLayerId or nCurrLayerId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Recupero il Layer di Edit delle Curve, se non esiste allora errore
|
||||
local nLayerEditId = GlobVar.GetCurrentEditLayer( nCurrPartId)
|
||||
if not nLayerEditId or nLayerEditId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Not a valid Trimming Edit Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Chiedo Conferma dell'Operazione
|
||||
local bDelete = EgtOutBox( 'Do you want to confirm and ending the Editing mode ?', 'Confirm', 'QUESTION', 'YESNO')
|
||||
if not bDelete then EgtSetCurrPartLayer( nCurrPartId, nLayerEditId) return end
|
||||
|
||||
-- Elimino tutte le curve di Bordo dal Layer di Trimming corrente
|
||||
local nId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
local vIdToErase = {}
|
||||
while nId do
|
||||
if EgtGetName( nId) == EDGES_NAME then table.insert( vIdToErase, nId) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
EgtErase( vIdToErase)
|
||||
|
||||
-- Inserisco tutte le curve del Layer di Edit nel Layer di Trimming corrente
|
||||
nId = EgtGetFirstInGroup( nLayerEditId)
|
||||
local vIdToRelocate = {}
|
||||
while nId do
|
||||
EgtSetName( nId, EDGES_NAME)
|
||||
table.insert( vIdToRelocate, nId)
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
for i = 1, #vIdToRelocate do EgtRelocate( vIdToRelocate[i], nCurrLayerId) end
|
||||
|
||||
-- Cancello il Layer di Edit e rendo quello di Trimming come corrente
|
||||
EgtErase( nLayerEditId)
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
|
||||
-- Aggiorno la Grafica
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,64 @@
|
||||
-- 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_CURVE .. '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 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()
|
||||
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 81 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 119 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 123 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,54 @@
|
||||
-- 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()
|
||||
@@ -1,93 +0,0 @@
|
||||
# Trimming
|
||||
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
|
||||
## Add your files
|
||||
|
||||
* [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://gitlab.steamware.net/egalware-cadcam/lua/trimming.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
|
||||
* [Set up project integrations](https://gitlab.steamware.net/egalware-cadcam/lua/trimming/-/settings/integrations)
|
||||
|
||||
## Collaborate with your team
|
||||
|
||||
* [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
* [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
* [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
* [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
|
||||
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
* [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
@@ -0,0 +1,45 @@
|
||||
-- ResetEditBezierBorders.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_CURVE = 'Error in Edit Borders : '
|
||||
|
||||
-- Recupero Part, Layer di Edit e di Trimming corrente
|
||||
local nCurrPartId = EgtGetCurrPart()
|
||||
local nTmpLayerId = EgtGetCurrLayer()
|
||||
if not nTmpLayerId or nTmpLayerId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Not a valid Current Editing Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
local nCurrLayerId = nil
|
||||
if GlobVar.IsTrimmingLayer( nTmpLayerId) then nCurrLayerId = nTmpLayerId
|
||||
else nCurrLayerId = GlobVar.GetTrimmingLayerRefId( nTmpLayerId) end
|
||||
if not nCurrLayerId or nCurrLayerId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Recupero il Layer di Edit delle Curve, se non esiste allora errore
|
||||
local nLayerEditId = GlobVar.GetCurrentEditLayer( nCurrPartId)
|
||||
if not nLayerEditId or nLayerEditId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_EDIT_CURVE .. 'Not a valid Trimming Edit Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Chiedo Conferma dell'Operazione
|
||||
local bDelete = EgtOutBox( 'Do you want to end the Editing mode ?', 'Deleting', 'QUESTION', 'YESNO')
|
||||
if not bDelete then EgtSetCurrPartLayer( nCurrPartId, nLayerEditId) return end
|
||||
|
||||
-- Cancello il Layer di Edit e rendo quello di Trimming come corrente
|
||||
EgtErase( nLayerEditId)
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
|
||||
-- Aggiorno la Grafica
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,55 @@
|
||||
-- ResetSelect.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_SELECTION = 'Error in Surf Selection : '
|
||||
|
||||
-- Recupero il Part e Layer di Trimming corrente
|
||||
local nCurrPartId = EgtGetCurrPart()
|
||||
local nCurrLayerId = EgtGetCurrLayer()
|
||||
local nTrimmingLayer = GlobVar.GetTrimmingLayerRefId( nCurrLayerId)
|
||||
if not nTrimmingLayer or nTrimmingLayer == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Chiedo all'Utente la conferma dell'operazione
|
||||
local bRemove = EgtOutBox( 'Do you want to remove the last Selected Surface ?', 'Deleting', 'QUESTION', 'YESNO')
|
||||
if not bRemove then return end
|
||||
|
||||
-- Rendo invisibili gli altri Layer di Trimmatura e tutti i Layer Temporanei
|
||||
-- NB. Il focus va sul Layer corrente
|
||||
EgtSetStatus( nTrimmingLayer, GDB_ST.ON)
|
||||
local nId = EgtGetFirstInGroup( nCurrPartId)
|
||||
while nId do
|
||||
if nId ~= nTrimmingLayer and GlobVar.IsTrimmingLayer( nId) then EgtSetStatus( nId, GDB_ST.OFF) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
|
||||
-- Rimuovo Tutte le Entità ad Eccezione delle Superfici Selezionate ( nel caso Le rendo Visibili)
|
||||
local vIdToErase = {}
|
||||
nId = EgtGetFirstInGroup( nTrimmingLayer)
|
||||
while nId do
|
||||
local sName = EgtGetName( nId)
|
||||
if sName ~= SELECTION_SURF_NAME then table.insert( vIdToErase, nId)
|
||||
else EgtSetStatus( nId, GDB_ST.ON) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
EgtErase( vIdToErase)
|
||||
|
||||
-- Se Esiste un Layer di Edit o di Store, lo Rimuovo
|
||||
local vEditOrStoreLayerIds = GlobVar.GetAllEditOrStoredLayer( nTrimmingLayer)
|
||||
if vEditOrStoreLayerIds ~= nil and #vEditOrStoreLayerIds ~= 0 then EgtErase( vEditOrStoreLayerIds) end
|
||||
|
||||
-- Recupero l'ultima(le ultime) Supercicie(i) aggiunta(e) e la(e) elimino
|
||||
local vLastSurfIds = EgtGetInfo( nTrimmingLayer, KEY_SELECTION_LAST_IDS, 'vi')
|
||||
if vLastSurfIds ~= nil and #vLastSurfIds ~= 0 then EgtErase( vLastSurfIds) end
|
||||
|
||||
-- Aggiorno la grafica
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,38 @@
|
||||
-- ResetSyncLines.lua by Egalware s.r.l. 2026/01/05
|
||||
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( true)
|
||||
|
||||
-- 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 e di Store delle Curve di Sync
|
||||
local nLayerEditId = GlobVar.GetCurrentEditSyncCurvesLayer( nCurrPartId)
|
||||
local nLayerStoreId = GlobVar.GetCurrentStoredCurvesLayer( nCurrPartId)
|
||||
if ( not nLayerEditId or nLayerEditId == GDB_ID.NULL) and ( not nLayerStoreId or nLayerStoreId == GDB_ID.NULL) then
|
||||
EgtOutBox( ERROR_EDIT_SYNC_CURVES .. 'Not a valid Edit mode created', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Cancello ( se esistono) i rispettivi Gruppi
|
||||
if nLayerEditId then EgtErase( nLayerEditId) end
|
||||
if nLayerStoreId then EgtErase( nLayerStoreId) end
|
||||
|
||||
-- Metto il Focus sul Layer di Trimming
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
EgtSetCurrPartLayer( nCurrPartId, nCurrLayerId)
|
||||
|
||||
-- Aggiorno la Grafica
|
||||
EgtDraw()
|
||||
@@ -0,0 +1,251 @@
|
||||
-- Select.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_SELECTION = 'Error in Surf Selection : '
|
||||
|
||||
-- Recupero il Part e Layer di Trimming corrente
|
||||
local nCurrPartId = EgtGetCurrPart()
|
||||
local nCurrLayerId = EgtGetCurrLayer()
|
||||
if not GlobVar.IsTrimmingLayer( nCurrLayerId) then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Recupero l'oggetto selezionato ( verifico che sia Superficie TriMesh o Superficie Bezier)
|
||||
local nSelObjId = EgtGetLastSelectedObj()
|
||||
if not nSelObjId then
|
||||
EgtOutBox( ERROR_SELECTION .. 'No Object Selected', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
local nType = EgtGetType( nSelObjId)
|
||||
if nType ~= GDB_TY.SRF_BEZ and nType ~= GDB_TY.SRF_MESH then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Invalid Surface Selected. The Surface must be a TriMesh or a Bezier', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Chiedo l'operazione da svolgere su tale superficie e ricavo i parametri inseriti
|
||||
local dSize = 5.0
|
||||
local dStoredSize = EgtGetInfo( nCurrLayerId, KEY_SURF_BORDER_SIZE, 'd')
|
||||
if dStoredSize ~= nil then dSize = dStoredSize end
|
||||
local dSizeTol = 0.75
|
||||
local dStoredSizeTol = EgtGetInfo( nCurrLayerId, KEY_SURF_BORDER_SIZE_TOL, 'd')
|
||||
if dStoredSizeTol ~= nil then dSizeTol = dStoredSizeTol end
|
||||
local vsVal = EgtDialogBox( 'Seletion', { 'Type', 'CB:*Insert Surface,Face Search,Surf Search'},
|
||||
{ 'Size', tostring( dSize)},
|
||||
{ 'Size Tolerance', tostring( dSizeTol)})
|
||||
if not vsVal or #vsVal ~= 3 then return end
|
||||
dSize = tonumber( vsVal[2])
|
||||
dSizeTol = tonumber( vsVal[3])
|
||||
EgtSetInfo( nCurrLayerId, KEY_SURF_BORDER_SIZE, dSize)
|
||||
EgtSetInfo( nCurrLayerId, KEY_SURF_BORDER_SIZE_TOL, dSizeTol)
|
||||
|
||||
-- Recupero le tolleranze impostate alla creazione del Layer di Trimming corrente
|
||||
local dLinTol = EgtGetInfo( nCurrLayerId, KEY_LIN_TOL, 'd')
|
||||
local dAngTol = EgtGetInfo( nCurrLayerId, KEY_ANG_TOL, 'd')
|
||||
local dAngFaceTol = EgtGetInfo( nCurrLayerId, KEY_SURF_ANG_TOL, 'd')
|
||||
local bOk = ( dLinTol ~= nil and dAngTol ~= nil and dAngFaceTol ~= nil)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
-- Rendo invisibili gli altri Layer di Trimmatura e tutti i Layer Temporanei
|
||||
-- NB. Il focus va sul Layer corrente
|
||||
EgtSetStatus( nCurrLayerId, GDB_ST.ON)
|
||||
nId = EgtGetFirstInGroup( nCurrPartId)
|
||||
while nId do
|
||||
if nId ~= nCurrLayerId and
|
||||
( GlobVar.IsTrimmingLayer( nId) or GlobVar.IsEditOrStoredLayer( nId)) then EgtSetStatus( nId, GDB_ST.OFF) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
|
||||
-- Rimuovo Tutte le Entità ad Eccezione delle Superfici Selezionate ( nel caso Le rendo Visibili)
|
||||
-- [NB. La Selezione cancella tutti i risutati fatti fino ad adesso]
|
||||
local vIdToErase = {}
|
||||
local nId = EgtGetFirstInGroup( nCurrLayerId)
|
||||
while nId do
|
||||
local sName = EgtGetName( nId)
|
||||
if sName ~= SELECTION_SURF_NAME then table.insert( vIdToErase, nId)
|
||||
else EgtSetStatus( nId, GDB_ST.ON) end
|
||||
nId = EgtGetNext( nId)
|
||||
end
|
||||
EgtErase( vIdToErase)
|
||||
|
||||
-- Se Esiste un Layer di Edit o di Stored, lo Rimuovo
|
||||
-- [NB. La Selezione cancella tutti i risultati fatti fino ad adesso]
|
||||
local vEditOrStoredLayerIds = GlobVar.GetAllEditOrStoredLayer( nCurrPartId, nCurrLayerId)
|
||||
if vEditOrStoredLayerIds ~= nil and #vEditOrStoredLayerIds ~= 0 then EgtErase( nLayerEditId) end
|
||||
|
||||
--------------------------------- Inserimento della Superficie ---------------------------------
|
||||
-- [Nessuna Tolleranza]
|
||||
if vsVal[1] == 'Insert Surface' then
|
||||
|
||||
-- Recupero tutti gli Oggetti selezionati che sono Superfici TriMesh o di Bezier
|
||||
local vObjId = {}
|
||||
local nCurrObjId = EgtGetFirstSelectedObj()
|
||||
while nCurrObjId do
|
||||
local nObjType = EgtGetType( nCurrObjId)
|
||||
if nObjType == GDB_TY.SRF_MESH or nObjType == GDB_TY.SRF_BEZ then table.insert( vObjId, nCurrObjId) end
|
||||
nCurrObjId = EgtGetNextSelectedObj()
|
||||
end
|
||||
-- Dalle superfici già presenti nel Layer di selezione, rimuovo gli Id dei riferimenti ( per non duplicare superfici)
|
||||
local vOldSelSurfId = {}
|
||||
local nId = EgtGetFirstNameInGroup( nCurrLayerId, SELECTION_SURF_NAME)
|
||||
while nId do
|
||||
local nObjType = EgtGetType( nId)
|
||||
if nObjType == GDB_TY.SRF_MESH or nObjType == GDB_TY.SRF_BEZ then
|
||||
-- Se la superficie selezionata precedentemente ha come riferimento una superficie, ne memorizzo l'Id
|
||||
local nRefSurfId = EgtGetInfo( nId, KEY_SELECTION_REF_SURF, 'i')
|
||||
if nRefSurfId then table.insert( vOldSelSurfId, nRefSurfId) end
|
||||
end
|
||||
nId = EgtGetNextName( nId, SELECTION_SURF_NAME)
|
||||
end
|
||||
local setToRemove = {}
|
||||
for _, v in ipairs( vOldSelSurfId) do setToRemove[v] = true end
|
||||
local vSurfIds = {}
|
||||
for _, v in ipairs( vObjId) do
|
||||
if not setToRemove[v] then table.insert( vSurfIds, v) end
|
||||
end
|
||||
-- Inserisco le superfici rimanenti nel Layer di Selezione
|
||||
local vNewSurfIds = {}
|
||||
for i = 1, #vSurfIds do
|
||||
local nInsertSurfId = EgtCopyGlob( vSurfIds[i], nCurrLayerId)
|
||||
if not nInsertSurfId or nInsertSurfId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Copying Surface failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
table.insert( vNewSurfIds, nInsertSurfId)
|
||||
-- Assegno Colore e Nome
|
||||
local bOk = EgtSetColor( nInsertSurfId, SELECTION_SURF_COLOR) and
|
||||
EgtSetInfo( nInsertSurfId, KEY_SELECTION_REF_SURF, vSurfIds[i]) and
|
||||
EgtSetName( nInsertSurfId, SELECTION_SURF_NAME)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Copying Surface failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
end
|
||||
EgtSetInfo( nCurrLayerId, KEY_SELECTION_LAST_IDS, vNewSurfIds)
|
||||
|
||||
--------------------------------- Ricerca delle facce adiancenti --------------------------------
|
||||
-- [Tolleranza angolare di superficie]
|
||||
elseif vsVal[1] == 'Face Search' then
|
||||
|
||||
local bOk = false
|
||||
-- Se la superficie è una Bezier, allora la inserisco direttamente come Preview
|
||||
if nType == GDB_TY.SRF_BEZ then
|
||||
local nInsertSurfId = EgtCopyGlob( nSelObjId, nCurrLayerId)
|
||||
if not nInsertSurfId or nInsertSurfId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Copying Surface failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
-- Assegno Colore, Info e Name
|
||||
bOk = EgtSetColor( nInsertSurfId, SELECTION_SURF_COLOR) and
|
||||
EgtSetInfo( nInsertSurfId, KEY_SELECTION_REF_SURF, nSelObjId) and
|
||||
EgtSetName( nInsertSurfId, SELECTION_SURF_NAME) and
|
||||
EgtSetInfo( nCurrLayerId, KEY_SELECTION_LAST_IDS, { nInsertSurfId})
|
||||
|
||||
-- Se invece è una Trimesh, recupero il primo triangolo selezionato
|
||||
else
|
||||
local nId, nTria, ptInt = EgtGetLastSelInfo()
|
||||
if not nId or not nTria then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Face not found', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
-- *** Debug ( nel caso di errori, so che punto è stato selezionato ) ***
|
||||
local sStr = 'Pt = ' .. tostring( ptInt) .. ' - nTria = ' .. tostring( nTria)
|
||||
EgtOutLog( sStr)
|
||||
-- Recupero la superficie mediante adiancenza dei triangoli
|
||||
local nInsertSurfId = EgtTrimmingGetSurfTmFaceAdj( nCurrLayerId, nId, {nTria}, {ptInt}, dAngFaceTol, dSize, dSizeTol)
|
||||
if not nInsertSurfId or nInsertSurfId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Face Search failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
-- Assegno Colore, Info e Name
|
||||
bOk = EgtSetColor( nInsertSurfId, SELECTION_SURF_COLOR) and
|
||||
EgtSetInfo( nInsertSurfId, KEY_SELECTION_REF_SURF, nId) and
|
||||
EgtSetName( nInsertSurfId, SELECTION_SURF_NAME) and
|
||||
EgtSetInfo( nCurrLayerId, KEY_SELECTION_LAST_IDS, { nInsertSurfId})
|
||||
end
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Copying Surface failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
|
||||
--------------------------------- Ricerca delle superfici Adiacenti ---------------------------------
|
||||
-- [Tolleranza lineare, Tolleranza angolare e Tolleranza angolare applicata alla Superficie]
|
||||
elseif vsVal[1] == 'Surf Search' then
|
||||
|
||||
-- Recupero il Gruppo della superficie corrente
|
||||
local nSurfGroup = EgtGetParent( nSelObjId)
|
||||
if not nSurfGroup or nSurfGroup == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Surface not in a valid Group', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
-- Recupero tutti Gli Id delle Superfici Attive del Gruppo della Supercicie Corrente
|
||||
local vAllSurfIds = {}
|
||||
local nOtherId = EgtGetFirstInGroup( nSurfGroup)
|
||||
while nOtherId do
|
||||
local nStatus = EgtGetStatus( nOtherId)
|
||||
if nStatus == GDB_ST.ON and nOtherId ~= nId then
|
||||
table.insert( vAllSurfIds, nOtherId)
|
||||
end
|
||||
nOtherId = EgtGetNext( nOtherId)
|
||||
end
|
||||
-- Recupero le superfici da Selezionare
|
||||
local bOk, vSelSurfId = EgtTrimmingGetAdjSurfs( nSelObjId, vAllSurfIds, dLinTol, dAngTol, dAngFaceTol)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_SELECTION, 'Surface Search failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
table.insert( vSelSurfId, nSelObjId)
|
||||
-- Dalle superfici già presenti nel Layer di selezione, rimuovo gli Id dei riferimenti ( per non duplicare superfici)
|
||||
local vOldSelSurfId = {}
|
||||
local nId = EgtGetFirstNameInGroup( nCurrLayerId, SELECTION_SURF_NAME)
|
||||
while nId do
|
||||
local nObjType = EgtGetType( nId)
|
||||
if nObjType == GDB_TY.SRF_MESH or nObjType == GDB_TY.SRF_BEZ then
|
||||
-- Se la superficie selezionata precedentemente ha come riferimento una superficie, ne memorizzo l'Id
|
||||
local nRefSurfId = EgtGetInfo( nId, KEY_SELECTION_REF_SURF, 'i')
|
||||
if nRefSurfId then table.insert( vOldSelSurfId, nRefSurfId) end
|
||||
end
|
||||
nId = EgtGetNextName( nId, SELECTION_SURF_NAME)
|
||||
end
|
||||
local setToRemove = {}
|
||||
for _, v in ipairs( vOldSelSurfId) do setToRemove[v] = true end
|
||||
local vSurfIds = {}
|
||||
for _, v in ipairs( vSelSurfId) do
|
||||
if not setToRemove[v] then table.insert( vSurfIds, v) end
|
||||
end
|
||||
-- Aggiungo le Superfici come Preview, assegnando Colore, Info e Name
|
||||
local vNewInsertedSrfIds = {}
|
||||
for nSurf = 1, #vSurfIds do
|
||||
local nInsertSurfId = EgtCopyGlob( vSurfIds[nSurf], nCurrLayerId)
|
||||
if not nInsertSurfId or nInsertSurfId == GDB_ID.NULL then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Creating Selected Surf Preview failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
table.insert( vNewInsertedSrfIds, nInsertSurfId)
|
||||
bOk = EgtSetColor( nInsertSurfId, SELECTION_SURF_COLOR) and
|
||||
EgtSetInfo( nInsertSurfId, KEY_SELECTION_REF_SURF, vSurfIds[nSurf]) and
|
||||
EgtSetName( nInsertSurfId, SELECTION_SURF_NAME)
|
||||
if not bOk then
|
||||
EgtOutBox( ERROR_SELECTION .. 'Copying Surface failed', 'Error', 'ERROR', 'OK')
|
||||
return
|
||||
end
|
||||
end
|
||||
EgtSetInfo( nCurrLayerId, KEY_SELECTION_LAST_IDS, vNewInsertedSrfIds)
|
||||
|
||||
end
|
||||
|
||||
-- Deselelziono la superficie corrente e aggiorno la grafica
|
||||
EgtDeselectObj( nSelObjId)
|
||||
EgtDraw()
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
[Trimming]
|
||||
TrimEnable=1
|
||||
BaseDir=C:\EgtData\Trimming
|
||||
Button1=AutoNewTrimming.lua,Images\AutoNewTrimming.png,Auto New Trimming
|
||||
Button2=NewTrimming.lua,Images\NewTrimming.png,New Trimming
|
||||
Button3=DeleteTrimming.lua,Images\DeleteTrimming.png, Delete Trimming
|
||||
Button4=Separator
|
||||
Button5=Select.lua,Images\Select.png,Select,
|
||||
Button6=ResetSelect.lua,Images\ResetSelect.png, <-- Undo,
|
||||
Button7=Separator
|
||||
Button8=CalcBezierEdges.lua,Images\BezierEdges.png,Get Borders
|
||||
Button9=EditBezierBorders.lua,Images\EditBezierEdges.png,Edit Curves
|
||||
Button10=ResetEditBezierBorders.lua,Images\ResetEditBezierEdges.png,<-- Undo
|
||||
Button11=EndEditBezierBorders.lua,Images\EndEditBezierEdges.png,Ok
|
||||
Button12=Separator
|
||||
Button13=CalcBezier.lua,Images\BezierSurf.png,Get Surf
|
||||
Button14=EditSyncLines.lua,Images\EditSyncLines.png,Edit SyncLines
|
||||
Button15=ResetSyncLines.lua,Images\ResetSyncLines.png,Reset SyncLines
|
||||
Button16=EndEditSyncLines.lua,Images\EndSyncLines.png,Ok
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
-- TrimmingLib.lua by Egalware s.r.l. 2026/01/05
|
||||
-- Modulo per Definizione di Costanti, Variabili e Funzioni di Trimming
|
||||
|
||||
local TrimmingVar = {
|
||||
nCounter = 0
|
||||
}
|
||||
|
||||
-- *** ============================== COSTANTI ============================== ***
|
||||
|
||||
-- Chiavi Info Part/Layers
|
||||
KEY_LIN_TOL = 'LinTol'
|
||||
KEY_LIN_TOL_EDGES = 'LinTolEdges' -- Edges Extraction (modify)
|
||||
KEY_THICK_EDGES = 'ThickEdges' -- Edges Extraction (modify)
|
||||
KEY_ANG_TOL = 'AngTol'
|
||||
KEY_SURF_ANG_TOL = 'SurfAngTol'
|
||||
KEY_SURF_BORDER_SIZE = 'BorderSize' -- Selection
|
||||
KEY_SURF_BORDER_SIZE_TOL = 'BorderSizeTol' -- Selection
|
||||
KEY_SELECTION_REF_SURF = 'nRefSurf' -- Selection
|
||||
KEY_SELECTION_LAST_IDS = 'vSelLastIds' -- Undo Selection
|
||||
KEY_REF_TRIMMING_LAYER = 'nRefTrimmingLayer' -- Trimming Layer Ref
|
||||
KEY_AUTO_TRIMMING = 'AutoTrim' -- AutoTrimming
|
||||
KEY_SKIMMING_FACTOR = 'SkimmingFactor' -- Skimming Sync Lines
|
||||
KEY_SKIMMING_FACTOR_ANG_TOL = 'SkimmingFactorAngTol' -- Skimming Sync Lines Tol
|
||||
|
||||
-- Chive per Tipologia di Layer
|
||||
KEY_LAYER_TYPE = 'Trimming_Layer_Type'
|
||||
KEY_LAYER_SELECTION = 'Trimming_Selection_Layer'
|
||||
KEY_LAYER_EDIT_CURVES = 'Trimming_EditCurves_Layer'
|
||||
KEY_LAYER_SYNC_CURVES = 'Trimming_SyncCurves_Layer'
|
||||
KEY_LAYER_SYNC_STORE_CURVES = 'Trimming_SyncStoredCurves_Layer'
|
||||
|
||||
-- Generali --
|
||||
PART_NAME = 'Trimming'
|
||||
LAYER_NAME_SELECTION = 'Trimming'
|
||||
LAYER_NAME_EDIT_CURVES = 'EditCurves'
|
||||
LAYER_NAME_SYNC_CURVES = 'SyncCurves'
|
||||
LAYER_NAME_SYNC_STORED_CURVES = 'SyncStoredCurves'
|
||||
ANG_FACE_TOL = 30.
|
||||
ANG_TOL = 15.
|
||||
LIN_TOL = 0.05
|
||||
SKIMMING_FACTOR = 4
|
||||
SKIMMING_ANG_TOL = 10.0
|
||||
|
||||
-- Selezione delle superfici --
|
||||
SELECTION_SURF_NAME = 'Selected_Surf'
|
||||
SELECTION_TYPE = {
|
||||
INSERT = 'Insert',
|
||||
FACE_SEARCH = 'Search Faces',
|
||||
SURF_SEARCH = 'Search Surfaces'
|
||||
}
|
||||
SELECTION_NO_FACE = -1
|
||||
SELECTION_SURF_COLOR = Color3d( 255, 255, 185)
|
||||
|
||||
-- Creazione dei bordi Bezier --
|
||||
EDGES_NAME = 'Border'
|
||||
EDGES_COLOR = Color3d( 0, 128, 255)
|
||||
|
||||
-- Edit dei bordi di Bezier --
|
||||
EDGES_EDIT_TYPE = {
|
||||
AUTOMATIC = 'Automatic',
|
||||
THICKNESS = 'Thickness'
|
||||
}
|
||||
|
||||
-- Creazione dei tratti di sincronizzazione
|
||||
SYNC_LINE_NAME = 'SyncLines'
|
||||
SYNC_LINE_COLOR = Color3d( 0, 255, 0)
|
||||
|
||||
-- Creazione della Superficie Ruled di Bezier
|
||||
RULED_BZ_NAME = 'SurfBz'
|
||||
RULED_BZ_COLOR = Color3d( 37, 37, 37)
|
||||
|
||||
|
||||
-- ***============================== FUNZIONI ==============================***
|
||||
|
||||
--======================== Contatore Incrementale =======================
|
||||
function TrimmingVar.IncrementCounter()
|
||||
TrimmingVar.nCounter = TrimmingVar.nCounter + 1
|
||||
end
|
||||
function TrimmingVar.ResetCounter()
|
||||
TrimmingVar.nCounter = 0
|
||||
end
|
||||
|
||||
--========================== Layer di Trimmatura ==========================
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Funzione per creare un Layer di Trimmatura
|
||||
function TrimmingVar.CreateTrimmingLayer( nCurrPartId)
|
||||
local nCurrLayerId = EgtGroup( nCurrPartId)
|
||||
local bOk = ( nCurrLayerId ~= nil)
|
||||
if bOk then
|
||||
TrimmingVar.IncrementCounter()
|
||||
local sName = LAYER_NAME_SELECTION .. ' ' .. TrimmingVar.nCounter
|
||||
bOk = EgtSetName( nCurrLayerId, sName) and EgtSetInfo( nCurrLayerId, KEY_LAYER_TYPE, KEY_LAYER_SELECTION)
|
||||
end
|
||||
if not bOk then
|
||||
EgtErase( nCurrLayerId)
|
||||
return GDB_ID.NULL
|
||||
end
|
||||
return nCurrLayerId
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Funzione per verificare se un Layer è un Layer di Trimmatura
|
||||
function TrimmingVar.IsTrimmingLayer( nId)
|
||||
-- Verifico che la chiave del gruppo sia coerente
|
||||
local sLayerType = EgtGetInfo( nId, KEY_LAYER_TYPE, 's')
|
||||
return ( sLayerType ~= nil and sLayerType == KEY_LAYER_SELECTION)
|
||||
end
|
||||
|
||||
--============================ Layer Edit Bordi ===========================
|
||||
|
||||
-- Funzione per creare un Layer di Edit dei bordi
|
||||
function TrimmingVar.CreateEditCurvesLayer( nCurrPartId, nCurrLayerId)
|
||||
local nEditLayerId = EgtGroup( nCurrPartId)
|
||||
local bOk = ( nEditLayerId ~= nil)
|
||||
if bOk then
|
||||
bOk = ( EgtSetName( nEditLayerId, LAYER_NAME_EDIT_CURVES) and
|
||||
EgtSetInfo( nEditLayerId, KEY_LAYER_TYPE, KEY_LAYER_EDIT_CURVES) and
|
||||
EgtSetInfo( nEditLayerId, KEY_REF_TRIMMING_LAYER, nCurrLayerId))
|
||||
end
|
||||
if not bOk then
|
||||
EgtErase( nEditLayerId)
|
||||
return GDB_ID.NULL
|
||||
end
|
||||
return nEditLayerId
|
||||
end
|
||||
|
||||
-- Funzione per verificare se un Layer è un Layer di Edit dei bordi
|
||||
function TrimmingVar.IsEditCurvesLayer( nId)
|
||||
if nId == nil or nId == GDB_ID.NULL then return false end
|
||||
-- Verifico che la chiave del gruppo sia coerente
|
||||
local sLayerType = EgtGetInfo( nId, KEY_LAYER_TYPE, 's')
|
||||
return ( sLayerType ~= nil and sLayerType == KEY_LAYER_EDIT_CURVES)
|
||||
end
|
||||
|
||||
-- Funzione per ottenere il Layer di Edit dei bordi corrente
|
||||
function TrimmingVar.GetCurrentEditLayer( nPartId)
|
||||
if nPartId == nil or nPartId == GDB_ID.NULL then return false end
|
||||
local nEditLayerId
|
||||
local nLayerId = EgtGetFirstInGroup( nPartId)
|
||||
while nLayerId do
|
||||
if TrimmingVar.IsEditCurvesLayer( nLayerId) then return nLayerId end
|
||||
nLayerId = EgtGetNext( nLayerId)
|
||||
end
|
||||
return GDB_ID.NULL
|
||||
end
|
||||
|
||||
--======================== Layer Edit Sync Curve =======================
|
||||
|
||||
-- Funzione per creare un Layer di Edit delle curve di Sincornizzazione
|
||||
function TrimmingVar.CreateEditSyncCurvesLayer( nCurrPartId, nCurrLayerId)
|
||||
local nEditSyncLayerId = EgtGroup( nCurrPartId)
|
||||
local bOk = ( nEditSyncLayerId ~= nil)
|
||||
if bOk then
|
||||
bOk = ( EgtSetName( nEditSyncLayerId, LAYER_NAME_SYNC_CURVES) and
|
||||
EgtSetInfo( nEditSyncLayerId, KEY_LAYER_TYPE, KEY_LAYER_SYNC_CURVES) and
|
||||
EgtSetInfo( nEditSyncLayerId, KEY_REF_TRIMMING_LAYER, nCurrLayerId))
|
||||
end
|
||||
if not bOk then
|
||||
EgtErase( nEditSyncLayerId)
|
||||
return GDB_ID.NULL
|
||||
end
|
||||
return nEditSyncLayerId
|
||||
end
|
||||
|
||||
-- Funzione per verificare se un Layer è un Layer di Edit delle curve di Sincronizzazione
|
||||
function TrimmingVar.IsEditSyncCurvesLayer( nId)
|
||||
if nId == nil or nId == GDB_ID.NULL then return false end
|
||||
-- Verifico che la chiave del gruppo sia coerente
|
||||
local sLayerType = EgtGetInfo( nId, KEY_LAYER_TYPE, 's')
|
||||
return ( sLayerType ~= nil and sLayerType == KEY_LAYER_SYNC_CURVES)
|
||||
end
|
||||
|
||||
-- Funzione che ritorna il Layer di Stored delle curve di sincronizzazione corrente
|
||||
function TrimmingVar.GetCurrentEditSyncCurvesLayer( nPartId)
|
||||
if nPartId == nil or nPartId == GDB_ID.NULL then return false end
|
||||
local nEditSyncLayerId
|
||||
local nLayerId = EgtGetFirstInGroup( nPartId)
|
||||
while nLayerId do
|
||||
if TrimmingVar.IsEditSyncCurvesLayer( nLayerId) then return nLayerId end
|
||||
nLayerId = EgtGetNext( nLayerId)
|
||||
end
|
||||
return GDB_ID.NULL
|
||||
end
|
||||
|
||||
--======================== Layer Store Sync Curve =======================
|
||||
|
||||
-- Funzione per creare un Layer di Stored delle curve di Sincronizzazione
|
||||
function TrimmingVar.CreateSyncStoredCurvesLayer( nCurrPartId, nCurrLayerId)
|
||||
local nEditSyncStoredLayerId = EgtGroup( nCurrPartId)
|
||||
local bOk = ( nEditSyncStoredLayerId ~= nil)
|
||||
if bOk then
|
||||
bOk = ( EgtSetName( nEditSyncStoredLayerId, LAYER_NAME_SYNC_STORED_CURVES) and
|
||||
EgtSetInfo( nEditSyncStoredLayerId, KEY_LAYER_TYPE, KEY_LAYER_SYNC_STORE_CURVES) and
|
||||
EgtSetInfo( nEditSyncStoredLayerId, KEY_REF_TRIMMING_LAYER, nCurrLayerId) and
|
||||
EgtSetLevel( nEditSyncStoredLayerId, GDB_LV.SYSTEM))
|
||||
end
|
||||
if not bOk then
|
||||
EgtErase( nEditSyncStoredLayerId)
|
||||
return GDB_ID.NULL
|
||||
end
|
||||
return nEditSyncStoredLayerId
|
||||
end
|
||||
|
||||
-- Funzione per verificare se un Layer è un Layer di Stored delle curve di Sincronizzazione
|
||||
function TrimmingVar.IsSyncStoredCurvesLayer( nId)
|
||||
if nId == nil or nId == GDB_ID.NULL then return false end
|
||||
-- Verifico che la chiave del gruppo sia coerente
|
||||
local sLayerType = EgtGetInfo( nId, KEY_LAYER_TYPE, 's')
|
||||
return ( sLayerType ~= nil and sLayerType == KEY_LAYER_SYNC_STORE_CURVES)
|
||||
end
|
||||
|
||||
-- Funzione che ritorna il Layer di Stored delle curve di sincronizzazione corrente
|
||||
function TrimmingVar.GetCurrentStoredCurvesLayer( nPartId)
|
||||
if nPartId == nil or nPartId == GDB_ID.NULL then return false end
|
||||
local nStoredEditLayerId
|
||||
local nLayerId = EgtGetFirstInGroup( nPartId)
|
||||
while nLayerId do
|
||||
if TrimmingVar.IsSyncStoredCurvesLayer( nLayerId) then return nLayerId end
|
||||
nLayerId = EgtGetNext( nLayerId)
|
||||
end
|
||||
return GDB_ID.NULL
|
||||
end
|
||||
|
||||
--======================== Utility =======================
|
||||
|
||||
-- Funzione per verificare se un Layer è un Layer di Edit o di Stored
|
||||
function TrimmingVar.IsEditOrStoredLayer( nId)
|
||||
if nId == nil or nId == GDB_ID.NULL then return false end
|
||||
return ( TrimmingVar.IsEditCurvesLayer( nId) or
|
||||
TrimmingVar.IsEditSyncCurvesLayer( nId) or
|
||||
TrimmingVar.IsSyncStoredCurvesLayer( nId))
|
||||
end
|
||||
|
||||
-- Funzione per ottenere il Layer di Trimmatura di riferimento dato un generico Layer
|
||||
function TrimmingVar.GetTrimmingLayerRefId( nId)
|
||||
if nId == nil or nId == GDB_ID.NULL then return GDB_ID.NULL end
|
||||
-- Se Layer di Trimmatura allora è lui stesso
|
||||
if TrimmingVar.IsTrimmingLayer( nId) then return nId end
|
||||
if TrimmingVar.IsEditOrStoredLayer( nId) then
|
||||
local nTrimmingLayerRef = EgtGetInfo( nId, KEY_REF_TRIMMING_LAYER, 'i')
|
||||
if nTrimmingLayerRef ~= nil and TrimmingVar.IsTrimmingLayer( nTrimmingLayerRef) then return nTrimmingLayerRef end
|
||||
end
|
||||
return GDB_ID.NULL
|
||||
end
|
||||
|
||||
-- Funzione che dato un Layer di Trimmatura, ritorna tutti i Layer di Edit o Store associati
|
||||
function TrimmingVar.GetAllEditOrStoredLayer( nPartId, nLayerId)
|
||||
local vLayerIds = {}
|
||||
if nLayerId == nil or nLayerId == GDB_ID.NULL then return vLayerIds end
|
||||
if not TrimmingVar.IsTrimmingLayer( nLayerId) then return vLayerIds end
|
||||
local nId = EgtGetFirstGroupInGroup( nPartId)
|
||||
while nId ~= nil do
|
||||
if TrimmingVar.IsEditOrStoredLayer( nId) then
|
||||
local nLayerRefId = TrimmingVar.GetTrimmingLayerRefId( nId)
|
||||
if nLayerRefId ~= nil and nLayerRefId ~= GDB_ID.NULL and nLayerRefId ~= nLayerId then table.insert( vLayerIds, nId) end
|
||||
end
|
||||
nId = EgtGetNextGroup( nId)
|
||||
end
|
||||
return vLayerIds
|
||||
end
|
||||
|
||||
return TrimmingVar
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Version.lua by Egaltech s.r.l. 2026/01/15
|
||||
-- Gestione della versione di Trimming dei Termoformati
|
||||
|
||||
NAME = 'Trimming'
|
||||
VERSION = '3.1a1'
|
||||
MIN_EXE = '3.1a1'
|
||||