DataBeam :
- correzioni varie - gestione scassi a C passanti e grandi con fresature sui due lati - miglioria a contorni liberi chiusi per posizione di attacco - correzioni a feature 3/4-020-X caso particolare Olaf.
This commit is contained in:
+34
-1
@@ -122,6 +122,30 @@ function BeamLib.PutStartOnTop( nCrvId)
|
||||
return true
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function BeamLib.PutStartOnLonger( nCrvId)
|
||||
-- verifico che la curva sia chiusa
|
||||
if not EgtCurveIsClosed( nCrvId) then return false end
|
||||
-- cerco l'entità più lunga e la imposto come inizio
|
||||
local dUmax = 0
|
||||
local dLmax = - GEO.INFINITO
|
||||
local dUi, dUf = EgtCurveDomain( nCrvId)
|
||||
for dU = dUi, dUf - 1 do
|
||||
local ptP1 = EgtUP( nCrvId, dU, GDB_ID.ROOT)
|
||||
local ptP2 = EgtUP( nCrvId, dU + 0.5, GDB_ID.ROOT)
|
||||
local ptP3 = EgtUP( nCrvId, dU + 1.0, GDB_ID.ROOT)
|
||||
local dL = dist( ptP1, ptP2) + dist( ptP2, ptP3)
|
||||
if dL > dLmax + GEO.EPS_SMALL then
|
||||
dLmax = dL
|
||||
dUmax = dU
|
||||
end
|
||||
end
|
||||
if abs( dUmax - dUi) > GEO.EPS_ZERO then
|
||||
EgtChangeClosedCurveStart( nCrvId, dUmax)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function BeamLib.PutStartNearestToEdge( nCrvId, b3Raw)
|
||||
-- verifico che la curva sia chiusa
|
||||
@@ -319,7 +343,7 @@ function BeamLib.GetBoxFaceNorm( b3Box, ptP, vtV)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId)
|
||||
function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId, bCompare3Fc)
|
||||
-- recupero il numero di facce
|
||||
local nFacCnt = EgtSurfTmFacetCount( nSurfId)
|
||||
-- recupero le normali delle facce
|
||||
@@ -371,6 +395,15 @@ function BeamLib.GetFaceWithMostAdj( nSurfId, nPartId)
|
||||
end
|
||||
end
|
||||
end
|
||||
if bCompare3Fc and nFacCnt == 3 then
|
||||
if vAdj[1] == 2 and vAdj[2] == 1 and vAdj[3] == 1 then
|
||||
if vOrtho[1] == true and vOrtho[2] == true and vOrtho[3] == true then
|
||||
return -1, GEO.INFINITO, true
|
||||
else
|
||||
return -1, GEO.INFINITO
|
||||
end
|
||||
end
|
||||
end
|
||||
-- recupero le facce non in sottosquadra e con il maggior numero di adiacenze
|
||||
local nFacInd = {}
|
||||
local nMaxAdj = -1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-- ProcessCut.lua by Egaltech s.r.l. 2020/02/29
|
||||
-- ProcessCut.lua by Egaltech s.r.l. 2020/03/16
|
||||
-- Gestione calcolo singoli tagli di lama per Travi
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
@@ -176,6 +176,8 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead, bFromBottom)
|
||||
else
|
||||
vtOrthoO = -Y_AX()
|
||||
end
|
||||
-- tagli molto di lato e inclinati sono permessi fino a -45deg
|
||||
if abs( vtN:getX()) < 0.5 then dNzLimDwnUp = -0.707 end
|
||||
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, vtOrthoO, dNzLimDwnUp, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw)
|
||||
if not bOk then
|
||||
return bOk, sErr
|
||||
|
||||
@@ -159,6 +159,8 @@ local function MakeByMill( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
dStep = dCrvLen / nStep
|
||||
EgtOutLog( string.format( 'CrvLen=%.1f StepNbr=%d StepLen=%.1f', dCrvLen, nStep, dStep), 3)
|
||||
end
|
||||
-- eventuale spezzatura sul tratto più lungo se curva chiusa
|
||||
BL.PutStartOnLonger( AuxId)
|
||||
-- verifiche per affondamento ( possibili lavorazioni in doppio)
|
||||
local bCross = false
|
||||
if abs( vtExtr:getY()) > 0.707 then
|
||||
|
||||
+1013
-395
File diff suppressed because it is too large
Load Diff
@@ -35,6 +35,92 @@ function ProcessSimpleScarf.Classify( Proc)
|
||||
return true, false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- lavorazione smussi
|
||||
local function MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- verifico che lo smusso sia richiesto
|
||||
local dDepth = EgtGetInfo( Proc.Id, 'Q01', 'd') or 0
|
||||
if dDepth < 0.1 then return true end
|
||||
-- ingombro del grezzo
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- recupero e verifico l'entità curva associata
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
if not AuxId or ( EgtGetType( AuxId) & GDB_FY.GEO_CURVE) == 0 then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing profile geometry'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero i dati della curva e del profilo
|
||||
local dWidth = abs( EgtCurveThickness( AuxId))
|
||||
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
-- eseguo lo smusso solo se direzione orizzontale
|
||||
if abs( vtExtr:getZ()) > 0.1 then
|
||||
local sWarn = 'Warning on process ' .. tostring( Proc.Id) .. ' skipped not horizontale chamfer'
|
||||
EgtOutLog( sWarn)
|
||||
return true
|
||||
end
|
||||
-- eseguo lo smusso solo se feature larga come la trave
|
||||
if dWidth < b3Raw:getDimY() - 1 then
|
||||
local sWarn = 'Warning on process ' .. tostring( Proc.Id) .. ' skipped chamfer (feature smaller than beam)'
|
||||
EgtOutLog( sWarn)
|
||||
return true
|
||||
end
|
||||
local dExtra = 2
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Mark')
|
||||
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 del lato standard
|
||||
local sName1 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMch1Id = EgtAddMachining( sName1, sMilling)
|
||||
if not nMch1Id then
|
||||
local sErr = 'Error adding machining ' .. sName1 .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- assegno affondamento e offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- assegno lato di lavoro
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
end
|
||||
-- Inserisco la lavorazione del lato opposto
|
||||
local sName2 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMch2Id = EgtAddMachining( sName2, sMilling)
|
||||
if not nMch2Id then
|
||||
local sErr = 'Error adding machining ' .. sName2 .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- inverto direzione utensile
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
-- assegno affondamento e offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- assegno lato di lavoro
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione
|
||||
function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
@@ -128,6 +214,9 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
if not bOk then return bOk, sNameOrErr end
|
||||
end
|
||||
end
|
||||
-- inserimento smussi
|
||||
-- local bOkc, sErrC = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- if not bOkc then return bOkc, sErrC end
|
||||
-- se esistono faccia interna ed intermedia, verifico se richiedono taglio a cubetti
|
||||
local vCuts = {}
|
||||
if vFaceOrd[2] ~= 0 and vFaceOrd[3] ~= 0 then
|
||||
|
||||
+389
-101
@@ -1,4 +1,4 @@
|
||||
-- ProcessStepJointNotch.lua by Egaltech s.r.l. 2020/02/11
|
||||
-- ProcessStepJointNotch.lua by Egaltech s.r.l. 2020/03/17
|
||||
-- Gestione calcolo tacca a gradino per Travi
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
@@ -29,17 +29,17 @@ function ProcessStepJointNotch.Classify( Proc)
|
||||
-- numero delle facce
|
||||
local nFacetCnt = EgtSurfTmFacetCount( Proc.Id)
|
||||
-- gestisco solo 2 o 4 facce
|
||||
if nFacetCnt ~= 2 and nFacetCnt ~= 4 then
|
||||
if nFacetCnt ~= 2 and nFacetCnt ~= 4 and nFacetCnt ~= 6 and nFacetCnt ~= 8 then
|
||||
return false, false
|
||||
end
|
||||
-- verifico le normali delle facce
|
||||
local bDown = false
|
||||
for i = 1, nFacetCnt do
|
||||
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT)
|
||||
-- se faccia limite
|
||||
-- se faccia limite la salto
|
||||
if AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then
|
||||
-- attualmente non gestita
|
||||
return false, false
|
||||
-- return false, false
|
||||
-- altrimenti faccia principale
|
||||
elseif vtN:getZ() < -0.1 then
|
||||
bDown = true
|
||||
@@ -49,41 +49,8 @@ function ProcessStepJointNotch.Classify( Proc)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Lavorazione di due facce
|
||||
local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- ingombro del grezzo
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- ingombro del pezzo
|
||||
local Ls = EgtGetFirstNameInGroup( nPartId, 'Box')
|
||||
local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
if not b3Solid then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- dati delle facce
|
||||
local ptC = {}
|
||||
local vtN = {}
|
||||
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
|
||||
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
|
||||
-- normale media per capire se taglio di testa o di coda
|
||||
local vtNm = ( vtN[1] + vtN[2]) ; vtNm:normalize()
|
||||
local bHead = ( vtNm:getX() > 0)
|
||||
-- angolo diedro
|
||||
local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
|
||||
local bOnY = true
|
||||
local ptPs = ( ptC[1] + ptC[2]) / 2
|
||||
if bAdj then
|
||||
local vtDir = ptP1 - ptP2 ; vtDir:normalize()
|
||||
bOnY = abs( vtDir:getZ()) > 0.5 and ( abs( vtDir:getZ()) + abs( vtDir:getX()) > abs( vtDir:getY()))
|
||||
ptPs = ( ptP1 + ptP2) / 2
|
||||
bConvex = ( dAng > 0)
|
||||
end
|
||||
-- determino quale faccia è più grande
|
||||
local _, dB1, dH1 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0)
|
||||
local _, dB2, dH2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 1)
|
||||
local nBigInd = EgtIf( dB1 * dH1 >= dB2 * dH2, 1, 2)
|
||||
local nSmaInd = 3 - nBigInd
|
||||
local function MachineByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Solid, ptC, vtN, nBigInd, nSmaInd, bOnY, ptPs, b3Raw)
|
||||
|
||||
-- recupero la lavorazione
|
||||
local sCutting = ML.FindCutting( 'HeadSide')
|
||||
if not sCutting then
|
||||
@@ -150,14 +117,237 @@ local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
return bOk, sErr
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MakePocket( Proc, nPartId, ptPs, vtN, nFaceRef, nDiffWidth, sMchFind, nUseRoughTool, tBHx)
|
||||
|
||||
-- calcolo il elevazione dal punto medio
|
||||
local dElev
|
||||
local dLenIn, dLedOut = BL.GetPointDirDepth( nPartId, ptPs, vtN[nFaceRef])
|
||||
if dLenIn > 0 then
|
||||
dElev = dLenIn
|
||||
elseif dLedOut then
|
||||
dElev = dLedOut
|
||||
end
|
||||
local dCollSic = 2 * BD.COLL_SIC
|
||||
-- calcolo il diametro utensile
|
||||
local dDiamTool
|
||||
if nUseRoughTool == 1 then
|
||||
dDiamTool = max( 80, min( tBHx[nFaceRef][1], tBHx[nFaceRef][2]))
|
||||
else
|
||||
-- se non uso truciolatore prendo il valore dalle dimensioni minime delle facce
|
||||
dDiamTool = min( tBHx[nFaceRef][1], tBHx[nFaceRef][2])
|
||||
end
|
||||
local sPocketing = ML.FindPocketing( sMchFind, dDiamTool, dElev + dCollSic)
|
||||
if not sPocketing then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- inserisco la lavorazione di svuotatura
|
||||
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. 'F' .. tostring( nFaceRef - 1)
|
||||
local nMchFId = EgtAddMachining( sName, sPocketing)
|
||||
if not nMchFId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ Proc.Id, (nFaceRef-1)}})
|
||||
-- imposto uso faccia
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT)
|
||||
-- imposto posizione braccio porta testa
|
||||
if vtN[nFaceRef]:getY() < GEO.EPS_SMALL then
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
|
||||
else
|
||||
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
|
||||
end
|
||||
-- se tasca aperta e non lavorata col truciolatore, imposto opportuno attacco
|
||||
if sMchFind == 'OpenPocket' and nUseRoughTool == 0 then
|
||||
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN)
|
||||
end
|
||||
-- imposto elevazione
|
||||
local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 1) .. ';'
|
||||
EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes)
|
||||
if not EgtApplyMachining( true, false) then
|
||||
-- provo ad allargare leggermente la tasca
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, -0.1)
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, nBigInd, nSmaInd, ptPs, tBHx, b3Raw, nDiffWidth, nUseRoughTool, dAng)
|
||||
|
||||
local sMchFind = 'Pocket'
|
||||
-- se feature non larga come trave provo a verificare se sborda da un lato o è completamente dentro la faccia del trave
|
||||
if nDiffWidth ~= 1 then sMchFind = 'OpenPocket' end
|
||||
-- se feature non passante disabilito eventuale sgrossatore
|
||||
if nDiffWidth ~= 0 then nUseRoughTool = 0 end
|
||||
|
||||
-- applico la svuotatura
|
||||
local bOk, sErr = MakePocket( Proc, nPartId, ptPs, vtN, nBigInd, nDiffWidth, sMchFind, nUseRoughTool, tBHx)
|
||||
if not bOk then
|
||||
return bOk, sErr
|
||||
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 30 gradi utilizzo la svutatura altrimenti la contornatura
|
||||
if abs( vtN[nSmaInd]:getX()) < 0.866 then -- se si discosta di più di 30° applico svuotatura
|
||||
-- applico la svuotatura
|
||||
local bOk, sErr = MakePocket( Proc, nPartId, ptPs, vtN, nSmaInd, nDiffWidth, sMchFind, nUseRoughTool, tBHx)
|
||||
if not bOk then
|
||||
return bOk, sErr
|
||||
end
|
||||
-- altrimenti contornatura
|
||||
else
|
||||
local bOpenStart = false
|
||||
local bOpenEnd = false
|
||||
if nDiffWidth == 0 then
|
||||
bOpenStart = true
|
||||
bOpenEnd = true
|
||||
else
|
||||
local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, (nBigInd-1))[1]
|
||||
for j = 1, #vAdj2 do
|
||||
if vAdj2[j] == (nSmaInd-1) then
|
||||
-- Se non esiste faccia adiacente a lato precedente -> inizio aperto
|
||||
local i = EgtIf( j > 1, j - 1, #vAdj2)
|
||||
while vAdj2[i] == (nSmaInd-1) do
|
||||
i = EgtIf( i > 1, i - 1, #vAdj2)
|
||||
end
|
||||
bOpenStart = ( vAdj2[i] < 0)
|
||||
-- Se non esiste faccia adiacente a lato successivo -> fine aperto
|
||||
local k = EgtIf( j < #vAdj2, j + 1, 1)
|
||||
while vAdj2[k] == (nSmaInd-1) do
|
||||
k = EgtIf( k < #vAdj2, k + 1, 1)
|
||||
end
|
||||
bOpenEnd = ( vAdj2[k] < 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
local sMilling = ML.FindMilling( 'LongSmallCut')
|
||||
if not sMilling then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- recupero i dati dell'utensile
|
||||
local dTDiam = 50
|
||||
if EgtMdbSetCurrMachining( sMilling) then
|
||||
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
|
||||
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
|
||||
dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dTDiam
|
||||
end
|
||||
end
|
||||
-- Calcolo uso faccia
|
||||
local nFaceUse = BL.GetNearestParalOpposite( tBHx[nBigInd][3]:getVersZ())
|
||||
-- inserisco la lavorazione di fresatura
|
||||
local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMchFId = EgtAddMachining( sName, sMilling)
|
||||
if not nMchFId then
|
||||
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ Proc.Id, (nSmaInd-1)}})
|
||||
-- imposto uso faccia
|
||||
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
|
||||
-- applico gli allungamenti o accorciamenti considerando che la lavorazione è invertita
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenStart, dTDiam / 2, - dTDiam / 2))
|
||||
EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, dTDiam / 2, - dTDiam / 2))
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchFId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Lavorazione di due facce
|
||||
local function MakeFourFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
local function MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth)
|
||||
-- ingombro del grezzo
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- ingombro del pezzo
|
||||
local Ls = EgtGetFirstNameInGroup( nPartId, 'Box')
|
||||
local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD)
|
||||
if not b3Solid then
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' part box not found'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- dati delle facce
|
||||
local tBHx = {}
|
||||
local ptC = {}
|
||||
local vtN = {}
|
||||
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
|
||||
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
|
||||
-- normale media per capire se taglio di testa o di coda
|
||||
local vtNm = ( vtN[1] + vtN[2]) ; vtNm:normalize()
|
||||
local bHead = ( vtNm:getX() > 0)
|
||||
-- angolo diedro
|
||||
local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
|
||||
local bOnY = true
|
||||
local ptPs = ( ptC[1] + ptC[2]) / 2
|
||||
local bConvex
|
||||
if bAdj then
|
||||
local vtDir = ptP1 - ptP2 ; vtDir:normalize()
|
||||
bOnY = abs( vtDir:getZ()) > 0.5 and ( abs( vtDir:getZ()) + abs( vtDir:getX()) > abs( vtDir:getY()))
|
||||
ptPs = ( ptP1 + ptP2) / 2
|
||||
bConvex = ( dAng > 0)
|
||||
end
|
||||
-- determino quale faccia è più grande
|
||||
local rfFac1, dH1, dV1 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 0, GDB_ID.ROOT)
|
||||
local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, 1, GDB_ID.ROOT)
|
||||
local nBigInd = EgtIf( dV1 * dH1 >= dV2 * dH2, 1, 2)
|
||||
local nSmaInd = 3 - nBigInd
|
||||
tBHx[1] = {dH1, dV1, rfFac1}
|
||||
tBHx[2] = {dH2, dV2, rfFac2}
|
||||
-- verifico parametro Q per stabilire se deve essere lavorato con truciolatore
|
||||
-- o se larghezza inferiore del trave, utilizzare una svuotatura
|
||||
local nUseRoughTool = EgtGetInfo( Proc.Id, 'Q02', 'i') or 0
|
||||
-- se feature non è larga come trave o è selezionato l'utilizzo del truciolatore utilizzo svuotatura
|
||||
if nDiffWidth > 0 or nUseRoughTool == 1 then
|
||||
-- se angolo compreso è >= di 90° applico svuotatura con fresa
|
||||
if not bConvex and ( 180 + dAng) >= 90 then
|
||||
local bOk, sErr = MachineByMill( Proc, nPhase, nRawId, nPartId, b3Solid, ptC, vtN, nBigInd, nSmaInd, ptPs, tBHx, b3Raw, nDiffWidth, nUseRoughTool, dAng)
|
||||
if not bOk then
|
||||
return bOk, sErr
|
||||
end
|
||||
else
|
||||
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' internal angle less than square angle'
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- altrimenti provo a lavorare con la lama
|
||||
else
|
||||
local bOk, sErr = MachineByBlade( Proc, nPhase, nRawId, nPartId, dOvmHead, b3Solid, ptC, vtN, nBigInd, nSmaInd, bOnY, ptPs, b3Raw)
|
||||
if not bOk then
|
||||
return bOk, sErr
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Lavorazione di due facce
|
||||
local function MakeFourFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth)
|
||||
-- Prime due facce
|
||||
local bOk, sErr = MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
local bOk, sErr = MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth)
|
||||
if not bOk then return bOk, sErr end
|
||||
-- Seconde due facce
|
||||
-- recupero gruppo per geometria addizionale
|
||||
@@ -175,7 +365,7 @@ local function MakeFourFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id))
|
||||
-- applico lavorazione
|
||||
local NewProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg}
|
||||
local bOk, sErr = MakeTwoFaces( NewProc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
local bOk, sErr = MakeTwoFaces( NewProc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth)
|
||||
if not bOk then return bOk, sErr end
|
||||
end
|
||||
return true
|
||||
@@ -184,9 +374,6 @@ end
|
||||
---------------------------------------------------------------------
|
||||
-- lavorazione smussi
|
||||
local function MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- verifico che lo smusso sia richiesto
|
||||
local dDepth = EgtGetInfo( Proc.Id, 'Q01', 'd') or 0
|
||||
if dDepth < 0.1 then return true end
|
||||
-- ingombro del grezzo
|
||||
local b3Raw = EgtGetRawPartBBox( nRawId)
|
||||
-- recupero e verifico l'entità curva associata
|
||||
@@ -200,18 +387,100 @@ local function MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- recupero i dati della curva e del profilo
|
||||
local dWidth = abs( EgtCurveThickness( AuxId))
|
||||
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
-- eseguo lo smusso solo se direzione orizzontale
|
||||
if abs( vtExtr:getZ()) > 0.1 then
|
||||
local sWarn = 'Warning on process ' .. tostring( Proc.Id) .. ' skipped not horizontale chamfer'
|
||||
EgtOutLog( sWarn)
|
||||
return true
|
||||
-- prendo il boundig box della feature
|
||||
local bBoxExtr = EgtGetBBoxGlob( AuxId, GDB_BB.STANDARD )
|
||||
local nTypePos = 0
|
||||
-- determino se sborda da un lato
|
||||
if abs( vtExtr:getZ()) < 0.1 then -- se orizzontale
|
||||
-- se altezza percorso inferiore della larghezza trave
|
||||
if dWidth < b3Raw:getDimY() - 1 then
|
||||
nTypePos = 1
|
||||
-- verifico se sborda verso y+
|
||||
if abs( bBoxExtr:getMax():getY() - b3Raw:getMax():getY()) < 0.1 then
|
||||
nTypePos = 2
|
||||
-- se sborda verso y-
|
||||
elseif abs( bBoxExtr:getMin():getY() - b3Raw:getMin():getY()) < 0.1 then
|
||||
nTypePos = 3
|
||||
end
|
||||
end
|
||||
elseif abs( vtExtr:getZ()) > 0.9 then -- se verticale
|
||||
-- se altezza percorso inferiore della larghezza trave
|
||||
if dWidth < b3Raw:getDimZ() - 1 then
|
||||
nTypePos = 1
|
||||
-- verifico se sborda verso z+
|
||||
if abs( bBoxExtr:getMax():getZ() - b3Raw:getMax():getZ()) < 0.1 then
|
||||
nTypePos = 4
|
||||
-- se sborda verso z-
|
||||
elseif abs( bBoxExtr:getMin():getZ() - b3Raw:getMin():getZ()) < 0.1 then
|
||||
nTypePos = 5
|
||||
end
|
||||
end
|
||||
else -- altrimenti se altra direzione setto per non fare smussi
|
||||
nTypePos = 6
|
||||
end
|
||||
-- eseguo lo smusso solo se feature larga come la trave
|
||||
if dWidth < b3Raw:getDimY() - 1 then
|
||||
|
||||
-- verifico che lo smusso sia richiesto
|
||||
local dDepth = EgtGetInfo( Proc.Id, 'Q01', 'd') or 0
|
||||
if dDepth < 0.1 then return true, '', nTypePos end
|
||||
|
||||
-- disabilito smusso se feature non sborda dalla trave almeno da un lato
|
||||
if nTypePos == 1 then
|
||||
local sWarn = 'Warning on process ' .. tostring( Proc.Id) .. ' skipped chamfer (feature smaller than beam)'
|
||||
EgtOutLog( sWarn)
|
||||
return true
|
||||
return true, sWarn , nTypePos
|
||||
end
|
||||
-- salto lo smusso se sborda dal lato in Z- o una direzione diversa da Y e Z
|
||||
if nTypePos >= 5 then
|
||||
local sWarn = 'Warning on process ' .. tostring( Proc.Id) .. ' skipped chamfer (wrong side to apply)'
|
||||
EgtOutLog( sWarn)
|
||||
return true, sWarn, nTypePos
|
||||
end
|
||||
local bExeNormal = true
|
||||
local bExeOpposite = true
|
||||
-- controllo le lavorazioni quando la feature è orizzontale
|
||||
if abs( vtExtr:getY()) > 0.99 then
|
||||
-- se diretta verso Y+
|
||||
if vtExtr:getY() > 0 then
|
||||
-- se sborda verso Y+ abilito solo la lavorazione della parte normale
|
||||
if nTypePos == 2 then
|
||||
bExeOpposite = false
|
||||
-- se sborda verso Y- abilito solo la lavorazione della parte opposta
|
||||
elseif nTypePos == 3 then
|
||||
bExeNormal = false
|
||||
end
|
||||
-- altrimenti diretta verso Y-
|
||||
else
|
||||
-- se sborda verso Y+ abilito solo la lavorazione della parte opposta
|
||||
if nTypePos == 2 then
|
||||
bExeNormal = false
|
||||
-- se sborda verso Y- abilito solo la lavorazione della parte normale
|
||||
elseif nTypePos == 3 then
|
||||
bExeOpposite = false
|
||||
end
|
||||
end
|
||||
-- se diretta verso Z
|
||||
elseif abs( vtExtr:getZ()) > 0.99 then
|
||||
-- se diretta verso Z+
|
||||
if vtExtr:getZ() > 0 then
|
||||
-- se sborda verso Z+ abilito solo la lavorazione della parte normale
|
||||
if nTypePos == 4 or nTypePos == 0 then
|
||||
bExeOpposite = false
|
||||
else -- altrimenti disabilito entrambe
|
||||
bExeNormal = false
|
||||
bExeOpposite = false
|
||||
end
|
||||
-- altrimenti diretta verso Z-
|
||||
else
|
||||
-- se sborda verso Z+ abilito solo la lavorazione della parte opposta
|
||||
if nTypePos == 4 or nTypePos == 0 then
|
||||
bExeNormal = false
|
||||
else -- altrimenti disabilito entrambe
|
||||
bExeNormal = false
|
||||
bExeOpposite = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local dExtra = 2
|
||||
-- recupero la lavorazione
|
||||
local sMilling = ML.FindMilling( 'Mark')
|
||||
@@ -220,66 +489,85 @@ local function MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- Inserisco la lavorazione del lato standard
|
||||
local sName1 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMch1Id = EgtAddMachining( sName1, sMilling)
|
||||
if not nMch1Id then
|
||||
local sErr = 'Error adding machining ' .. sName1 .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
if bExeNormal then
|
||||
-- Inserisco la lavorazione del lato standard
|
||||
local sName1 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMch1Id = EgtAddMachining( sName1, sMilling)
|
||||
if not nMch1Id then
|
||||
local sErr = 'Error adding machining ' .. sName1 .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- assegno affondamento e offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- assegno lato di lavoro
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- assegno affondamento e offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- assegno lato di lavoro
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
if bExeOpposite then
|
||||
-- Inserisco la lavorazione del lato opposto
|
||||
local sName2 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMch2Id = EgtAddMachining( sName2, sMilling)
|
||||
if not nMch2Id then
|
||||
local sErr = 'Error adding machining ' .. sName2 .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- inverto direzione utensile
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
-- assegno affondamento e offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- assegno lato di lavoro
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
-- Inserisco la lavorazione del lato opposto
|
||||
local sName2 = 'SJN_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
|
||||
local nMch2Id = EgtAddMachining( sName2, sMilling)
|
||||
if not nMch2Id then
|
||||
local sErr = 'Error adding machining ' .. sName2 .. '-' .. sMilling
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
-- aggiungo geometria
|
||||
EgtSetMachiningGeometry( {{ AuxId, -1}})
|
||||
-- inverto direzione utensile
|
||||
EgtSetMachiningParam( MCH_MP.TOOLINVERT, true)
|
||||
-- assegno affondamento e offset radiale
|
||||
EgtSetMachiningParam( MCH_MP.DEPTH, dDepth + dExtra)
|
||||
EgtSetMachiningParam( MCH_MP.OFFSR, dExtra)
|
||||
-- assegno lato di lavoro
|
||||
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
|
||||
-- eseguo
|
||||
if not EgtApplyMachining( true, false) then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nMchId, false)
|
||||
return false, sErr
|
||||
end
|
||||
return true
|
||||
return true, '', nTypePos
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Applicazione della lavorazione
|
||||
function ProcessStepJointNotch.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- esecuzione eventuale smusso
|
||||
local bOkc, sErrC = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
-- ottengo anche il flag che indica che la feature è larga come la trave
|
||||
local bOkc, sErrC, nDiffWidth = MakeChamfer( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
if not bOkc then return bOkc, sErrC end
|
||||
-- come fatto nella classify, conto solo le facce che non sono dirette in Y o Z
|
||||
local nFacetCnt = EgtSurfTmFacetCount( Proc.Id)
|
||||
local nUsableFaces = 0
|
||||
|
||||
for i = 1, nFacetCnt do
|
||||
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i-1, GDB_ID.ROOT)
|
||||
-- se faccia limite la salto
|
||||
if AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then
|
||||
-- altrimenti faccia principale
|
||||
else
|
||||
nUsableFaces = nUsableFaces + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- se due facce
|
||||
if Proc.Fct == 2 then
|
||||
local bOk, sErr = MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
if nUsableFaces == 2 then
|
||||
local bOk, sErr = MakeTwoFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth)
|
||||
if not bOk then return bOk, sErr end
|
||||
-- se quattro facce
|
||||
elseif Proc.Fct == 4 then
|
||||
local bOk, sErr = MakeFourFaces( Proc, nPhase, nRawId, nPartId, dOvmHead)
|
||||
elseif nUsableFaces == 4 then
|
||||
local bOk, sErr = MakeFourFaces( Proc, nPhase, nRawId, nPartId, dOvmHead, nDiffWidth)
|
||||
if not bOk then return bOk, sErr end
|
||||
-- altrimenti errore
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user