diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 35d2dcc..78d84d3 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -28,14 +28,16 @@ local function SetCurrMachiningAndTool( sMachName) end --------------------------------------------------------------------- -function WMachiningLib.FindCutting( sType) +function WMachiningLib.FindCutting( sType, dDepth) for i = 1, #Cuttings do local Cutting = Cuttings[i] if Cutting.On and Cutting.Type == sType and SetCurrMachiningAndTool( Cutting.Name) then local dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or 0 local dSawThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) or 0 local dSawMaxDepth = EgtTdbGetCurrToolMaxDepth() or 0 - return Cutting.Name, dSawDiam, dSawThick, dSawMaxDepth + if not dDepth or dSawMaxDepth > dDepth - 10 * GEO.EPS_SMALL then + return Cutting.Name, dSawDiam, dSawThick, dSawMaxDepth + end end end end diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index 010fd7f..3476b7a 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -1,4 +1,4 @@ --- ProcessFreeContour.lua by Egaltech s.r.l. 2021/02/19 +-- ProcessFreeContour.lua by Egaltech s.r.l. 2021/03/11 -- Gestione calcolo profilo libero per Pareti -- Tabella per definizione modulo @@ -1091,6 +1091,8 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd dMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth()) or dMaxDepth end end + -- se entità singola in parte fatta con lama, non lavoro + if #vFace == 1 and vFace[1].Type ~= 4 then return true end -- verifico se ciclo chiuso local bClosed = ( abs( vFace[1].PrevAng) > 0.1) -- ciclo di inserimento delle fresate sulle facce del contorno in esame @@ -1191,7 +1193,7 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd local dEal = 0 local OrigI = i i = i + 1 - local j = EgtIf( i <= #vFace, i, EgtIf( bAllType4, nil, 1)) + local j = EgtIf( i <= #vFace, i, EgtIf( bAllType4 or not bClosed, nil, 1)) while j and ( ( vFace[j].Type & 1) ~= 0 or vFace[j].Type == 4) and abs( vFace[j].SideAng - vFace[OrigI].SideAng) < 0.1 do table.insert( vGeom, { Proc.Id, vFace[j].Fac}) dEal = EgtIf( ( vFace[j].Type & 1) ~= 0, vFace[j].Whisk - vFace[j].Len, 0) @@ -1201,6 +1203,11 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd i = i + 1 j = EgtIf( j + 1 <= #vFace, j + 1, EgtIf( bAllType4 or not bClosed, nil, 1)) end + -- se faccia singola è da fare tutta senza oltrepassare estremi + if #vFace == 1 then + dSal = -dMillDiam / 2 + dEal = -dMillDiam / 2 + end -- se non devo scaricare l'angolo if nConeCut <= 1 then EgtSetMachiningGeometry( vGeom) @@ -1470,6 +1477,7 @@ local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw, dSawThick) return false, sErr end EgtSetInfo( nMchId, 'Part', Proc.PartId) + local dSpeed = EgtGetMachiningParam( MCH_MP.SPEED) -- aggiungo geometria EgtSetMachiningGeometry( { { Proc.Id, vFace[i].Fac}}) -- assegno affondamento @@ -1485,8 +1493,8 @@ local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw, dSawThick) EgtSetMachiningParam( MCH_MP.INVERT, bInvert) -- imposto lato di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( bInvert, MCH_SAW_WS.LEFT, MCH_SAW_WS.RIGHT)) - -- lato mandrino sempre a sinistra (rotazione lama oraria) - EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT) + -- lato mandrino ( a sinistra se rotazione CCW, altrimenti a destra) + EgtSetMachiningParam( MCH_MP.HEADSIDE, EgtIf( dSpeed < 0, MCH_SAW_HS.LEFT, MCH_SAW_HS.RIGHT)) -- assegno i dati di attacco (sicurezza solo se angolo interno) local nLeadIn = MCH_SAW_LI.CENT if ( not bInvert and ( vFace[i].Type & 1) ~= 0) or ( bInvert and ( vFace[i].Type & 2) ~= 0) then @@ -1509,9 +1517,15 @@ local function AddCuts( sCutting, vFace, Proc, nRawId, b3Raw, dSawThick) EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.NONE) -- eseguo if not EgtApplyMachining( true, false) then - local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) - return false, sErr + -- provo a invertire direzione e lato di lavoro + EgtSetMachiningParam( MCH_MP.INVERT, not bInvert) + EgtSetMachiningParam( MCH_MP.WORKSIDE, EgtIf( not bInvert, MCH_SAW_WS.LEFT, MCH_SAW_WS.RIGHT)) + -- ri-eseguo + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchId, false) + return false, sErr + end end -- se limite lunghezza di taglio e taglio lo supera if WD.CUT_MAX_LENGTH and vFace[i].Len > WD.CUT_MAX_LENGTH then @@ -1555,11 +1569,18 @@ local function MakeByCut( Proc, nRawId, b3Raw) end if vtExtr:getZ() < 0 then bNegZ = true end end + -- altezza massima delle facce + local dWidth = 0 + for i = 1, Proc.Fct do + local _, _, dFctW = WL.GetFaceHvRefDim( Proc.Id, i - 1) + dWidth = max( dWidth, dFctW) + end -- lettura parametri (probabile/i parametro/i Q) local nConeCut = VerifyCornerType( Proc) - -- recupero la lavorazione di taglio con lama e i suoi parametri - local sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard') + -- recupero la lavorazione di taglio con lama e i suoi parametri (dapprima cerco quella che possa tagliare completamente) + local sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard', dWidth) if not sCutting then + sCutting, dSawDiam, dSawThick, dSawMaxDepth = WM.FindCutting( 'Standard') local sErr = 'Error : cutting not found in library' EgtOutLog( sErr) return false, sErr @@ -1767,7 +1788,7 @@ local function MakeByNail( Proc, nRawId, b3Raw) EgtSetMachiningParam( MCH_MP.TOOLINVERT, true) end -- assegno affondamento - EgtSetMachiningParam( MCH_MP.DEPTH, 2) + EgtSetMachiningParam( MCH_MP.DEPTH, 10) -- assegno lato di lavoro EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.CENTER) -- eseguo diff --git a/Process.lua b/Process.lua index 1425ab3..9df416c 100644 --- a/Process.lua +++ b/Process.lua @@ -141,6 +141,8 @@ local function MyProcessInputData() vWall[i].PosX = vWall[i].PosX - vWall[i].Box:getDimX() if abs( dRotAng - 0) < GEO.EPS_ANG_SMALL then vWall[i].PosZ = vWall[i].PosZ - vWall[i].Box:getDimY() + elseif abs( dRotAng - 180) < GEO.EPS_ANG_SMALL or abs( dRotAng + 180) < GEO.EPS_ANG_SMALL then + vWall[i].PosX = vWall[i].PosX + vWall[i].Box:getDimX() end elseif abs( dInvAng - 270) < GEO.EPS_ANG_SMALL or abs( dInvAng + 90) < GEO.EPS_ANG_SMALL then if abs( dRotAng - 0) < GEO.EPS_ANG_SMALL then