DataBeam :
- modifiche a DiceCut per uso generale di dNzLimDwnUp = BL.GetNzLimDownUp... - modifiche a fori per angolo limite da BeamData e diametro portautensile da utensile - migliorie a profili - aggiunta possibilità di pulitura spigolo su L020.
This commit is contained in:
+204
-17
@@ -1,4 +1,4 @@
|
||||
-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/03/04
|
||||
-- ProcessLapJoint.lua by Egaltech s.r.l. 2020/03/06
|
||||
-- Gestione calcolo mezzo-legno per Travi
|
||||
-- 2019/10/08 Agg. gestione OpenPocket.
|
||||
|
||||
@@ -765,9 +765,8 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiam)
|
||||
local function ChoseCorner( Proc, nFacInd)
|
||||
-- Recupero le facce adiacenti alla principale
|
||||
local sMyWarn
|
||||
local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1]
|
||||
local tFacAdj = {}
|
||||
for i = 1, #vAdj do
|
||||
@@ -803,6 +802,180 @@ local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd,
|
||||
dMaxLen = tFacAdj[i][3]
|
||||
end
|
||||
end
|
||||
|
||||
return dMaxLen, nIdLine, tFacAdj
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiam)
|
||||
|
||||
local sMyWarn
|
||||
local pAuxId = {}
|
||||
local nAuxId
|
||||
local AuxId
|
||||
local ptApPoint
|
||||
local dLenTrimExt
|
||||
local sMilling
|
||||
local dMaxDepth = 0
|
||||
|
||||
-- ottengo l'angolo di riferimento dove applicare il percorso di pulitura
|
||||
local dMaxLen, nIdLine, tFacAdj = ChoseCorner( Proc, nFacInd)
|
||||
-- prendo il primo versore
|
||||
local _, vtN1 = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
|
||||
local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, tFacAdj[nIdLine][1], GDB_ID.ROOT)
|
||||
local _, vtN3 = EgtSurfTmFacetCenter( Proc.Id, tFacAdj[nIdLine][2], GDB_ID.ROOT)
|
||||
|
||||
if not tFacAdj then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' geometry not found for clean corner'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
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
|
||||
-- versore direzione
|
||||
local vtExtr = tFacAdj[nIdLine][nIdIniPoint] - tFacAdj[nIdLine][nIdEndPoint]
|
||||
vtExtr:normalize()
|
||||
-- inserisco le prime tre linee
|
||||
if nIdIniPoint and nIdEndPoint then
|
||||
-- se fresatura da sotto salto la lavorazione
|
||||
if vtExtr:getZ() < BD.DRILL_VZ_MIN then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' clean corner milling from bottom impossible'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErrLX
|
||||
end
|
||||
-- sommo i tre versori per avre una direzione media
|
||||
vtExtr = vtN1 + vtN2 + vtN3
|
||||
vtExtr:normalize()
|
||||
-- recupero la lavorazione
|
||||
sMilling = ML.FindMilling( 'CleanCorner', (dDiam * 0.6))
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' clean corner milling not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero i dati dell'utensile ( temporaneo, per compensare errore nella lavorazione)
|
||||
if EgtMdbSetCurrMachining( sMilling) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
dMaxDepth = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMaxDepth
|
||||
end
|
||||
nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdIniPoint], tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB)
|
||||
table.insert( pAuxId, nAuxId)
|
||||
-- se il punto finale corrisponde con il punto utilizzato in precedenza, uso l'altro
|
||||
if dist( tFacAdj[nIdLine][nIdEndPoint], ptLocP1) < 10 * GEO.EPS_SMALL then
|
||||
ptApPoint = ptLocP2
|
||||
else
|
||||
ptApPoint = ptLocP1
|
||||
end
|
||||
nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], ptApPoint, GDB_RT.GLOB)
|
||||
dLenTrimExt = dist( tFacAdj[nIdLine][nIdEndPoint], ptApPoint) - (( dDiam/2) + 2)
|
||||
-- se la distanza dei due punti della linea è maggiore dal raggio fresa + delta, trimmo al raggio fresa + delta
|
||||
if dLenTrimExt > 10 * GEO.EPS_SMALL then
|
||||
EgtTrimExtendCurveByLen( nAuxId , -dLenTrimExt, ptApPoint , GDB_RT.GLOB)
|
||||
-- prendo il nuovo punto finale
|
||||
ptApPoint = EgtEP( nAuxId, GDB_RT.GLOB)
|
||||
end
|
||||
table.insert( pAuxId, nAuxId)
|
||||
-- creo linea di ritorno
|
||||
nAuxId = EgtLine( nAddGrpId, ptApPoint, tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB)
|
||||
table.insert( pAuxId, nAuxId)
|
||||
end
|
||||
-- inserisco le ultime tre linee
|
||||
-- trovo il secondo punto sulla superfice di riferimento
|
||||
_, ptLocP1, ptLocP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, tFacAdj[nIdLine][2], GDB_ID.ROOT)
|
||||
if ptLocP1 and ptLocP2 then
|
||||
-- se il punto finale corrisponde con il punto utilizzato in precedenza, uso l'altro
|
||||
if dist( tFacAdj[nIdLine][nIdEndPoint], ptLocP1) < 10 * GEO.EPS_SMALL then
|
||||
ptApPoint = ptLocP2
|
||||
else
|
||||
ptApPoint = ptLocP1
|
||||
end
|
||||
nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], ptApPoint, GDB_RT.GLOB)
|
||||
dLenTrimExt = dist( tFacAdj[nIdLine][nIdEndPoint], ptApPoint) - (( dDiam/2) + 2)
|
||||
-- se la distanza dei due punti della linea è maggiore dal raggio fresa + delta, trimmo al raggio fresa + delta
|
||||
if dLenTrimExt > 10 * GEO.EPS_SMALL then
|
||||
EgtTrimExtendCurveByLen( nAuxId , -dLenTrimExt, ptApPoint , GDB_RT.GLOB)
|
||||
-- prendo il nuovo punto finale
|
||||
ptApPoint = EgtEP( nAuxId, GDB_RT.GLOB)
|
||||
end
|
||||
table.insert( pAuxId, nAuxId)
|
||||
-- creo linea di ritorno
|
||||
nAuxId = EgtLine( nAddGrpId, ptApPoint, tFacAdj[nIdLine][nIdEndPoint], GDB_RT.GLOB)
|
||||
table.insert( pAuxId, nAuxId)
|
||||
-- ultima linea di risalita
|
||||
nAuxId = EgtLine( nAddGrpId, tFacAdj[nIdLine][nIdEndPoint], tFacAdj[nIdLine][nIdIniPoint], GDB_RT.GLOB)
|
||||
table.insert( pAuxId, nAuxId)
|
||||
end
|
||||
-- trasformo in percorso
|
||||
if #pAuxId > 0 then
|
||||
AuxId = EgtCurveCompo( nAddGrpId, pAuxId, true)
|
||||
end
|
||||
-- se non c'é il percorso do errore
|
||||
if not AuxId then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' impossible make clean corner path'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- modifico versore direzione
|
||||
EgtModifyCurveExtrusion( AuxId, vtExtr, GDB_RT.GLOB)
|
||||
-- inserisco la lavorazione
|
||||
local sName = 'Clean_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMchId = EgtAddMachining( sName, sMilling)
|
||||
if not nMchId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
|
||||
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)
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, 0)
|
||||
-- Note utente con dichiarazione nessuna generazione sfridi per Vmill
|
||||
local sUserNotes = 'VMRS=0;'
|
||||
-- aggiungo alle note massima elevazione
|
||||
sUserNotes = sUserNotes .. 'MaxElev=' .. EgtNumToString( dMaxDepth, 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
|
||||
|
||||
return true, sMyWarn
|
||||
end
|
||||
---------------------------------------------------------------------
|
||||
local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiam)
|
||||
local sMyWarn
|
||||
-- ottengo l'angolo dove applicare il foro
|
||||
local dMaxLen, nIdLine, tFacAdj = ChoseCorner( Proc, nFacInd)
|
||||
if not tFacAdj then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' geometry not found for drilling'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- trovo il punto sulla superfice di riferimento
|
||||
local _, ptLocP1, ptLocP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, tFacAdj[nIdLine][1], GDB_ID.ROOT)
|
||||
local nIdIniPoint
|
||||
@@ -820,7 +993,7 @@ local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd,
|
||||
if nIdIniPoint and nIdEndPoint then
|
||||
-- versore direzione
|
||||
local vtExtr = tFacAdj[nIdLine][nIdIniPoint] - tFacAdj[nIdLine][nIdEndPoint]
|
||||
vtExtr:normalize()
|
||||
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'
|
||||
@@ -837,6 +1010,7 @@ local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd,
|
||||
-- recupero i dati dell'utensile
|
||||
local dMaxDepth = 20
|
||||
local dDiamTool = 20
|
||||
local dDiamTh = 35
|
||||
local bIsDrilling
|
||||
if EgtMdbSetCurrMachining( sDrilling) then
|
||||
bIsDrilling = ( EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) == MCH_MY.DRILLING)
|
||||
@@ -848,8 +1022,17 @@ local function MakeDrillOnCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd,
|
||||
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
|
||||
end
|
||||
dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
||||
dDiamTh = EgtTdbGetCurrToolThDiam()
|
||||
end
|
||||
end
|
||||
-- se foro inclinato, limito il massimo affondamento
|
||||
local CosB = abs( vtExtr:getX())
|
||||
if CosB < BD.DRILL_VX_MAX then
|
||||
local TgA = CosB / sqrt( 1 - CosB * CosB)
|
||||
dMaxDepth = dMaxDepth - dDiamTh / 2 * TgA
|
||||
else
|
||||
dMaxDepth = 0
|
||||
end
|
||||
-- setto griglia
|
||||
EgtSetGridFrame( Frame3d( tFacAdj[nIdLine][nIdIniPoint], vtExtr))
|
||||
-- creo geometria
|
||||
@@ -1121,6 +1304,7 @@ end
|
||||
local function EvaluateQParam( Proc, nRawId, bMakeVertCham, sDephtCham, sOnlyCham, sUseBlade)
|
||||
local nChamfer = 0
|
||||
local bForceUseBlade = false
|
||||
local sErr
|
||||
-- verifico che lo smusso sia richiesto
|
||||
local dDepth = EgtGetInfo( Proc.Id, sDephtCham, 'd') or 0
|
||||
if dDepth > 0 then
|
||||
@@ -1132,7 +1316,7 @@ local function EvaluateQParam( Proc, nRawId, bMakeVertCham, sDephtCham, sOnlyCha
|
||||
nChamfer = nChamfer + 1
|
||||
-- altrimenti se non ho l'affondamento esco
|
||||
else
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' no chamfer depth'
|
||||
sErr = 'Error on process ' .. tostring( Proc.Id) .. ' no chamfer depth'
|
||||
EgtOutLog( sErr)
|
||||
return -1, dDepth, sErr
|
||||
end
|
||||
@@ -1141,15 +1325,8 @@ local function EvaluateQParam( Proc, nRawId, bMakeVertCham, sDephtCham, sOnlyCha
|
||||
if EgtGetInfo( Proc.Id, sUseBlade, 'i') == 1 then
|
||||
bForceUseBlade = true
|
||||
end
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Mark')
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' chamfer not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return -1, 0, sErr
|
||||
end
|
||||
|
||||
return nChamfer, dDepth, sMilling, bForceUseBlade
|
||||
return nChamfer, dDepth, sErr, bForceUseBlade
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -1185,17 +1362,24 @@ 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 = EvaluateQParam( Proc, nRawId, false, sDepthChamferMill, sPreemptiveChamfer, sForceUseBlade)
|
||||
local nChamfer, dDepthCham, sErrCham, 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
|
||||
return false, sChamfer
|
||||
return false, sErrCham
|
||||
end
|
||||
if bClosedOrthoFaces then -- se tunnel provo a vedere se è possibile lavorarlo di con la svuotatura o con la sega catena
|
||||
-- ottengo le dimensioni del tunnel
|
||||
local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt = GetTunnelDimension( Proc, nPartId)
|
||||
-- se devo inserire il chamfer
|
||||
if nChamfer > 0 then
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Mark')
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' chamfer not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- ottengo le curve di contorno libero
|
||||
local nAuxId1, nNumIdAux = EgtExtractSurfTmLoops( Proc.Id, nAddGrpId)
|
||||
if nAuxId1 then
|
||||
@@ -1209,9 +1393,9 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
|
||||
if vtExtr:getZ() > -0.707 and ( abs(vtOrtho:getX()) > 0.99 or abs(vtOrtho:getY()) > 0.99 or abs(vtOrtho:getZ()) > 0.99) then
|
||||
-- inserisco la lavorazione
|
||||
local sNameCh = 'Cham_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i)
|
||||
local nMchId = EgtAddMachining( sNameCh, sChamfer)
|
||||
local nMchId = EgtAddMachining( sNameCh, sMilling)
|
||||
if not nMchId then
|
||||
local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sChamfer
|
||||
local sErr = 'Error adding machining ' .. sNameCh .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
@@ -1610,6 +1794,9 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
|
||||
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
|
||||
elseif EgtGetInfo( Proc.Id, sInsertBoreOnCorner, 'i') == 2 then
|
||||
local bOk, sWarn = MakeCleanCorner( Proc, nPhase, nRawId, nPartId, b3Raw, nFacInd, nAddGrpId, dDiamTool)
|
||||
if not bOk then return false, sWarn end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user