- in sawpluschain migliorata gestione errori chainsaw
- in sawpluschain migliorato riconoscimento facce laterali
This commit is contained in:
+43
-18
@@ -4589,6 +4589,7 @@ end
|
||||
--#region SawPlusChain
|
||||
local SawPlusChain = {}
|
||||
|
||||
|
||||
function SawPlusChain.IsTopologyOk( Proc)
|
||||
if Proc.TopologyLongName == 'Pocket-Blind-RightAngles-Parallel-5' or
|
||||
Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' or
|
||||
@@ -4599,6 +4600,7 @@ function SawPlusChain.IsTopologyOk( Proc)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.GetBottomFace( Proc)
|
||||
-- la faccia di fondo ha sempre Fct - 1 adiacenze. Se si trovano più facce di fondo si sceglie quella con minor elevazione
|
||||
local vBottomFace = Topology.GetFacesWithGivenAdjacencyNumber( Proc, Proc.vAdj, Proc.Fct - 1)
|
||||
@@ -4632,6 +4634,7 @@ function SawPlusChain.GetBottomFace( Proc)
|
||||
return BottomFace
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.GetFaceToMachine( Proc)
|
||||
if not Proc.Pocket.BottomFace or not Proc.Pocket.BottomFace.Id then
|
||||
Proc.Pocket.BottomFace = SawPlusChain.GetBottomFace( Proc)
|
||||
@@ -4667,10 +4670,14 @@ function SawPlusChain.GetFaceToMachine( Proc)
|
||||
return FaceToMachine
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.GetSideFaces( Proc)
|
||||
if not Proc.Pocket.BottomFace or not Proc.Pocket.BottomFace.Id then
|
||||
Proc.Pocket.BottomFace = SawPlusChain.GetBottomFace( Proc)
|
||||
end
|
||||
if not Proc.Pocket.FaceToMachine or not Proc.Pocket.FaceToMachine.Id then
|
||||
Proc.Pocket.FaceToMachine = SawPlusChain.GetFaceToMachine( Proc)
|
||||
end
|
||||
|
||||
-- si cercano le facce adiacenti a quella di fondo
|
||||
local FacesAdjacentToBottom = {}
|
||||
@@ -4683,11 +4690,13 @@ function SawPlusChain.GetSideFaces( Proc)
|
||||
end
|
||||
end
|
||||
|
||||
-- le facce laterali sono quelle che rimangono una volta escluse le due sopra e sotto, che sono le più lunghe
|
||||
-- se non 4 facce, le facce laterali sono quelle che rimangono una volta escluse le due sopra e sotto, che sono le più lunghe
|
||||
-- se 4 facce, le facce laterali sono le rimanenti esclusa quella da lavorare
|
||||
table.sort( FacesAdjacentToBottom, function( a, b) return a.LengthOnBottom > b.LengthOnBottom end)
|
||||
local SideFaces = {}
|
||||
for i = 1, #FacesAdjacentToBottom do
|
||||
if i > 2 then
|
||||
if ( Proc.Fct ~= 4 and i > 2) or
|
||||
( Proc.Fct == 4 and ( FacesAdjacentToBottom[i].Id ~= Proc.Pocket.FaceToMachine.Id)) then
|
||||
table.insert( SideFaces, FacesAdjacentToBottom[i])
|
||||
SideFaces[ #SideFaces].Id = FacesAdjacentToBottom[i].Id
|
||||
SideFaces[ #SideFaces].Width = Proc.Face[FacesAdjacentToBottom[i].Id + 1].Width
|
||||
@@ -4703,6 +4712,7 @@ function SawPlusChain.GetSideFaces( Proc)
|
||||
return SideFaces
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.GetToolFromMachining( sMachiningName)
|
||||
local Tool = {}
|
||||
if EgtMdbSetCurrMachining( sMachiningName) then
|
||||
@@ -4734,6 +4744,7 @@ function SawPlusChain.GetToolFromMachining( sMachiningName)
|
||||
return Tool
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.GetSCC( vtMachiningDirection)
|
||||
local nSCC = MCH_SCC.NONE
|
||||
if AreSameVectorApprox( vtMachiningDirection, Z_AX()) then
|
||||
@@ -4753,6 +4764,7 @@ function SawPlusChain.GetSCC( vtMachiningDirection)
|
||||
return nSCC
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.GetVerticalSteps( Proc, Machining)
|
||||
if not Proc.Pocket or not Proc.Pocket.Height then
|
||||
error( 'Missing pocket depth')
|
||||
@@ -4764,12 +4776,12 @@ function SawPlusChain.GetVerticalSteps( Proc, Machining)
|
||||
VerticalSteps.Count = ceil( ( Proc.Pocket.Height - 10 * GEO.EPS_SMALL) / Machining.Tool.Thickness)
|
||||
if VerticalSteps.Count > 1 then
|
||||
VerticalSteps.StepLength = ( Proc.Pocket.Height - Machining.Tool.Thickness) / ( VerticalSteps.Count - 1)
|
||||
VerticalSteps.StepType = MCH_MILL_ST.ONEWAY
|
||||
end
|
||||
|
||||
return VerticalSteps
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.GetHorizontalSteps( Machining)
|
||||
if not Machining.Depth then
|
||||
error( 'Missing machining depth')
|
||||
@@ -4784,6 +4796,7 @@ function SawPlusChain.GetHorizontalSteps( Machining)
|
||||
return HorizontalSteps
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.GetLeadInOut( Proc, Machining)
|
||||
-- si determina se l'inizio o la fine della lavorazione sono chiusi e l'eventuale riduzione da applicare
|
||||
local bIsStartClosed = false
|
||||
@@ -4850,11 +4863,13 @@ function SawPlusChain.GetLeadInOut( Proc, Machining)
|
||||
return LeadIn, LeadOut
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.ApplyMachining( Machining, sOperationNamePrefix, b3Raw)
|
||||
local sErr = ''
|
||||
local sOperationName = sOperationNamePrefix .. ( EgtGetName( Machining.ProcId) or tostring( Machining.ProcId)) .. '_' .. tostring( Machining.FaceToMachine.Id + 1)
|
||||
local nOperationId = EgtAddMachining( sOperationName, Machining.Name)
|
||||
if not nOperationId then
|
||||
local sErr = 'Error adding machining ' .. sOperationName .. '-' .. Machining.Name
|
||||
sErr = 'Error adding machining ' .. sOperationName .. '-' .. Machining.Name
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
@@ -4902,27 +4917,28 @@ function SawPlusChain.ApplyMachining( Machining, sOperationNamePrefix, b3Raw)
|
||||
|
||||
local bIsApplyOk = ML.ApplyMachining( true, false)
|
||||
if not bIsApplyOk then
|
||||
local _, sErr = EgtGetLastMachMgrError()
|
||||
sErr = EgtGetLastMachMgrError()
|
||||
EgtSetOperationMode( nOperationId, false)
|
||||
return false, sErr
|
||||
end
|
||||
|
||||
return true
|
||||
return true, sErr
|
||||
end
|
||||
|
||||
|
||||
function SawPlusChain.Make( Proc, b3Raw, bOnlySaw)
|
||||
Proc.Pocket = {}
|
||||
Proc.Pocket.Strategy = 'SawPlusChain'
|
||||
|
||||
if not SawPlusChain.IsTopologyOk( Proc) then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : Strategy ' .. Proc.Pocket.Strategy .. ' not implemented for topology ' .. Proc.TopologyLongName
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not implemented for topology ' .. Proc.TopologyLongName
|
||||
return false, sErr
|
||||
end
|
||||
|
||||
-- se tasca su faccia sotto la strategia non è applicabile (la sega a catena in generale non può lavorare da sotto)
|
||||
-- TODO se OnlySaw questo test è da rimuovere ma bisogna considerare anche la lama da sotto
|
||||
if Proc.AffectedFaces.Bottom then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ': Strategy not applicable - pocket on bottom face'
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket on bottom face'
|
||||
return false, sErr
|
||||
end
|
||||
|
||||
@@ -4940,7 +4956,7 @@ function SawPlusChain.Make( Proc, b3Raw, bOnlySaw)
|
||||
Cutting.ProcId = Proc.Id
|
||||
Cutting.Name = ML.FindCutting( 'HeadSide', true, false)
|
||||
if not Cutting.Name then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ': Strategy ' .. Proc.Pocket.Strategy .. ' not applicable - saw blade not found'
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - saw blade not found'
|
||||
return false, sErr
|
||||
end
|
||||
Cutting.Type = MCH_OY.MILLING
|
||||
@@ -4950,13 +4966,13 @@ function SawPlusChain.Make( Proc, b3Raw, bOnlySaw)
|
||||
-- verifica dimensioni tasca compatibili con lama
|
||||
-- se tasca meno spessa della lama la strategia non è applicabile
|
||||
if Cutting.Tool.Thickness > Proc.Pocket.Height - 10 * GEO.EPS_SMALL then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ': Strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for saw blade thickness'
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for saw blade thickness'
|
||||
return false, sErr
|
||||
end
|
||||
if Proc.Pocket.SideOpeningsCount == 0 then
|
||||
-- se tasca più stretta della lama la strategia non è applicabile
|
||||
if Cutting.Tool.Diameter > Proc.Pocket.Width - 10 * GEO.EPS_SMALL then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ': Strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for saw blade diameter'
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for saw blade diameter'
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
@@ -4987,6 +5003,7 @@ function SawPlusChain.Make( Proc, b3Raw, bOnlySaw)
|
||||
end
|
||||
-- step verticale e offset longitudinale
|
||||
Cutting.Steps = SawPlusChain.GetVerticalSteps( Proc, Cutting)
|
||||
Cutting.Steps.StepType = MCH_MILL_ST.ONEWAY
|
||||
Cutting.MaxElev = Cutting.Steps.StepLength * Cutting.Steps.Count - 10 * GEO.EPS_SMALL
|
||||
if Cutting.ToolInvert and Cutting.Steps.Count > 1 then
|
||||
Cutting.LongitudinalOffset = - Proc.Pocket.Height
|
||||
@@ -5032,9 +5049,12 @@ function SawPlusChain.Make( Proc, b3Raw, bOnlySaw)
|
||||
-- lavorazione di sega a catena e relativi dati
|
||||
local Chainsawing = {}
|
||||
Chainsawing.ProcId = Proc.Id
|
||||
Chainsawing.Name = ML.FindSawing( 'Sawing')
|
||||
Chainsawing.Name = ML.FindSawing( 'Sawing', Proc.Pocket.Depth)
|
||||
if not Chainsawing.Name then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ': Strategy ' .. Proc.Pocket.Strategy .. ' not applicable - chainsaw not found'
|
||||
Chainsawing.Name = ML.FindSawing( 'Sawing', nil, nil, 'Longest')
|
||||
end
|
||||
if not Chainsawing.Name then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - chainsaw not found'
|
||||
return false, sErr
|
||||
end
|
||||
Chainsawing.Type = MCH_OY.MORTISING
|
||||
@@ -5044,18 +5064,20 @@ function SawPlusChain.Make( Proc, b3Raw, bOnlySaw)
|
||||
-- verifica dimensioni tasca compatibili con sega a catena
|
||||
-- se tasca meno spessa della sega a catena la strategia non è applicabile
|
||||
if not bOnlySaw and Chainsawing.Tool.Thickness > Proc.Pocket.Height - 10 * GEO.EPS_SMALL then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ': Strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for chainsaw thickness'
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for chainsaw thickness'
|
||||
return false, sErr
|
||||
end
|
||||
|
||||
if Proc.Pocket.SideOpeningsCount == 0 then
|
||||
-- se tasca più stretta della sega a catena la strategia non è applicabile
|
||||
if not bOnlySaw and Chainsawing.Tool.Width > Proc.Pocket.Width - 10 * GEO.EPS_SMALL then
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ': Strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for chainsaw width'
|
||||
local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Proc.Pocket.Strategy .. ' not applicable - pocket too narrow for chainsaw width'
|
||||
return false, sErr
|
||||
end
|
||||
end
|
||||
|
||||
local sErrorMessageChainsawing = ''
|
||||
|
||||
-- parametri della lavorazione con sega a catena
|
||||
-- lato di lavoro e inversioni
|
||||
if Chainsawing.Tool.IsCCW then
|
||||
@@ -5073,7 +5095,7 @@ function SawPlusChain.Make( Proc, b3Raw, bOnlySaw)
|
||||
else
|
||||
Chainsawing.Depth = Chainsawing.Tool.MaxMat
|
||||
Chainsawing.LongitudinalOffset = Proc.Pocket.Depth - Chainsawing.Depth
|
||||
-- QUI WARNING DEL MANCATO COMPLETAMENTO DELLA TASCA
|
||||
sErrorMessageChainsawing = 'Feature '.. Proc.FeatureId .. ' : chainsawing elevation bigger than max tool depth'
|
||||
end
|
||||
-- offset radiale
|
||||
Chainsawing.RadialOffset = 0
|
||||
@@ -5098,10 +5120,13 @@ function SawPlusChain.Make( Proc, b3Raw, bOnlySaw)
|
||||
-- lavorazione con sega a catena
|
||||
Chainsawing.VerticalSteps = SawPlusChain.GetVerticalSteps( Proc, Chainsawing)
|
||||
local dOriginalRadialOffsetChainsawing = Chainsawing.RadialOffset
|
||||
local bIsChainsawingOk, sErrorMessageChainsawing
|
||||
local bIsChainsawingOk, sErrorMessageChainsawingApply
|
||||
for i = Chainsawing.VerticalSteps.Count, 1, -1 do
|
||||
Chainsawing.RadialOffset = dOriginalRadialOffsetChainsawing + Chainsawing.VerticalSteps.StepLength * ( i - 1)
|
||||
bIsChainsawingOk, sErrorMessageChainsawing = SawPlusChain.ApplyMachining( Chainsawing, 'Chainsaw_', b3Raw)
|
||||
bIsChainsawingOk, sErrorMessageChainsawingApply = SawPlusChain.ApplyMachining( Chainsawing, 'Chainsaw_', b3Raw)
|
||||
end
|
||||
if sErrorMessageChainsawingApply and #sErrorMessageChainsawingApply > 0 then
|
||||
sErrorMessageChainsawing = sErrorMessageChainsawing .. '\n' .. 'Apply : ' .. sErrorMessageChainsawingApply
|
||||
end
|
||||
|
||||
return bIsChainsawingOk, sErrorMessageChainsawing
|
||||
|
||||
Reference in New Issue
Block a user