DataBeam :

- aggiunta possibilità di foro su spigolo di L20 da parametro Q
- corretti profili per copia lavorazione di sgrossatura per finitura con nome originale e non effettivo.
This commit is contained in:
Dario Sassi
2020-03-05 17:16:45 +00:00
parent d5cb4e3df8
commit 901ba42814
8 changed files with 294 additions and 165 deletions
+201 -15
View File
@@ -1,4 +1,4 @@
-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/02/26
-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/03/04
-- Gestione calcolo mezzo-legno per Travi
-- 2019/10/08 Agg. gestione OpenPocket.
@@ -21,9 +21,18 @@ local BD = require( 'BeamData')
local ML = require( 'MachiningLib')
-- variabili assegnazione parametri Q
local sForceUseBlade = 'Q01' -- i
local sDepthChamferMill = 'Q04' -- d
local sPreemptiveChamfer = 'Q05' -- i
local sForceUseBlade = '' -- i
local sDepthChamferMill = '' -- d
local sPreemptiveChamfer = '' -- i
local sUseMill = '' -- i
local sUseRoughTool = '' -- i
local sUseRoughToolWithBAxis90 = '' -- i
local sUseRoughToolWithBAxis0 = '' -- i
local sInsertBoreOnCorner = '' -- 1
local sMakeContourWithSmallTool = '' -- i
local sMakeOnlyContourOrFullPocket = '' -- i
local sMakeBySideRoughTool = '' -- i
local sAntisplintMode = '' -- i
---------------------------------------------------------------------
-- Riconoscimento della feature
@@ -39,6 +48,34 @@ function ProcessLapJoint.Identify( Proc)
( Proc.Grp == 4 and Proc.Prc == 39))
end
---------------------------------------------------------------------
local function AssignQValues( Proc)
if ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 16 then
sForceUseBlade = 'Q01' -- i
sDepthChamferMill = 'Q04' -- d
sPreemptiveChamfer = 'Q05' -- i
elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 17 then
sDepthChamferMill = 'Q01' -- d
sPreemptiveChamfer = 'Q02' -- i
elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 20 then
sDepthChamferMill = 'Q01' -- d
sUseMill = 'Q02' -- i
sUseRoughTool = 'Q03' -- i
sUseRoughToolWithBAxis90 = 'Q04' -- i
sUseRoughToolWithBAxis0 = 'Q05' -- i
sInsertBoreOnCorner = 'Q06' -- i
elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 30 then
sMakeContourWithSmallTool = 'Q01' -- i
sMakeOnlyContourOrFullPocket = 'Q02' -- i
sMakeBySideRoughTool = 'Q03' -- i
sAntisplintMode = 'Q06' -- i
sDepthChamferMill = 'Q07' -- d
elseif ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 32 then
sMakeBySideRoughTool = 'Q01' -- i
-- le altre features gestite non hanno parametri Q nei parametri globali
end
end
---------------------------------------------------------------------
local function TestElleShape3( Proc)
@@ -727,6 +764,146 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV
return true
end
---------------------------------------------------------------------
local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiam)
-- Recupero le facce adiacenti alla principale
local sMyWarn
local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1]
local tFacAdj = {}
for i = 1, #vAdj do
if vAdj[i] >= 0 then
for j = 1, #vAdj do
if vAdj[j] >= 0 and j ~= i then
local bInsert = true
for k = 1, #tFacAdj do
local nFace1 = tFacAdj[k][1]
local nFace2 = tFacAdj[k][2]
if ( nFace1 == vAdj[i] and nFace2 == vAdj[j]) or
( nFace1 == vAdj[j] and nFace2 == vAdj[i]) then
bInsert = false
end
end
if bInsert then
local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, vAdj[i], vAdj[j], GDB_ID.ROOT)
if ptP1 and ptP2 then
local dLen = dist( ptP1, ptP2)
table.insert( tFacAdj, { vAdj[i], vAdj[j], dLen, ptP1, ptP2})
end
end
end
end
end
end
-- tra le linee prendo quella più lunga
local dMaxLen = 0
local nIdLine
for i = 1, #tFacAdj do
if tFacAdj[i][3] > dMaxLen then
nIdLine = i
dMaxLen = tFacAdj[i][3]
end
end
-- trovo il punto sulla superfice di riferimento
local _, ptLocP1, ptLocP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, tFacAdj[nIdLine][1], GDB_ID.ROOT)
local nIdIniPoint
local nIdEndPoint
if ptLocP1 and ptLocP2 then
if ( dist( ptLocP1, tFacAdj[nIdLine][4]) < GEO.EPS_SMALL) or ( dist( ptLocP2, tFacAdj[nIdLine][4]) < GEO.EPS_SMALL) then
nIdEndPoint = 4
nIdIniPoint = 5
elseif ( dist( ptLocP1, tFacAdj[nIdLine][5]) < GEO.EPS_SMALL) or ( dist( ptLocP2, tFacAdj[nIdLine][5]) < GEO.EPS_SMALL) then
nIdEndPoint = 5
nIdIniPoint = 4
end
end
-- inserisco foro
if nIdIniPoint and nIdEndPoint then
-- versore direzione
local vtExtr = tFacAdj[nIdLine][nIdIniPoint] - tFacAdj[nIdLine][nIdEndPoint]
vtExtr:normalize()
-- se foratura da sotto salto la lavorazione
if vtExtr:getZ() < BD.DRILL_VZ_MIN then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' drilling from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- recupero la lavorazione
local sDrilling, nType = ML.FindDrilling( dDiam)
if not sDrilling then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' drilling not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dMaxDepth = 20
local dDiamTool = 20
local bIsDrilling
if EgtMdbSetCurrMachining( sDrilling) then
bIsDrilling = ( EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) == MCH_MY.DRILLING)
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
if bIsDrilling then
dMaxDepth = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth
else
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
end
dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
end
end
-- setto griglia
EgtSetGridFrame( Frame3d( tFacAdj[nIdLine][nIdIniPoint], vtExtr))
-- creo geometria
local AuxId = EgtCircle( nAddGrpId, {0,0,0}, EgtIf( bIsDrilling, dDiamTool/2, ( dDiamTool/2) + 0.1), GDB_RT.GRID)
EgtModifyCurveThickness( AuxId, -dMaxLen)
-- riporto la griglia a globale
EgtSetGridFrame()
-- inserisco la lavorazione
local sName = 'Drill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchId = EgtAddMachining( sName, sDrilling)
if not nMchId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sDrilling
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ AuxId, -1}})
-- imposto posizione braccio porta testa
local nSCC = MCH_SCC.ADIR_YM
if vtExtr:getY() > 100 * GEO.EPS_ZERO then
nSCC = MCH_SCC.ADIR_YP
end
EgtSetMachiningParam( MCH_MP.SCC, nSCC)
-- aggiusto l'affondamento
local dDepth = dMaxLen
if dDepth > dMaxDepth + 10 * GEO.EPS_SMALL then
sMyWarn = 'Warning in drill : depth (' .. EgtNumToString( dDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')'
dDepth = dMaxDepth
EgtOutLog( sMyWarn .. ' (process ' .. tostring( Proc.Id) .. ')')
end
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth)
-- Note utente con dichiarazione nessuna generazione sfridi per Vmill
local sUserNotes = 'VMRS=0;'
-- aggiungo alle note massima elevazione (coincide con affondamento)
sUserNotes = sUserNotes .. 'MaxElev=' .. EgtNumToString( dDepth, 1) .. ';'
EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes)
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
else
local _, sWarn = EgtGetMachMgrWarning( 0)
if EgtIsMachiningEmpty() then
EgtSetOperationMode( nMchFId, false)
return false, sWarn
else
return true, ( sMyWarn or sWarn)
end
end
end
return true, sMyWarn
end
---------------------------------------------------------------------
local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dElev, bForceUseBlade)
-- Recupero le facce adiacenti alla principale
@@ -941,7 +1118,7 @@ local function MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw)
end
---------------------------------------------------------------------
local function VerifyQParam( Proc, nRawId, bMakeVertCham, sDephtCham, sOnlyCham, sUseBlade)
local function EvaluateQParam( Proc, nRawId, bMakeVertCham, sDephtCham, sOnlyCham, sUseBlade)
local nChamfer = 0
local bForceUseBlade = false
-- verifico che lo smusso sia richiesto
@@ -1008,7 +1185,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
end
-- verifico se sono presenti i parametri Q per la profondità smusso e
-- per eseguire in esclusiva solo lo smusso
local nChamfer, dDepthCham, sChamfer, bForceUseBlade = VerifyQParam( Proc, nRawId, false, sDepthChamferMill, sPreemptiveChamfer, sForceUseBlade)
local nChamfer, dDepthCham, sChamfer, bForceUseBlade = EvaluateQParam( Proc, nRawId, false, sDepthChamferMill, sPreemptiveChamfer, sForceUseBlade)
-- se non posso lavorare la feature perché condizionata dall'esecuzione del solo chamfer
-- genero errore e non faccio nulla
if nChamfer < 0 then
@@ -1281,7 +1458,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
local bMakeBySideMill, bHead, sMilling, dMaxMat = VerifyIfByBHSideMill( Proc)
if bMakeBySideMill and ( dMaxMat <= dV) then
-- se smusso non è esclusivo
-- if nChamfer < 2 then
if nChamfer < 2 then
-- inserisco la lavorazione di fresatura
local sName = 'BHMill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sMilling)
@@ -1310,11 +1487,11 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
-- end
end
-- altrimenti lavoro con svuotatura
else
-- se smusso non è esclusivo
-- if nChamfer < 2 then
if nChamfer < 2 then
-- se orientata verso il basso, verifico l'alternativa
if vtN:getZ() < BD.NZ_MINA and nFacInd2 then
ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT)
@@ -1365,7 +1542,8 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
end
end
-- se richiesti antischeggia con lama su U trasversale
if EgtGetInfo( Proc.Id, 'Q06', 'i') == 1 and bIsU and
-- rimane da gestire: se da eseguire con fresa o se richiesto lama ma impossibile utilizzarla, si utilizza fresa
if EgtGetInfo( Proc.Id, sAntisplintMode, 'i') == 1 and bIsU and
( Proc.Box:getDimY() > b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > b3Raw:getDimZ() - 1) then
-- va eseguito sulle facce diverse dalla principale
for nFacet = 0, 2 do
@@ -1375,12 +1553,14 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
end
end
end
-- recupero i dati dell'utensile
-- recupero i dati dell'utensile: utilizzo il diametro utensile per il foro opzionale
local dMaxDepth = 0
local dDiamTool = 20
if EgtMdbSetCurrMachining( sPocketing) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth)
dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
end
end
-- inserisco la lavorazione di svuotatura
@@ -1426,7 +1606,12 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
return false, sErr
end
end
-- end
-- se abilitato dal parametro Q inserisco foro sullo spigolo
if EgtGetInfo( Proc.Id, sInsertBoreOnCorner, 'i') == 1 then
local bOk, sWarn = MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiamTool)
if not bOk then return false, sWarn end
end
end
end
end
@@ -1484,7 +1669,8 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
local MAX_MILL_LIN = 80
-- recupero l'ingombro del grezzo di appartenenza
local b3Raw = EgtGetRawPartBBox( nRawId)
-- in base al tipo di feature attribuisco il significato dei parametri Q
AssignQValues( Proc)
-- se lunghezza richiede spezzatura
if Proc.Box:getDimX() > BD.LONGCUT_MAXLEN then
-- una faccia
@@ -1515,7 +1701,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
else
-- una faccia
if Proc.Fct == 1 then
local bForcedBlade = ( Proc.Prc == 20 and EgtGetInfo( Proc.Id, 'Q03', 'i') ~= 1 )
local bForcedBlade = EgtGetInfo( Proc.Id, sUseRoughTool, 'i') ~= 1
-- se piccola, con fresa
if not bForcedBlade and ( Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN)) then
return MakeOneFaceByMill( Proc, nPhase, nRawId, nPartId)
@@ -1527,7 +1713,7 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
elseif Proc.Fct == 2 then
-- determino l'angolo tra le facce
local bAdj, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
local bForcedBlade = ( Proc.Prc == 20 and EgtGetInfo( Proc.Id, 'Q03', 'i') ~= 1 )
local bForcedBlade = EgtGetInfo( Proc.Id, sUseRoughTool, 'i') ~= 1
-- se ortogonali e piccole, con fresa
if not bForcedBlade and bAdj and abs( dAng + 90) < 1 and
( Proc.Box:getDimX() < MAX_MILL_LIN and ( Proc.Box:getDimZ() < MAX_MILL_LIN or Proc.Box:getDimY() < MAX_MILL_LIN)) then