DataBeam :
- correzioni e migliorie varie.
This commit is contained in:
+171
-21
@@ -1733,11 +1733,10 @@ local function MakePocket( Proc, nPartId, ptPs, tvtN, nFaceRef, sMchFind, nUseRo
|
||||
local dCollSic = 2 * BD.COLL_SIC
|
||||
-- calcolo il diametro utensile
|
||||
local dDiamTool
|
||||
if nUseRoughTool == 1 and tDimAndRef then
|
||||
dDiamTool = max( 80, min( tDimAndRef[2][1], tDimAndRef[2][2]))
|
||||
elseif tDimAndRef then
|
||||
-- se non uso truciolatore prendo il valore dalle dimensioni minime delle facce
|
||||
dDiamTool = min( tDimAndRef[2][1], tDimAndRef[2][2])
|
||||
local dFaceDiamTool
|
||||
if tDimAndRef then
|
||||
-- prendo il valore dalle dimensioni minime delle facce
|
||||
dFaceDiamTool = min( tDimAndRef[2][1], tDimAndRef[2][2])
|
||||
end
|
||||
-- se ho lavorazione precedente ricalcolo grossolanamente l'elevazione
|
||||
if dPrevFaceElev and dPrevFaceElev > 0 and dAng then
|
||||
@@ -1749,7 +1748,7 @@ local function MakePocket( Proc, nPartId, ptPs, tvtN, nFaceRef, sMchFind, nUseRo
|
||||
if sMasterPocket then
|
||||
sPocketing = sMasterPocket
|
||||
else
|
||||
sPocketing = ML.FindPocketing( sMchFind, dDiamTool, dElev + dCollSic)
|
||||
sPocketing = ML.FindPocketing( sMchFind, dFaceDiamTool, dElev + dCollSic)
|
||||
end
|
||||
if not sPocketing then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'
|
||||
@@ -1766,6 +1765,10 @@ local function MakePocket( Proc, nPartId, ptPs, tvtN, nFaceRef, sMchFind, nUseRo
|
||||
dDiamTool = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
|
||||
end
|
||||
end
|
||||
-- se nome svuotatura non è stato ricalcolato, confronto il diametro utensile utilizzato con il minimo faccia e se non sono compatibili esco
|
||||
if sMasterPocket and dFaceDiamTool and dDiamTool >= dFaceDiamTool then
|
||||
return false, '', sTuuidPk, dDiamTool, dElev
|
||||
end
|
||||
-- inserisco la lavorazione di svuotatura
|
||||
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. 'F' .. tostring( nFaceRef)
|
||||
local nMchFId = EgtAddMachining( sName, sPocketing)
|
||||
@@ -1830,11 +1833,66 @@ local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, tvtN, nBas
|
||||
end
|
||||
-- se angolo tra le facce maggiore di 90, inserisco la contornatura o svuotatura del lato più corto
|
||||
if ( 180 + dAng) > 90.1 then
|
||||
-- se la normale della faccia corta si discosta dalla trave di più di 45° utilizzo la svutatura altrimenti la contornatura
|
||||
if abs( tvtN[2]:getX()) < cos(dAngLimit) then -- se si discosta di più di 30° applico svuotatura
|
||||
-- calcolo l'angolo dalla verticale dall'angolo tra le due facce, perchè la feature potrebbe essere ruotata sulla Z locale della
|
||||
-- faccia principale e quindi la componente X del versore della faccia potrebbe dare un valore non coerente
|
||||
local dDiffFromSqAng = 180 + dAng - 90
|
||||
-- se la normale della faccia corta si discosta dalla trave di più dell'angolo selezionato utilizzo la svutatura altrimenti la contornatura
|
||||
-- if abs( tvtN[2]:getX()) < cos(dAngLimit) then -- se si discosta di più del valore impostato applico svuotatura
|
||||
-- se l'angolo dalla verticale si discosta di più dell'angolo limite impostato, utilizzo la svuotatura
|
||||
if cos( dDiffFromSqAng) < cos(dAngLimit) then -- se si discosta di più del valore impostato applico svuotatura
|
||||
-- applico la svuotatura
|
||||
return MakePocket( Proc, nPartId, ptPs, tvtN, nSideFace, sMchFind, nUseRoughTool, sPocketing, dPrevFaceElev, tDimAndRef, dAng)
|
||||
-- altrimenti contornatura
|
||||
local bOk, sWarn, sTuuidPk, dDiamTool, dElev = MakePocket( Proc, nPartId, ptPs, tvtN, nSideFace, sMchFind, nUseRoughTool, sPocketing, dPrevFaceElev, tDimAndRef, dAng)
|
||||
if not bOk then
|
||||
-- se ho id utensile e diametro è perchè non ha fatto svuotatura perchè la faccia è più stretta del diametro utensile
|
||||
-- e provo ad inserire singola passata di testa
|
||||
if sTuuidPk and dDiamTool then
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Long2Cut', dElev, sTuuidPk)
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- inserisco la lavorazione
|
||||
local sName = 'Prof_' .. ( 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( {{ Proc.Id, nSideFace}})
|
||||
-- imposto uso faccia
|
||||
local nFaceUse = BL.GetNearestOrthoOpposite(tvtN[1])
|
||||
-- aggiusto i parametri
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH')
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, 0)
|
||||
EgtSetMachiningParam( MCH_MP.INVERT, false)
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, 1)
|
||||
-- imposto posizione braccio porta testa
|
||||
if tvtN[2]:getY() < GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
-- imposto elevazione e dichiaro non si generano sfridi per VMill
|
||||
local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 1) .. ';'
|
||||
sNotes = sNotes .. 'VMRS=0;'
|
||||
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes)
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
else
|
||||
return false, sWarn
|
||||
end
|
||||
else
|
||||
return bOk, sWarn
|
||||
end
|
||||
-- altrimenti contornatura di fianco
|
||||
else
|
||||
local bOpenStart = false
|
||||
local bOpenEnd = false
|
||||
@@ -2255,6 +2313,73 @@ local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho, b3Solid, nAdd
|
||||
return nil, 0, nil
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function CheckPocketTool( sMchFind, dDiam, dElev)
|
||||
|
||||
local sPocketing = ML.FindPocketing( sMchFind, dDiam, dElev)
|
||||
if sPocketing then
|
||||
-- recupero i dati dell'utensile
|
||||
local dTDiam = 50
|
||||
if EgtMdbSetCurrMachining( sPocketing) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam
|
||||
return true, dTDiam
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, dElev)
|
||||
local bUSAngle
|
||||
local dDiam = min( dH, dV)
|
||||
local dMaxLenFace = max( dH, dV)
|
||||
-- verifico che diametro utensile prende con la openpocket con la massima dimensione faccia
|
||||
local bUseMaxTool, dMaxDiam = CheckPocketTool( 'OpenPocket', dMaxLenFace, dElev)
|
||||
-- se non trovato utensile esco
|
||||
if not bUseMaxTool then
|
||||
return false
|
||||
end
|
||||
-- Recupero le facce adiacenti alla principale
|
||||
local vAdj = EgtSurfTmFacetAdjacencies( Proc.Id, nFacInd)[1]
|
||||
-- se non ho facce adiacenti esco subito
|
||||
if not vAdj or #vAdj == 0 then
|
||||
return false
|
||||
end
|
||||
-- Cerco le facce adiacenti alla principale con angolo >= 90
|
||||
local nFacAdj
|
||||
local tDistAdj = {}
|
||||
for i = 1, #vAdj do
|
||||
if vAdj[i] >= 0 then
|
||||
local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT)
|
||||
-- se adiacenza e angolo >= 90
|
||||
if bAdj and dAng < 0 and 180 + dAng > 90 - 20 * GEO.EPS_SMALL then
|
||||
table.insert( tDistAdj, dist( ptP1, ptP2))
|
||||
elseif bAdj and dAng < 0 and 180 + dAng < 90 - 20 * GEO.EPS_SMALL then
|
||||
-- se trovato angolo sottosquadra esco subito
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
-- se le facce di adiacenza non corrispondono con quelle della forma esco
|
||||
if ( bIsU and #tDistAdj ~= 2) or ( bIsL and #tDistAdj ~= 1) then
|
||||
return false
|
||||
end
|
||||
local bUseMaxDist = true
|
||||
for i = 1, #tDistAdj do
|
||||
-- se trovo una lunghezza di adiacenza sul lato lungo e diametro minimo inferiore di quello massimo trovato
|
||||
-- setto di non utilizzare il diametro massimo
|
||||
if tDistAdj[i] > dMaxLenFace - 20 * GEO.EPS_SMALL and dDiam < dMaxDiam + 10 * GEO.EPS_SMALL then
|
||||
bUseMaxDist = false
|
||||
end
|
||||
end
|
||||
if bUseMaxDist then
|
||||
return dMaxDiam, 'OpenPocket', 1
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakeByPockets( Proc, nPhase, nRawId, nPartId, nChamfer, dDepthCham, nAddGrpId, sMchFindMaster, b3FacesUsed, b3Solid, bOrthoFacesMaster)
|
||||
|
||||
@@ -2858,8 +2983,11 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part)
|
||||
if not bOk then return false, sErr end
|
||||
end
|
||||
-- recupero la lavorazione
|
||||
local dCollSic = 2 * BD.COLL_SIC
|
||||
if abs( vtN:getX()) > 0.996 or abs( vtN:getY()) > 0.996 or abs( vtN:getZ()) > 0.996 then dCollSic = 0 end
|
||||
local nUseRoughTool = 0
|
||||
local sMchFind = 'Pocket'
|
||||
local dDiam
|
||||
-- se processo 20 vedo se ho truciolatore abilitato
|
||||
if Proc.Prc == 20 then
|
||||
-- se forzato uso truciolatore altrimenti prosegue con fresa più piccola
|
||||
@@ -2867,22 +2995,44 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part)
|
||||
sMchFind = 'OpenPocket'
|
||||
nUseRoughTool = 1
|
||||
end
|
||||
dDiam = min( dH, dV)
|
||||
else
|
||||
-- Se feature lavorata in singolo passo uso fresa (richiesta di Alessandro)
|
||||
if bSingle_part and not bIsL and not bIsU then
|
||||
-- Da disposizini di Alessandro, se feature lavorata in singolo passo uso fresa
|
||||
if bSingle_part then
|
||||
-- disabilito il truciolatore
|
||||
sMchFind = 'Pocket'
|
||||
nUseRoughTool = 0
|
||||
-- altrimenti va lavorata in passo multiplo
|
||||
-- verifico dalla forma se posso prendere utensile più grande
|
||||
if ( Proc.Fct == 3 and bIsU) or ( Proc.Fct == 2 and bIsL) then
|
||||
--verifico dimensioni facce adiacenti
|
||||
dDiam, sMchFind, nUseRoughTool = CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, ( dFacElev + dCollSic))
|
||||
if not dDiam then
|
||||
dDiam = min( dH, dV)
|
||||
sMchFind = 'Pocket'
|
||||
nUseRoughTool = 0
|
||||
end
|
||||
else
|
||||
dDiam = min( dH, dV)
|
||||
end
|
||||
-- altrimenti le lavorata in passo multiplo
|
||||
else
|
||||
-- abilito il truciolatore
|
||||
sMchFind = 'OpenPocket'
|
||||
nUseRoughTool = 1
|
||||
-- verifico dalla forma se posso prendere utensile più grande
|
||||
if ( Proc.Fct == 3 and bIsU) or ( Proc.Fct == 2 and bIsL) or ( Proc.Fct == 1 and not bIsU and not bIsL) then
|
||||
--verifico dimensioni facce adiacenti
|
||||
dDiam, sMchFind, nUseRoughTool = CheckDiamToolByFaces( Proc, nFacInd, dH, dV, bIsU, bIsL, ( dFacElev + dCollSic))
|
||||
if not dDiam then
|
||||
dDiam = min( dH, dV)
|
||||
sMchFind = 'Pocket'
|
||||
nUseRoughTool = 0
|
||||
end
|
||||
else
|
||||
dDiam = min( dH, dV)
|
||||
end
|
||||
end
|
||||
end
|
||||
local dDiam = min( dH, dV)
|
||||
local dCollSic = 2 * BD.COLL_SIC
|
||||
if abs( vtN:getX()) > 0.996 or abs( vtN:getY()) > 0.996 or abs( vtN:getZ()) > 0.996 then dCollSic = 0 end
|
||||
--EgtOutLog( 'Mortise Find Diam =' .. EgtNumToString( dDiam))
|
||||
local sPocketing = ML.FindPocketing( sMchFind, dDiam, dFacElev + dCollSic)
|
||||
-- se non trova una svuotatura adatta
|
||||
@@ -2893,7 +3043,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part)
|
||||
if nChamfer < 2 then
|
||||
return MakeByMill( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac, dH, dV, dFacElev)
|
||||
end
|
||||
-- altrimenti provo con la sega a catena o lama
|
||||
-- altrimenti, in base alla forma, provo con svuotature di fianco o con la sega a catena o lama
|
||||
else
|
||||
local bTryWithBlades = true
|
||||
local nOk, bOk, sStat, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces
|
||||
@@ -2932,10 +3082,11 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part)
|
||||
-- se richiesti antischeggia con lama su U trasversale e smusso non esclusivo
|
||||
-- rimane da gestire: se da eseguire con fresa o se richiesto lama ma impossibile utilizzarla, si utilizza fresa
|
||||
local bMadeASbyBld = false
|
||||
if nChamfer < 2 and EgtGetInfo( Proc.Id, sAntisplintMode, 'i') == 1 and bIsU and
|
||||
if nChamfer < 2 and EgtGetInfo( Proc.Id, sAntisplintMode, 'i') == 1 and ( bIsU or bIsL) and
|
||||
( Proc.Box:getDimY() > b3Raw:getDimY() - 1 or Proc.Box:getDimZ() > b3Raw:getDimZ() - 1) then
|
||||
local nNumFac = EgtIf( bIsU, 2, 1)
|
||||
-- va eseguito sulle facce diverse dalla principale
|
||||
for nFacet = 0, 2 do
|
||||
for nFacet = 0, nNumFac do
|
||||
if nFacet ~= nFacInd then
|
||||
bMadeASbyBld, sWarn = MakeAntiSplintBySaw( Proc, nFacet, vtN, b3Raw)
|
||||
if not bMadeASbyBld then return false, sWarn end
|
||||
@@ -2951,7 +3102,6 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId, bSingle_part)
|
||||
local bOk
|
||||
bOk, sWarn, sTuuidPk, dDiamTool = MakePocket( Proc, nPartId, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dFacElev)
|
||||
if not bOk then return false, sWarn end
|
||||
|
||||
-- se ho più di 3 facce e non di forma ad u oppure ho 3 facce e di forma ad u
|
||||
-- e non sono stati inseriti antischeggia di lama
|
||||
-- controllo se c'è una faccia non ortogonale alla principale e la lavoro con una contornatura o svuotatura
|
||||
@@ -3046,8 +3196,8 @@ local function MakeLongMoreFaces( Proc, nPhase, nRawId, nPartId)
|
||||
local nFct = EgtSurfTmFacetCount( vAddId[i])
|
||||
local AddProc = { Id = vAddId[i], Grp = Proc.Grp, Prc = Proc.Prc, Box = b3Box, Fct = nFct, Flg = Proc.Flg}
|
||||
local bOk, sMyWarn = MakeMoreFaces( AddProc, nPhase, nRawId, nPartId, false)
|
||||
if not bOk then return bOk, sWarn end
|
||||
if not sWarn then sWarn = sMyWarn end
|
||||
if not bOk then return bOk, sWarn end
|
||||
end
|
||||
return true, sWarn
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user