diff --git a/LuaLibs/ProcessProfCamb.lua b/LuaLibs/ProcessProfCamb.lua index a346bcc..cbccf1f 100644 --- a/LuaLibs/ProcessProfCamb.lua +++ b/LuaLibs/ProcessProfCamb.lua @@ -1,4 +1,4 @@ --- ProcessProfCamb.lua by Egaltech s.r.l. 2022/02/02 +-- ProcessProfCamb.lua by Egaltech s.r.l. 2022/05/24 -- Gestione calcolo profilo caudato per Travi -- 2021/05/03 Aggiunta gestione smusso da sopra e sotto per macchina con testa da sotto. -- 2021/06/28 Per macchine con testa sotto, smussi di lato con questa testa se non c'è lav.ne da sopra. @@ -6,6 +6,7 @@ -- 2021/10/12 Portato a 30deg l'angolo limite per fare l'antischeggia. -- 2022/01/26 Migliorato controllo lavorazione con fresa su testa da sotto. -- 2022/02/02 Aggiunta funzione OnlyChamfer. +-- 2022/05/24 Aggiunta fresatura da sotto su macchine con testa da sotto. -- Tabella per definizione modulo local ProcessProfCamb = {} @@ -204,6 +205,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + local sWarn -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- ingombro del pezzo @@ -443,9 +445,124 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se il chamfer non è esclusivo continuo con le altre lavorazioni if nChamfer < 2 then -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) + local bDouble = ( dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) - -- inserisco la lavorazione + -- se lavorazione da due parti, aggiungo la seconda + local sMillingDown + if bDouble then + if nSide == 0 then + if BD.DOWN_HEAD then + -- recupero la lavorazione + sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) + if not sMillingDown then + sWarn = 'Warning : milling from bottom not found in library' + EgtOutLog( sWarn) + bDouble = false + end + else + sWarn = 'Warning in profiling : depth (' .. EgtNumToString( dProfDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dToolMaxDepth, 1) .. ')' + EgtOutLog( sWarn) + bDouble = false + end + end + end + -- se orizzontale o trovata lavorazione per doppio verticale + if bDouble then + -- inserisco la lavorazione + local sName + if bMakeAs then + sName = 'ProfB_As_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + else + sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + end + local nMchId = EgtAddMachining( sName, EgtIf( BD.DOWN_HEAD and nSide == 0, sMillingDown, sMilling)) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- se lavorazione da sopra e da sotto + if ( nSide == 0) then + if vtExtr:getZ() > 0.1 then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + -- altrimenti lavorazione davanti e dietro + else + -- se lavorazione a destra di fronte o sinistra da dietro, inverto + if ( bHead and vtExtr:getY() > 0.1) or + ( not bHead and vtExtr:getY() < -0.1) then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + end + -- imposto l'affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) + -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale + local bFinish + local dOriOffset = 0 + local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + bFinish = true + end + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + end + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + else + -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno + -- della feature inverto il punto di inizio della lavorazione + ModifySideAndInvert( Proc, bHead) + end + -- se devo fare l'antischeggia in testa + if bMakeAs then + local sNewName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + -- copio lavorazione per ingresso antischeggia (la copia è la lavorazione finale) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + -- rendo corrente la precedente, la inverto e modifico il parametri di uscita + EgtSetCurrMachining( nMchId) + local dCrvLen = EgtCurveLength( AuxId) + if dCrvLen > abs(dMakeAntiSplintOnHead) then + ModifySideAndInvert( Proc, bHead, true, ( abs(dMakeAntiSplintOnHead) - dCrvLen)) + end + -- rendo corrente la copia (cioè la lavorazione completa) + EgtSetCurrMachining( nMch2Id) + nMchId = nMch2Id + end + -- se abilitata, aggiungo lavorazione di finitura + if bFinish then + -- inserisco la lavorazione + local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + if not nMch2Id then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + else + -- riporto il sovramateriale originale e tolgo i passi inutili + EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) + EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMch2Id, false) + return false, sErr + end + end + end + end + -- inserisco la prima lavorazione local sName if bMakeAs then sName = 'Prof_As_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) @@ -553,85 +670,6 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end end - -- se lavorazione da due parti, aggiungo la seconda - if bDouble then - -- inserisco la lavorazione - local sName - if bMakeAs then - sName = 'ProfB_As_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - else - sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - end - 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}}) - -- sempre lavorazione da sopra o da sotto - -- se lavorazione a destra di fronte o sinistra da dietro, inverto - if ( bHead and vtExtr:getY() > 0.1) or - ( not bHead and vtExtr:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end - -- imposto l'affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) - -- posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) - -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente - if dOffsetPar > 0 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) - end - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr - else - -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno - -- della feature inverto il punto di inizio della lavorazione - ModifySideAndInvert( Proc, bHead) - end - -- se devo fare l'antischeggia in testa - if bMakeAs then - local sNewName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - -- copio lavorazione per ingresso antischeggia (la copia è la lavorazione finale) - local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) - -- rendo corrente la precedente, la inverto e modifico il parametri di uscita - EgtSetCurrMachining( nMchId) - local dCrvLen = EgtCurveLength( AuxId) - if dCrvLen > abs(dMakeAntiSplintOnHead) then - ModifySideAndInvert( Proc, bHead, true, ( abs(dMakeAntiSplintOnHead) - dCrvLen)) - end - -- rendo corrente la copia (cioè la lavorazione completa) - EgtSetCurrMachining( nMch2Id) - nMchId = nMch2Id - end - -- se abilitata, aggiungo lavorazione di finitura - if bFinish then - -- inserisco la lavorazione - local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) - if not nMch2Id then - local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - else - -- riporto il sovramateriale originale e tolgo i passi inutili - EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) - EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMch2Id, false) - return false, sErr - end - end - end - end -- se non da sotto e parametro Q abilitato, inserisco lavorazione finitura angolo if ( nSide ~= -1 or bMillDown) and EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') == 1 then sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) @@ -684,7 +722,7 @@ function ProcessProfCamb.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) BL.UpdateTCING( nRawId, Proc.Box:getMin():getX() - b3Solid:getMin():getX()) end end - return true + return true, sWarn end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessProfConcave.lua b/LuaLibs/ProcessProfConcave.lua index 9b26dd6..79ecaac 100644 --- a/LuaLibs/ProcessProfConcave.lua +++ b/LuaLibs/ProcessProfConcave.lua @@ -1,8 +1,9 @@ --- ProcessProfConcave.lua by Egaltech s.r.l. 2022/02/02 +-- ProcessProfConcave.lua by Egaltech s.r.l. 2022/05/24 -- Gestione calcolo profilo concavo per Travi -- 2021/05/03 Aggiunta gestione smusso da sopra e sotto per macchina con testa da sotto. -- 2021/06/28 Per macchine con testa sotto, smussi di lato con questa testa se non c'è lav.ne da sopra. -- 2022/02/02 Aggiunta funzione OnlyChamfer. +-- 2022/05/24 Aggiunta fresatura da sotto su macchine con testa da sotto. -- Tabella per definizione modulo local ProcessProfConcave = {} @@ -89,8 +90,8 @@ local function ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, dLenLst, -- confronto il punto iniziale e finale della lavorazione con il box della feature -- e se è vicino alla parte esterna della trave inverto la lavorazione - ptSP = EgtGetMachiningStartPoint() - ptEp = EgtGetMachiningEndPoint() + local ptSP = EgtGetMachiningStartPoint() + local ptEp = EgtGetMachiningEndPoint() local nMachMode = EgtGetMachiningParam( MCH_MP.STEPTYPE) if nMachMode == 1 and ptSP and ptEp then if abs( EgtIf( bHead, Proc.Box:getMax():getX(), Proc.Box:getMin():getX()) - ptSP:getX()) < @@ -195,6 +196,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + local sWarn -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- ingombro del pezzo @@ -411,9 +413,109 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) + local bDouble = ( dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) - -- inserisco la lavorazione + -- se lavorazione da due parti, aggiungo la seconda + local sMillingDown + if bDouble then + if nSide == 0 then + if BD.DOWN_HEAD then + -- recupero la lavorazione + sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) + if not sMillingDown then + sWarn = 'Warning : milling from bottom not found in library' + EgtOutLog( sWarn) + bDouble = false + end + else + sWarn = 'Warning in profiling : depth (' .. EgtNumToString( dProfDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dToolMaxDepth, 1) .. ')' + EgtOutLog( sWarn) + bDouble = false + end + end + end + -- se orizzontale o trovata lavorazione per doppio verticale + if bDouble then + -- inserisco la lavorazione + local sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, EgtIf( BD.DOWN_HEAD and nSide == 0, sMillingDown, sMilling)) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- resetto il flag inversione percorso + bFlagInvert = false + -- se lavorazione da sopra e da sotto + if ( nSide == 0) then + if vtExtr:getZ() > 0.1 then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + bFlagInvert = true + end + -- altrimenti lavorazione davanti e dietro + else + -- se lavorazione a destra di fronte o sinistra da dietro, inverto + if ( bHead and vtExtr:getY() > 0.1) or + ( not bHead and vtExtr:getY() < -0.1) then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + bFlagInvert = true + end + end + -- imposto l'affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) + -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale + local bFinish + local dOriOffset = 0 + local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + bFinish = true + end + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + end + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + else + -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno + -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco + -- e uscita + ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, dLenLst, bFirstTrim, bLastTrim, bFlagInvert, dOffsetPar) + end + -- se abilitata, aggiungo lavorazione di finitura + if bFinish then + -- inserisco la lavorazione + local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + if not nMch2Id then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + else + -- riporto il sovramateriale originale e tolgo i passi inutili + EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) + EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMch2Id, false) + return false, sErr + end + end + end + end + -- inserisco la prima lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sMilling) if not nMchId then @@ -467,7 +569,6 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- posizione braccio porta testa EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale - local ptSP, ptEp local bFinish local dOriOffset = 0 local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 @@ -491,7 +592,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) if bFinish then -- inserisco la lavorazione local sNewName = 'Prof_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) if not nMch2Id then local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling EgtOutLog( sErr) @@ -508,73 +609,10 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end end - -- se lavorazione da due parti, aggiungo la seconda - if bDouble then - -- inserisco la lavorazione - local sName = 'ProfB_' .. ( 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}}) - -- resetto il flag inversione percorso - bFlagInvert = false - -- sempre lavorazione da sopra o da sotto - -- se lavorazione a destra di fronte o sinistra da dietro, inverto - if ( bHead and vtExtr:getY() > 0.1) or - ( not bHead and vtExtr:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - EgtSetMachiningParam( MCH_MP.INVERT, true) - bFlagInvert = not bFlagInvert - end - -- imposto l'affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) - -- posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) - -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente - if dOffsetPar > 0 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) - end - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr - else - -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno - -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco - -- e uscita - ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, dLenLst, bFirstTrim, bLastTrim, bFlagInvert, dOffsetPar) - end - -- se abilitata, aggiungo lavorazione di finitura - if bFinish then - -- inserisco la lavorazione - local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) - if not nMch2Id then - local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - else - -- riporto il sovramateriale originale e tolgo i passi inutili - EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) - EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMch2Id, false) - return false, sErr - end - end - end - end -- se parametro Q disabilitato, e consentito anche in alcuni casi lavorarlo con la feature da sotto -- inserisco eventuale finitura faccia finale (ortogonale alla trave o, se da sotto, parallela) if EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') ~= 1 and bLastTrim and - ( nSide ~= -1 or ( nSide == -1 and EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1)) then + ( nSide ~= -1 or ( nSide == -1 and ( EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1 or BD.DOWN_HEAD))) then sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchVId = EgtAddMachining( sName, sMilling) if not nMchVId then @@ -610,7 +648,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se parametro Q disabilitato, e consentito anche in alcuni casi lavorarlo con la feature da sotto -- inserisco eventuale finitura faccia finale (ortogonale alla trave o, se da sotto, parallela) if EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') ~= 1 and bFirstTrim and - ( nSide ~= -1 or ( nSide == -1 and EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1)) then + ( nSide ~= -1 or ( nSide == -1 and ( EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1 or BD.DOWN_HEAD))) then sName = 'ProfV2_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchV2Id = EgtAddMachining( sName, sMilling) if not nMchV2Id then @@ -656,7 +694,7 @@ function ProcessProfConcave.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) BL.UpdateTCING( nRawId, Proc.Box:getMin():getX() - b3Solid:getMin():getX()) end end - return true + return true, sWarn end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessProfConvex.lua b/LuaLibs/ProcessProfConvex.lua index 6ca8742..6901f27 100644 --- a/LuaLibs/ProcessProfConvex.lua +++ b/LuaLibs/ProcessProfConvex.lua @@ -1,8 +1,9 @@ --- ProcessProfConvex.lua by Egaltech s.r.l. 2022/02/02 +-- ProcessProfConvex.lua by Egaltech s.r.l. 2022/05/24 -- Gestione calcolo profilo convesso per Travi -- 2021/05/03 Aggiunta gestione smusso da sopra e sotto per macchina con testa da sotto. -- 2021/06/28 Per macchine con testa sotto, smussi di lato con questa testa se non c'è lav.ne da sopra. -- 2022/02/02 Aggiunta funzione OnlyChamfer. +-- 2022/05/24 Aggiunta fresatura da sotto su macchine con testa da sotto. -- Tabella per definizione modulo local ProcessProfConvex = {} @@ -89,8 +90,8 @@ local function ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, dLenLst, -- confronto il punto iniziale e finale della lavorazione con il box della feature -- e se è vicino alla parte esterna della trave inverto la lavorazione - ptSP = EgtGetMachiningStartPoint() - ptEp = EgtGetMachiningEndPoint() + local ptSP = EgtGetMachiningStartPoint() + local ptEp = EgtGetMachiningEndPoint() local nMachMode = EgtGetMachiningParam( MCH_MP.STEPTYPE) if nMachMode == 1 and ptSP and ptEp then if abs( EgtIf( bHead, Proc.Box:getMax():getX(), Proc.Box:getMin():getX()) - ptSP:getX()) < @@ -195,6 +196,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + local sWarn -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- ingombro del pezzo @@ -411,9 +413,109 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) + local bDouble = ( dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) - -- inserisco la lavorazione + -- se lavorazione da due parti, aggiungo la seconda + local sMillingDown + if bDouble then + if nSide == 0 then + if BD.DOWN_HEAD then + -- recupero la lavorazione + sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) + if not sMillingDown then + sWarn = 'Warning : milling from bottom not found in library' + EgtOutLog( sWarn) + bDouble = false + end + else + sWarn = 'Warning in profiling : depth (' .. EgtNumToString( dProfDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dToolMaxDepth, 1) .. ')' + EgtOutLog( sWarn) + bDouble = false + end + end + end + -- se orizzontale o trovata lavorazione per doppio verticale + if bDouble then + -- inserisco la lavorazione + local sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, EgtIf( BD.DOWN_HEAD and nSide == 0, sMillingDown, sMilling)) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- resetto il flag inversione percorso + bFlagInvert = false + -- se lavorazione da sopra e da sotto + if ( nSide == 0) then + if vtExtr:getZ() > 0.1 then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + bFlagInvert = true + end + -- altrimenti lavorazione davanti e dietro + else + -- se lavorazione a destra di fronte o sinistra da dietro, inverto + if ( bHead and vtExtr:getY() > 0.1) or + ( not bHead and vtExtr:getY() < -0.1) then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + bFlagInvert = true + end + end + -- imposto l'affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) + -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale + local bFinish + local dOriOffset = 0 + local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + bFinish = true + end + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + end + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + else + -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno + -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco + -- e uscita + ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, dLenLst, bFirstTrim, bLastTrim, bFlagInvert, dOffsetPar) + end + -- se abilitata, aggiungo lavorazione di finitura + if bFinish then + -- inserisco la lavorazione + local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + if not nMch2Id then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + else + -- riporto il sovramateriale originale e tolgo i passi inutili + EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) + EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMch2Id, false) + return false, sErr + end + end + end + end + -- inserisco la prima lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sMilling) if not nMchId then @@ -467,7 +569,6 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- posizione braccio porta testa EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale - local ptSP, ptEp local bFinish local dOriOffset = 0 local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 @@ -508,73 +609,10 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end end - -- se lavorazione da due parti, aggiungo la seconda - if bDouble then - -- inserisco la lavorazione - local sName = 'ProfB_' .. ( 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}}) - -- resetto il flag inversione percorso - bFlagInvert = false - -- sempre lavorazione da sopra o da sotto - -- se lavorazione a destra di fronte o sinistra da dietro, inverto - if ( bHead and vtExtr:getY() > 0.1) or - ( not bHead and vtExtr:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - EgtSetMachiningParam( MCH_MP.INVERT, true) - bFlagInvert = not bFlagInvert - end - -- imposto l'affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) - -- posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) - -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente - if dOffsetPar > 0 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) - end - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr - else - -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno - -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco - -- e uscita - ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, dLenLst, bFirstTrim, bLastTrim, bFlagInvert, dOffsetPar) - end - -- se abilitata, aggiungo lavorazione di finitura - if bFinish then - -- inserisco la lavorazione - local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) - if not nMch2Id then - local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - else - -- riporto il sovramateriale originale e tolgo i passi inutili - EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) - EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMch2Id, false) - return false, sErr - end - end - end - end -- se parametro Q disabilitato, e consentito anche in alcuni casi lavorarlo con la feature da sotto -- inserisco eventuale finitura faccia finale (ortogonale alla trave o, se da sotto, parallela) if EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') ~= 1 and bLastTrim and - ( nSide ~= -1 or ( nSide == -1 and EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1)) then + ( nSide ~= -1 or ( nSide == -1 and ( EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1 or BD.DOWN_HEAD))) then sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchVId = EgtAddMachining( sName, sMilling) if not nMchVId then @@ -610,7 +648,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- se parametro Q disabilitato, e consentito anche in alcuni casi lavorarlo con la feature da sotto -- inserisco eventuale finitura faccia finale (ortogonale alla trave o, se da sotto, parallela) if EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') ~= 1 and bFirstTrim and - ( nSide ~= -1 or ( nSide == -1 and EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1)) then + ( nSide ~= -1 or ( nSide == -1 and ( EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1 or BD.DOWN_HEAD))) then sName = 'ProfV2_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchV2Id = EgtAddMachining( sName, sMilling) if not nMchV2Id then @@ -655,7 +693,7 @@ function ProcessProfConvex.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) BL.UpdateTCING( nRawId, Proc.Box:getMin():getX() - b3Solid:getMin():getX()) end end - return true + return true, sWarn end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessProfFront.lua b/LuaLibs/ProcessProfFront.lua index 3a68535..1b2fdbf 100644 --- a/LuaLibs/ProcessProfFront.lua +++ b/LuaLibs/ProcessProfFront.lua @@ -1,8 +1,9 @@ --- ProcessProfFront.lua by Egaltech s.r.l. 2022/02/02 +-- ProcessProfFront.lua by Egaltech s.r.l. 2022/05/24 -- Gestione calcolo profilo frontale per Travi -- 2021/05/03 Aggiunta gestione smusso da sopra e sotto per macchina con testa da sotto. -- 2021/06/28 Per macchine con testa sotto, smussi di lato con questa testa se non c'è lav.ne da sopra. -- 2022/02/02 Aggiunta funzione OnlyChamfer. +-- 2022/05/24 Aggiunta fresatura da sotto su macchine con testa da sotto. -- Tabella per definizione modulo local ProcessProfFront = {} @@ -167,6 +168,7 @@ end --------------------------------------------------------------------- -- Applicazione della lavorazione function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) + local sWarn -- ingombro del grezzo local b3Raw = EgtGetRawPartBBox( nRawId) -- ingombro del pezzo @@ -370,8 +372,104 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) + local bDouble = ( dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) + -- se lavorazione da due parti, aggiungo la seconda + local sMillingDown + if bDouble then + if nSide == 0 then + if BD.DOWN_HEAD then + -- recupero la lavorazione + sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) + if not sMillingDown then + sWarn = 'Warning : milling from bottom not found in library' + EgtOutLog( sWarn) + bDouble = false + end + else + sWarn = 'Warning in profiling : depth (' .. EgtNumToString( dProfDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dToolMaxDepth, 1) .. ')' + EgtOutLog( sWarn) + bDouble = false + end + end + end + -- se orizzontale o trovata lavorazione per doppio verticale + if bDouble then + -- inserisco la lavorazione + local sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, EgtIf( BD.DOWN_HEAD and nSide == 0, sMillingDown, sMilling)) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- se lavorazione da sopra e da sotto + if ( nSide == 0) then + if vtExtr:getZ() > 0.1 then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + -- altrimenti lavorazione davanti e dietro + else + -- se lavorazione a destra di fronte o sinistra da dietro, inverto + if ( bHead and vtExtr:getY() > 0.1) or + ( not bHead and vtExtr:getY() < -0.1) then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + end + -- imposto l'affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) + -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale + local bFinish + local dOriOffset = 0 + local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + bFinish = true + end + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + end + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + else + -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno + -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco + -- e uscita + ModifySideInvertLead( Proc, bHead, dToolDiam) + end + -- se abilitata, aggiungo lavorazione di finitura + if bFinish then + -- inserisco la lavorazione + local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + if not nMch2Id then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + else + -- riporto il sovramateriale originale e tolgo i passi inutili + EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) + EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMch2Id, false) + return false, sErr + end + end + end + end -- inserisco la lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sMilling) @@ -420,7 +518,6 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- posizione braccio porta testa EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale - local ptSP, ptEp local bFinish local dOriOffset = 0 local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 @@ -461,70 +558,10 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end end - -- se lavorazione da due parti, aggiungo la seconda - if bDouble then - -- inserisco la lavorazione - local sName = 'ProfB_' .. ( 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}}) - -- sempre lavorazione da sopra o da sotto - -- se lavorazione a destra di fronte o sinistra da dietro, inverto - if ( bHead and vtExtr:getY() > 0.1) or - ( not bHead and vtExtr:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - EgtSetMachiningParam( MCH_MP.INVERT, true) - end - -- imposto l'affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) - -- posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) - -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente - if dOffsetPar > 0 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) - end - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr - else - -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno - -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco - -- e uscita - ModifySideInvertLead( Proc, bHead, dToolDiam) - end - -- se abilitata, aggiungo lavorazione di finitura - if bFinish then - -- inserisco la lavorazione - local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) - if not nMch2Id then - local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - else - -- riporto il sovramateriale originale e tolgo i passi inutili - EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) - EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMch2Id, false) - return false, sErr - end - end - end - end -- se parametro Q disabilitato, e consentito anche in alcuni casi lavorarlo con la feature da sotto -- inserisco eventuale finitura faccia finale (ortogonale alla trave o, se da sotto, parallela) if EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') ~= 1 and bFirstTrim and - ( nSide ~= -1 or ( nSide == -1 and EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1)) then + ( nSide ~= -1 or ( nSide == -1 and ( EgtGetInfo( Proc.Id, sMachFacesUnderneath, 'i') == 1 or BD.DOWN_HEAD))) then -- se non da sotto, inserisco lavorazione finitura angolo --if nSide ~= -1 then sName = 'ProfV_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) @@ -547,7 +584,9 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dWidth, 1)) -- imposto tipo uso faccia local nFaceUse = MCH_MILL_FU.PARAL_DOWN - if nSide ~= 1 then + if nSide == -1 then + nFaceUse = EgtIf( vtN:getX() > 0.1, MCH_MILL_FU.PARAL_LEFT, MCH_MILL_FU.PARAL_RIGHT) + elseif nSide ~= 1 then nFaceUse = EgtIf( vtN:getY() > 0.1, MCH_MILL_FU.PARAL_FRONT, MCH_MILL_FU.PARAL_BACK) end EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) @@ -587,7 +626,7 @@ function ProcessProfFront.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- BL.UpdateTCING( nRawId, Proc.Box:getMax():getX() - b3Solid:getMin():getX()) -- end --end - return true + return true, sWarn end --------------------------------------------------------------------- diff --git a/LuaLibs/ProcessProfHead.lua b/LuaLibs/ProcessProfHead.lua index 7dd73d9..3067d8c 100644 --- a/LuaLibs/ProcessProfHead.lua +++ b/LuaLibs/ProcessProfHead.lua @@ -1,9 +1,10 @@ --- ProcessProfHead.lua by Egaltech s.r.l. 2022/02/02 +-- ProcessProfHead.lua by Egaltech s.r.l. 2022/05/24 -- Gestione calcolo profilo di testa per Travi -- 2021/05/03 Aggiunta gestione smusso da sopra e sotto per macchina con testa sotto. -- 2021/06/28 Per macchine con testa sotto, smussi di lato con questa testa se non c'è lav.ne da sopra. -- 2021/10/12 Estesa gestione di testa da sotto, se presente. -- 2022/02/02 Aggiunta funzione OnlyChamfer. +-- 2022/05/24 Aggiunta fresatura da sotto su macchine con testa da sotto. -- Tabella per definizione modulo local ProcessProfHead = {} @@ -82,8 +83,8 @@ local function ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, dLenLst, -- confronto il punto iniziale e finale della lavorazione con il box della feature -- e se è vicino alla parte esterna della trave inverto la lavorazione - ptSP = EgtGetMachiningStartPoint() - ptEp = EgtGetMachiningEndPoint() + local ptSP = EgtGetMachiningStartPoint() + local ptEp = EgtGetMachiningEndPoint() local nMachMode = EgtGetMachiningParam( MCH_MP.STEPTYPE) if nMachMode == 1 and ptSP and ptEp then if abs( EgtIf( bHead, Proc.Box:getMax():getX(), Proc.Box:getMin():getX()) - ptSP:getX()) < @@ -418,9 +419,108 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end -- verifico se necessario lavorare in doppio - local bDouble = ( nSide ~= 0 and dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) + local bDouble = ( dProfDepth + BD.CUT_EXTRA > dToolMaxDepth) local dDepth = min( dToolMaxDepth, dProfDepth / 2 + BD.MILL_OVERLAP) - -- inserisco la lavorazione + -- se lavorazione da due parti, aggiungo la seconda + local sMillingDown + if bDouble then + if nSide == 0 then + if BD.DOWN_HEAD then + -- recupero la lavorazione + sMillingDown = ML.FindMilling( 'Prof_H2', nil, nil, nil, nil, false, true) + if not sMillingDown then + sWarn = 'Warning : milling from bottom not found in library' + EgtOutLog( sWarn) + bDouble = false + end + else + sWarn = 'Warning in profiling : depth (' .. EgtNumToString( dProfDepth, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dToolMaxDepth, 1) .. ')' + EgtOutLog( sWarn) + bDouble = false + end + end + end + -- se orizzontale o trovata lavorazione per doppio verticale + if bDouble then + -- inserisco la lavorazione + local sName = 'ProfB_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMchId = EgtAddMachining( sName, EgtIf( BD.DOWN_HEAD and nSide == 0, sMillingDown, sMilling)) + if not nMchId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + -- aggiungo geometria + EgtSetMachiningGeometry( {{ AuxId, -1}}) + -- resetto il flag inversione percorso + bFlagInvert = false + -- se lavorazione da sopra e da sotto + if ( nSide == 0) then + if vtExtr:getZ() > 0.1 then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + -- altrimenti lavorazione davanti e dietro + else + -- se lavorazione a destra di fronte o sinistra da dietro, inverto + if ( bHead and vtExtr:getY() > 0.1) or + ( not bHead and vtExtr:getY() < -0.1) then + EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + end + -- imposto l'affondamento + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + -- posizione braccio porta testa + EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) + -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale + local bFinish + local dOriOffset = 0 + local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + bFinish = true + end + -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente + if dOffsetPar > 0 then + EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) + end + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + else + -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno + -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco + -- e uscita + ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, + dLenLst, ( #vAngs > 0 and vAngs[1] == 0), ( #vAngs > 0 and vAngs[#vAngs] == (Proc.Fct-2)), bFlagInvert, dOffsetPar) + end + -- se abilitata, aggiungo lavorazione di finitura + if bFinish then + -- inserisco la lavorazione + local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) + local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) + if not nMch2Id then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + else + -- riporto il sovramateriale originale e tolgo i passi inutili + EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) + EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) + -- eseguo + if not ML.ApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMch2Id, false) + return false, sErr + end + end + end + end + -- inserisco la prima lavorazione local sName = 'Prof_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchId = EgtAddMachining( sName, sMilling) if not nMchId then @@ -474,7 +574,6 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) -- posizione braccio porta testa EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) -- variabili per gestione direzione percorso e per gestione lavorazione di finitura opzionale - local ptSP, ptEp local bFinish local dOriOffset = 0 local dOffsetPar = EgtGetInfo( Proc.Id, sOverMaterialForFinish, 'i') or 0 @@ -516,70 +615,6 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) end end end - -- se lavorazione da due parti, aggiungo la seconda - if bDouble then - -- inserisco la lavorazione - local sName = 'ProfB_' .. ( 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}}) - -- resetto il flag inversione percorso - bFlagInvert = false - -- sempre lavorazione da sopra o da sotto - -- se lavorazione a destra di fronte o sinistra da dietro, inverto - if ( bHead and vtExtr:getY() > 0.1) or - ( not bHead and vtExtr:getY() < -0.1) then - EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) - EgtSetMachiningParam( MCH_MP.INVERT, true) - bFlagInvert = not bFlagInvert - end - -- imposto l'affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) - -- posizione braccio porta testa - EgtSetMachiningParam( MCH_MP.SCC, EgtIf( bHead, MCH_SCC.ADIR_XP, MCH_SCC.ADIR_XM)) - -- se parametro sovramateriale è maggiore di 0 lo aggiungo al sovramateriale precedente - if dOffsetPar > 0 then - EgtSetMachiningParam( MCH_MP.OFFSR, ( dOriOffset + dOffsetPar)) - end - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr - else - -- applico controllo del punto entrata lavorazione e se non è distante dall'esterno - -- della feature inverto il punto di inizio della lavorazione e modifico i parametri dell'attacco - -- e uscita - ModifySideInvertLead( Proc, bHead, dToolDiam, dLenIni, - dLenLst, ( #vAngs > 0 and vAngs[1] == 0), ( #vAngs > 0 and vAngs[#vAngs] == (Proc.Fct-2)), bFlagInvert, dOffsetPar) - end - -- se abilitata, aggiungo lavorazione di finitura - if bFinish then - -- inserisco la lavorazione - local sNewName = 'ProfB_Fin_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) - local nMch2Id = EgtCopyMachining( sNewName, EgtGetName( nMchId)) - if not nMch2Id then - local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling - EgtOutLog( sErr) - return false, sErr - else - -- riporto il sovramateriale originale e tolgo i passi inutili - EgtSetMachiningParam( MCH_MP.OFFSR, dOriOffset) - EgtSetMachiningParam( MCH_MP.STEP, dToolMaxMat) - -- eseguo - if not ML.ApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMch2Id, false) - return false, sErr - end - end - end - end -- se parametro Q disabilitato, e consentito anche in alcuni casi lavorarlo con la feature da sotto -- inserisco eventuale finitura faccia finale (ortogonale alla trave o, se da sotto, parallela) if EgtGetInfo( Proc.Id, sEnableExtraMillUpperFace, 'i') ~= 1 and #vAngs > 0 then @@ -681,7 +716,7 @@ function ProcessProfHead.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH) BL.UpdateTCING( nRawId, Proc.Box:getMin():getX() - b3Solid:getMin():getX()) end end - return true + return true, sWarn end ---------------------------------------------------------------------