DataBeam :
- aggiunte funzioni sperimentali per ScarfJoint (dardo di giove) - in Mortise aggiunta gestione caso passante.
This commit is contained in:
+154
-14
@@ -23,16 +23,34 @@ function ProcessMortise.Identify( Proc)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Classificazione della feature
|
||||
-- Classificazione della feature: decide se la feature è in una posizione che per lavorala
|
||||
-- deve essere ribaltata o no
|
||||
function ProcessMortise.Classify( Proc)
|
||||
-- recupero e verifico il percorso supplementare
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
-- recupero versore estrusione della curva supplementare e non più della superficie
|
||||
-- perché quest'ultima potrebbe non avere il fondo e dare quindi un risultato non corretto
|
||||
local vtExtr = EgtCurveExtrusion( AuxId or GDB_ID.NULL, GDB_ID.ROOT)
|
||||
-- recupero i dati della faccia di fondo
|
||||
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
|
||||
-- verifico sia una superficie
|
||||
if not vtExtr then
|
||||
return false
|
||||
end
|
||||
if not vtN then
|
||||
return false
|
||||
end
|
||||
-- verifico se la mortasa è lavorabile solo da sotto
|
||||
local bDown = ( vtN:getZ() < - 0.1)
|
||||
local bDown
|
||||
-- Confronto le 2 direzioni Z dei versori
|
||||
-- se differiscono allora la faccetta 0 della superficie non è il fondo della mortasa+
|
||||
-- e quindi la mortasa è passante
|
||||
if abs( vtExtr:getZ() - vtN:getZ()) > GEO.EPS_SMALL then
|
||||
bDown = false
|
||||
else -- se è chiusa
|
||||
-- verifico se la mortasa è lavorabile solo da sotto
|
||||
bDown = ( vtN:getZ() < - 0.1)
|
||||
end
|
||||
return true, bDown
|
||||
end
|
||||
|
||||
@@ -41,7 +59,11 @@ end
|
||||
function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
|
||||
-- recupero e verifico l'entità curva
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
local bForceOneSide
|
||||
local bRevertSide
|
||||
if AuxId then
|
||||
AuxId = AuxId + Proc.Id
|
||||
end
|
||||
if not AuxId or ( EgtGetType( AuxId) & 256) == 0 then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry'
|
||||
EgtOutLog( sErr)
|
||||
@@ -53,17 +75,65 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
|
||||
EgtCloseCurveCompo( AuxId)
|
||||
EgtSetInfo( AuxId, 'OPEN', nCount)
|
||||
end
|
||||
-- recupero versore estrusione della curva supplementare e confronto la direzione Z
|
||||
-- del versore della componente Z della superficie
|
||||
local vtExtr = EgtCurveExtrusion( AuxId, GDB_ID.ROOT)
|
||||
-- recupero i dati del bottom
|
||||
local frMor, dL, dW = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0, GDB_ID.ROOT)
|
||||
local ptC = frMor:getOrigin()
|
||||
local vtN = frMor:getVersZ()
|
||||
EgtOutLog( 'ptC=' .. tostring( ptC) ..' vtN=' .. tostring( vtN), 3)
|
||||
-- verifico che la mortasa non sia orientata verso il basso (limite -5 deg)
|
||||
if vtN:getZ() < - 0.1 then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Mortise from bottom impossible'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
local bNotExistBtm
|
||||
-- Confronto le 2 direzioni Z dei versori
|
||||
-- se differiscono allora la faccetta 0 della superficie non è il fondo della mortasa+
|
||||
-- e quindi la mortasa è passante
|
||||
if abs( vtExtr:getZ() - vtN:getZ()) > GEO.EPS_SMALL then
|
||||
-- creo superficie chiusa
|
||||
local nFlat = EgtSurfTmByFlatContour( EgtGetParent(AuxId), AuxId, 0.02)
|
||||
if nFlat then
|
||||
frMor, dL, dW = EgtSurfTmFacetMinAreaRectangle( nFlat, 0, GDB_ID.ROOT)
|
||||
ptC = frMor:getOrigin()
|
||||
vtN = frMor:getVersZ()
|
||||
-- verifico se copiare la geometria lungo l'asse Z
|
||||
local b3Aux = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frMor)
|
||||
local bxMax = b3Aux:getMax()
|
||||
local b3Mor = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frMor)
|
||||
local bxMin = b3Mor:getMin()
|
||||
local dMove = bxMin:getZ()-bxMax:getZ()
|
||||
-- se il percorso ausiliario è esterno al grezzo, lo riavvicino
|
||||
if abs( dMove) > GEO.EPS_SMALL then
|
||||
AuxId = EgtCopyGlob( AuxId, BL.GetAddGroup(nPartId))
|
||||
EgtMove( AuxId, Vector3d(0,0,-dMove))
|
||||
EgtMove( nFlat, Vector3d(0,0,-dMove))
|
||||
frMor, dL, dW = EgtSurfTmFacetMinAreaRectangle( nFlat, 0, GDB_ID.ROOT)
|
||||
ptC = frMor:getOrigin()
|
||||
vtN = frMor:getVersZ()
|
||||
end
|
||||
-- cancello le prove del misfatto (superficie piana)
|
||||
EgtErase(nFlat)
|
||||
-- setto il flag che indica che non c'è il fondo
|
||||
bNotExistBtm = true
|
||||
end
|
||||
end
|
||||
-- scrivo info nel log
|
||||
EgtOutLog( 'ptC=' .. tostring( ptC) ..' vtN=' .. tostring( vtN), 3)
|
||||
if not bNotExistBtm then
|
||||
-- verifico che la mortasa non sia orientata verso il basso (limite -5 deg)
|
||||
if vtN:getZ() < - 0.1 then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Mortise from bottom impossible'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
else -- se mortasa passante
|
||||
-- determino se la mortasa da lavorare sul lato opposto sia di angolo inferiore a quello consentito
|
||||
if abs(vtN:getZ()) > 0.1 then
|
||||
bForceOneSide = true
|
||||
end
|
||||
-- determino se è meglio lavorare la mortasa nel lato opposto
|
||||
if vtN:getZ() < -GEO.EPS_SMALL then
|
||||
bRevertSide = true
|
||||
end
|
||||
end
|
||||
|
||||
-- determino altezza della mortasa
|
||||
local b3Mor = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frMor)
|
||||
local dMorH = b3Mor:getDimZ()
|
||||
@@ -97,21 +167,48 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- verifico se invertire versore estrusione geometria
|
||||
if bRevertSide then
|
||||
EgtModifyCurveExtrusion( AuxId, -vtExtr, GDB_ID.ROOT)
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtN:getY() < GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
if bRevertSide then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
end
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
if bRevertSide then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
end
|
||||
local sWarn
|
||||
local nDepthMin
|
||||
-- se la mortasa è passante e non è forzata a un solo lato, riduco l'affondamento a metà profondità
|
||||
if bNotExistBtm and not bForceOneSide then
|
||||
dMorH = dMorH * 0.5
|
||||
end
|
||||
-- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente
|
||||
local sWarn
|
||||
if dMorH > dMaxDepth + 10 * GEO.EPS_SMALL then
|
||||
sWarn = 'Warning in mortise : elevation (' .. EgtNumToString( dMorH,1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth,1) .. ')'
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth - dMorH)
|
||||
if not bRevertSide then -- se non ho invertito la direzione di estrusione
|
||||
nDepthMin = dMaxDepth - EgtIf( bNotExistBtm and not bForceOneSide, dMorH*2, dMorH)
|
||||
else
|
||||
nDepthMin = dMaxDepth
|
||||
end
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, nDepthMin)
|
||||
dMorH = dMaxDepth
|
||||
EgtOutLog( sWarn .. ' (process ' .. tostring( Proc.Id) .. ')')
|
||||
else
|
||||
if bNotExistBtm and not bForceOneSide then -- se mortasa passante setto metà profondità
|
||||
nDepthMin = -dMorH
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, nDepthMin)
|
||||
end
|
||||
end
|
||||
-- imposto elevazione
|
||||
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dMorH, 1) .. ';')
|
||||
@@ -121,6 +218,49 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
-- ESPERIMENTO:
|
||||
-- se non c'è il fondo e la lavorazione non ha lavorato tutta la superficie per limite altezza utensile
|
||||
-- inserisco una ulteriore lavorazione contraria
|
||||
if bNotExistBtm and not bForceOneSide and nDepthMin and abs(nDepthMin) > 0 then
|
||||
-- inserisco la lavorazione di svuotatura opposta
|
||||
sName = 'Mort_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_Oppo'
|
||||
nMchFId = EgtAddMachining( sName, sPocketing)
|
||||
if not nMchFId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- faccio la copia e la metto nel layer dedicato alle geometrie aggiunte
|
||||
local AuxId_oppo = EgtCopyGlob( AuxId, BL.GetAddGroup(nPartId))
|
||||
-- inverto la direzione estrusione di questa
|
||||
EgtModifyCurveExtrusion( AuxId_oppo, - vtExtr, GDB_ID.ROOT)
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId_oppo, -1}})
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtN:getY() < GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
end
|
||||
-- se altezza mortasa differente da altezza massima lavorabile
|
||||
if abs(dMorH - dMaxDepth) > GEO.EPS_SMALL then
|
||||
nDepthMin = -dMorH
|
||||
else -- se sono uguali setto
|
||||
nDepthMin = -(dMorH - BD.CUT_EXTRA)
|
||||
end
|
||||
|
||||
-- setto profondità
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, -nDepthMin+BD.CUT_EXTRA)
|
||||
-- imposto elevazione
|
||||
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( (-nDepthMin+BD.CUT_EXTRA), 1) .. ';')
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
|
||||
return true, sWarn
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user