- spostate funzioni per verifica lavorazione adatta a doppio in MachiningLib

- aggiunte (commentate per ora) prime righe per riconoscimento percorsi fresature da specchiare
This commit is contained in:
luca.mazzoleni
2023-08-30 12:09:08 +02:00
parent afb33aa7c6
commit 5524fbf0cb
3 changed files with 74 additions and 59 deletions
+10 -58
View File
@@ -735,56 +735,6 @@ local function MakeLocalSurf( ptP1, ptP2, ptP3, nAddGrpId)
return nidFace
end
---------------------------------------------------------------------
local function IsToolDoubleOk( sToolMasterName, sToolDoubleName)
local bIsToolDoubleOk = false
-- dimensioni utensile master
EgtTdbSetCurrTool( sToolMasterName)
local bIsBlade = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false
local dTMaxMat = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT))
local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMat, EgtTdbGetCurrToolMaxDepth())
local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local dTDiamTh = EgtTdbGetCurrToolThDiam() or 0
local bTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0
local dTMaxDepthOnSide = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiam - dTDiamTh)))
-- dimensioni utensile double
EgtTdbSetCurrTool( sToolDoubleName)
local bIsBladeDouble = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false
local dTMaxMatDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT))
local dTMaxDepthDouble = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMatDouble, EgtTdbGetCurrToolMaxDepth())
local dTDiamDouble = EgtTdbGetCurrToolParam( MCH_TP.DIAM)
local dTDiamThDouble = EgtTdbGetCurrToolThDiam() or 0
local bTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0
local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble)))
-- controllo che siano uguali
bIsToolDoubleOk = ( bIsBlade == bIsBladeDouble) and
( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and
( dTMaxDepthDouble > dTMaxDepth - 100 * GEO.EPS_SMALL) and
( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and
( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and
( bTipFeed == bTipFeedDouble) and
( abs( dTMaxDepthOnSide - dTMaxDepthOnSideDouble) < GEO.EPS_SMALL) and
EgtTdbGetCurrToolParam( MCH_TP.ACTIVE)
return bIsToolDoubleOk
end
---------------------------------------------------------------------
local function IsMachiningOkForDouble( sMachining)
local bDoubleOk = false
if sMachining and EgtMdbSetCurrMachining( sMachining) then
-- recupero l'utensile della lavorazione
local sToolMasterName = EgtMdbGetCurrMachiningParam( MCH_MP.TOOL)
if EgtTdbSetCurrTool( sToolMasterName or '') then
-- cerco eventuale utensile in doppio
local sToolDoubleName = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'DOUBLE', 's')
if sToolDoubleName and EgtTdbSetCurrTool( sToolDoubleName) then
bDoubleOk = IsToolDoubleOk( sToolMasterName, sToolDoubleName)
end
end
end
return bDoubleOk
end
---------------------------------------------------------------------
local function AddMillCornerMachining( nPartId, nNewProc, nFacInd, tFacAdj, nTypeConeCut, nAddGrpId,
dToolDiam, dThick, sMilling, dOffsAng, dDepthMach,
@@ -1387,7 +1337,7 @@ local function MakeByMill( Proc, nFacet, nOthFac, nRawId, b3Raw, dSideDist)
if Proc.Double and Proc.Double == 2 then
local sMillingBackup = sMilling
sMilling = WM.FindMilling( 'Side', nil, nil, nil, nil, nil, nil, nil, 'H1')
if not IsMachiningOkForDouble( sMilling) then
if not WL.IsMachiningOkForDouble( sMilling) then
Proc.Double = 0
sMilling = sMillingBackup
end
@@ -1505,7 +1455,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
if Proc.Double and Proc.Double == 2 then
local sMillOnSideBackup = sMilling
sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, nil, 'H1')
if not IsMachiningOkForDouble( sMilling) then
if not WL.IsMachiningOkForDouble( sMilling) then
Proc.Double = 0
sMilling = sMillOnSideBackup
end
@@ -2223,6 +2173,8 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d
end
---------------------------------------------------------------------
-- trova la migliore lavorazione tasca in base a diametro utensile, elevazione, doppio e eventuale interferenza di parti vicine
-- se necessario forza la tasca a chiusa
local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
local dStartDiameter = dMaxDiameter
if Proc.AffectedFaces.Front then
@@ -2257,7 +2209,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
if Proc.Double and Proc.Double == 2 then
local sPocketingBackup = sPocketing
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1')
if not IsMachiningOkForDouble( sPocketing) then
if not WL.IsMachiningOkForDouble( sPocketing) then
Proc.Double = 0
sPocketing = sPocketingBackup
end
@@ -2294,7 +2246,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
if Proc.Double and Proc.Double == 2 then
local sPocketingBackup = sPocketing
sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1')
if not IsMachiningOkForDouble( sPocketing) then
if not WL.IsMachiningOkForDouble( sPocketing) then
Proc.Double = 0
sPocketing = sPocketingBackup
end
@@ -2302,7 +2254,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV)
end
-- recupero dati utensile
if EgtMdbSetCurrMachining( sPocketing) then
if sPocketing and EgtMdbSetCurrMachining( sPocketing) then
sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
@@ -2545,7 +2497,7 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw)
if Proc.Double and Proc.Double == 2 then
local sMillOnSideBackup = sMillOnSide
sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, dMaxThick, nil, dMinSideElev, 'H1')
if IsMachiningOkForDouble( sMillOnSide) then
if WL.IsMachiningOkForDouble( sMillOnSide) then
bDoubleMillOnSide = true
else
sMillOnSide = sMillOnSideBackup
@@ -2801,7 +2753,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw)
if Proc.Double and Proc.Double == 2 then
local sMillOnSideBackup = sMillOnSide
sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, min( dH, dV), nil, dSideElev, 'H1')
if IsMachiningOkForDouble( sMillOnSide) then
if WL.IsMachiningOkForDouble( sMillOnSide) then
bDoubleMillOnSide = true
else
sMillOnSide = sMillOnSideBackup
@@ -2863,7 +2815,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw)
if Proc.Double and Proc.Double == 2 then
local sMillOnSideBackup = sMillOnSide
sMillOnSide = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, dSideElevMultiplier * dSideElev, 'H1')
if IsMachiningOkForDouble( sMillOnSide) then
if WL.IsMachiningOkForDouble( sMillOnSide) then
bDoubleMillOnSide = true
else
sMillOnSide = sMillOnSideBackup