- in WallExec -> squadratura aggiunta funzione AddSquaring che verifica e aggiunge la squadratura in base al caso specifico

- in Squaring aggiunte funzioni per ricerca e controllo correttezza utensili in base al caso specifico
This commit is contained in:
luca.mazzoleni
2024-10-21 12:43:28 +02:00
parent d5e47c06fa
commit fdd114a8cd
2 changed files with 129 additions and 53 deletions
+92 -44
View File
@@ -13,51 +13,99 @@ EgtOutLog( ' Squaring started', 1)
local WD = require( 'WallData')
-------------------------------------------------------------------------------------------------------------
function Squaring.GetMachining( dDepth)
local Machining = {}
local nSquaringToolType = 0
if WD.SQUARING_EXTEND_Z and type( WD.SQUARING_EXTEND_Z) == "number" then
dDepth = dDepth + WD.SQUARING_EXTEND_Z
local function IsToolOk( Tool, dMachiningDepth)
local bIsToolOk = false
local bToolExists = false
local dToolMaxDepth = 0
bToolExists = Tool ~= {}
if bToolExists then
if Tool.nType == MCH_TY.MILL_NOTIP then
dToolMaxDepth = Tool.dThickness
else
dToolMaxDepth = Tool.dMaxDepth
end
end
bIsToolOk = bToolExists and ( dToolMaxDepth > dMachiningDepth - 10 * GEO.EPS_SMALL)
return bIsToolOk
end
-------------------------------------------------------------------------------------------------------------
function Squaring.GetTools()
local Tool = {}
local SquaringTools = {}
SquaringTools.Blade = {}
SquaringTools.Diskmill = {}
SquaringTools.Mill = {}
SquaringTools.Blade.H1 = {}
SquaringTools.Blade.H2 = {}
SquaringTools.Blade.H7 = {}
SquaringTools.Diskmill.H1 = {}
SquaringTools.Diskmill.H7 = {}
SquaringTools.Mill.H1 = {}
SquaringTools.Mill.H7 = {}
Tool.sName = EgtTdbGetFirstTool( MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE)
while Tool.sName ~= '' do
EgtTdbSetCurrTool( Tool.sName)
local bToolLoadedOnSetup = EgtFindToolInCurrSetup( Tool.sName)
local bIsSquaringTool = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SQUARING', 'b') or false
Tool.nType = EgtTdbGetCurrToolParam( MCH_TP.TYPE)
Tool.dThickness = EgtTdbGetCurrToolParam( MCH_TP.THICK)
Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)
Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial
Tool.sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD)
Tool.bIsCcw = EgtTdbGetCurrToolParam( MCH_TP.SPEED) < 0
if bToolLoadedOnSetup and Tool.nType and bIsSquaringTool then
-- lame
if Tool.nType == MCH_TY.SAW_FLAT or Tool.nType == MCH_TY.SAW_STD then
SquaringTools.Blade[Tool.sHead] = Tool
-- frese standard
elseif Tool.nType == MCH_TY.MILL_STD then
SquaringTools.Mill[Tool.sHead] = Tool
-- truciolatori
elseif Tool.nType == MCH_TY.MILL_NOTIP then
SquaringTools.Diskmill[Tool.sHead] = Tool
end
end
Tool = {}
Tool.sName = EgtTdbGetNextTool( MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE)
end
-- ricerca lavorazione di squadratura in base alle preferenze utente
if WD.SQUARING_TOOL and type( WD.SQUARING_TOOL) == "number" then
nSquaringToolType = WD.SQUARING_TOOL
end
-- lama
if nSquaringToolType == 0 or nSquaringToolType == 1 then
Machining.sSquaring = WM.FindCutting( 'Squaring', dDepth)
if Machining.sSquaring then
Machining.sType = 'Sawing'
end
end
-- fresa
if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 2) then
Machining.sSquaring = WM.FindMilling( 'Squaring', dDepth, nil, nil, nil, nil, true)
if Machining.sSquaring then
Machining.sType = 'Milling'
end
end
-- truciolatore
if not Machining.sSquaring and ( nSquaringToolType == 0 or nSquaringToolType == 3) then
Machining.sSquaring = WM.FindMilling( 'Squaring', nil, nil, nil, nil, nil, nil, dDepth)
if Machining.sSquaring then
Machining.sType = 'DiskMilling'
end
return SquaringTools
end
-------------------------------------------------------------------------------------------------------------
function Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth)
local bAreToolsOk = false
if sSquaringTool == 'DoubleDiskmill' then
bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth)
and IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL)
and IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL))
elseif sSquaringTool == 'DoubleDiskmillAndBlade' then
bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth)
and ( IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL) or IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL)))
elseif sSquaringTool == 'DoubleBlade' then
bAreToolsOk = ( IsToolOk( SquaringTools.Blade.H2, dMachiningDepth)
and ( IsToolOk( SquaringTools.Blade.H1, dMachiningDepth) or IsToolOk( SquaringTools.Blade.H7, dMachiningDepth)))
elseif sSquaringTool == 'Diskmill' then
bAreToolsOk = IsToolOk( SquaringTools.Diskmill.H1, WD.SQUARING_MAX_OVERMATERIAL) or IsToolOk( SquaringTools.Diskmill.H7, WD.SQUARING_MAX_OVERMATERIAL)
elseif sSquaringTool == 'Blade' then
bAreToolsOk = IsToolOk( SquaringTools.Blade.H2, dMachiningDepth)
elseif sSquaringTool == 'DoubleMill' then
bAreToolsOk = IsToolOk( SquaringTools.Mill.H1, dMachiningDepth) and IsToolOk( SquaringTools.Mill.H7, dMachiningDepth)
elseif sSquaringTool == 'Mill' then
bAreToolsOk = IsToolOk( SquaringTools.Mill.H1, dMachiningDepth) or IsToolOk( SquaringTools.Mill.H7, dMachiningDepth)
else
error( 'Squaring Tool not recognized')
end
-- recupero informazioni utensile
local bIsToolCCW
if Machining.sSquaring and EgtMdbSetCurrMachining( Machining.sSquaring) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
local dSpeed = ( EgtTdbGetCurrToolParam( MCH_TP.SPEED))
bIsToolCCW = dSpeed < 0
end
end
Machining.bIsPathCW = ( not( bIsToolCCW) and Machining.sType == 'Milling') or ( bIsToolCCW and Machining.sType ~= 'Milling')
return Machining
return bAreToolsOk
end
-------------------------------------------------------------------------------------------------------------
@@ -86,7 +134,7 @@ function Squaring.CreateGeometry( RawPart, Machining)
local nRightLineId = EgtLine( RawPart.nId, pt2, pt3, GDB_RT.GLOB)
local nBackLinedId = EgtLine( RawPart.nId, pt3, pt4, GDB_RT.GLOB)
local nLeftLineId = EgtLine( RawPart.nId, pt4, pt1, GDB_RT.GLOB)
if Machining.sType == 'DiskMilling' or Machining.sType == 'Milling' then
if Machining.sType == 'Diskmilling' or Machining.sType == 'Milling' then
EgtModifyCurveExtrusion( nFrontLineId, -Y_AX(), GDB_RT.GLOB)
EgtModifyCurveExtrusion( nRightLineId, X_AX(), GDB_RT.GLOB)
EgtModifyCurveExtrusion( nBackLinedId, Y_AX(), GDB_RT.GLOB)
@@ -165,7 +213,7 @@ function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationI
EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.LEFT)
elseif Machining.sType == 'Milling' then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
elseif Machining.sType == 'DiskMilling' then
elseif Machining.sType == 'Diskmilling' then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
end
EgtSetMachiningParam( MCH_MP.INVERT, true)
@@ -175,7 +223,7 @@ function Squaring.AddMachinings( Machining, SquaringGeometries, nFirstOperationI
EgtSetMachiningParam( MCH_MP.HEADSIDE, MCH_SAW_HS.RIGHT)
elseif Machining.sType == 'Milling' then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT)
elseif Machining.sType == 'DiskMilling' then
elseif Machining.sType == 'Diskmilling' then
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
end
EgtSetMachiningParam( MCH_MP.INVERT, false)
+37 -9
View File
@@ -1079,10 +1079,39 @@ local function SetMirroredOperations()
end
-------------------------------------------------------------------------------------------------------------
local function AddSquaring( sSquaringTool, RawPart, nFirstOperationId)
local function AddSquaring( sSquaringTool, RawPart)
local dMachiningDepth = RawPart.b3:getDimZ()
local bOk
local sMsg = ''
local SquaringTools = {}
local Geometry = {}
local OperationsId = {}
SquaringTools = Squaring.GetTools()
bOk = Squaring.AreToolsOk( sSquaringTool, SquaringTools, dMachiningDepth)
if not bOk then
sMsg = 'Squaring failed: cannot find matching tools'
return false, sMsg
end
bOk, Geometry = Squaring.CreateGeometry( sSquaringTool, RawPart, SquaringTools)
if not bOk then
sMsg = 'Squaring failed: cannot create geometry'
return false, sMsg
end
bOk, sMsg, OperationsId = Squaring.AddMachinings( sSquaringTool, SquaringTools, Geometry)
if not bOk then
for i = 1, #OperationsId do
EgtRemoveOperation( i)
end
sMsg = 'Squaring failed: cannot apply machinings'
return false, sMsg
end
Squaring.AddScrapRemoval()
return true, sMsg
end
-------------------------------------------------------------------------------------------------------------
@@ -1237,29 +1266,28 @@ function WallExec.ProcessFeatures()
-- squadratura, se richiesta
if WD.SQUARING_TYPE and WD.SQUARING_TYPE > 0 then
local RawPart = { nId = nRawId, b3 = b3Raw}
local nFirstOperationId = EgtGetNextOperation( EgtGetPhaseDisposition( nPhase))
local bOk, sMsg
if WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 1 then
bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart, nFirstOperationId)
bOk, sMsg = AddSquaring( 'DoubleDiskmill', RawPart)
end
if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 2) then
bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart, nFirstOperationId)
bOk, sMsg = AddSquaring( 'DoubleDiskmillAndBlade', RawPart)
end
if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 3) then
bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart, nFirstOperationId)
bOk, sMsg = AddSquaring( 'DoubleBlade', RawPart)
end
if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 4) then
bOk, sMsg = AddSquaring( 'Diskmill', RawPart, nFirstOperationId)
bOk, sMsg = AddSquaring( 'Diskmill', RawPart)
end
if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 5) then
bOk, sMsg = AddSquaring( 'Blade', RawPart, nFirstOperationId)
bOk, sMsg = AddSquaring( 'Blade', RawPart)
end
if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 6) then
bOk, sMsg = AddSquaring( 'DoubleMill', RawPart, nFirstOperationId)
bOk, sMsg = AddSquaring( 'DoubleMill', RawPart)
end
if not bOk and ( WD.SQUARING_TOOL == 0 or WD.SQUARING_TOOL == 7) then
bOk, sMsg = AddSquaring( 'Mill', RawPart, nFirstOperationId)
bOk, sMsg = AddSquaring( 'Mill', RawPart)
end
if not bOk then