188 lines
8.9 KiB
Lua
188 lines
8.9 KiB
Lua
-- Strategia: STR0002
|
|
-- Descrizione
|
|
-- Svuotatura tasca
|
|
-- Feature:
|
|
-- Slot
|
|
-- FrontSlot
|
|
-- IsRidgeLap
|
|
-- IsLapJoint
|
|
-- IsNotchRabbet
|
|
-- IsNotch
|
|
-- IsPocket
|
|
-- Topology: 'Pocket-5-Blind'
|
|
-- 'Groove-4-Blind'
|
|
|
|
-- carico librerie
|
|
local BeamLib = require( 'BeamLib')
|
|
local BeamData = require( 'BeamData')
|
|
local MachLib = require( 'MachiningLib')
|
|
local FeatureData = require( 'FeatureData')
|
|
|
|
-- Tabella per definizione modulo
|
|
local STR0002 = {}
|
|
local Strategy = {}
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
local function IsTopologyOk( Proc)
|
|
if Proc.Topology.sName == 'Pocket-5-Blind' or Proc.Topology.sName == 'Groove-4-Blind' then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
function STR0002.Make( AddMachining, Proc, Part, CustomParameters)
|
|
-- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti)
|
|
local StrategyLib = {}
|
|
StrategyLib.Config = require( 'STR0002\\STR0002Config')
|
|
Strategy.sName = StrategyLib.Config.sStrategyId
|
|
CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters)
|
|
Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters)
|
|
Strategy.RatingResult = {}
|
|
|
|
if not IsTopologyOk( Proc) then
|
|
local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.Config.sStrategyId .. ' not implemented'
|
|
EgtOutLog( sErr)
|
|
return false, sErr
|
|
end
|
|
|
|
local ToolInfo = {}
|
|
|
|
-- serve utensile che possa lavorare di testa
|
|
local ToolSearchParameters = {}
|
|
ToolSearchParameters.sType = 'MILL_STD'
|
|
ToolSearchParameters.sMillShape = 'STANDARD'
|
|
ToolSearchParameters.dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.BottomFace.dHeight, Proc.MainFaces.BottomFace.dWidth)
|
|
ToolSearchParameters.dElevation = Proc.MainFaces.BottomFace.dElevation
|
|
ToolSearchParameters.vtToolDir = Proc.MainFaces.BottomFace.vtN
|
|
|
|
-- cerco utensile
|
|
ToolInfo = MachLib.FindMill( Proc, ToolSearchParameters)
|
|
|
|
if ToolInfo.nToolIndex and TOOLS[ToolInfo.nToolIndex].sName then
|
|
if ToolInfo.dMaxMatReduction < 0 then
|
|
Strategy.RatingResult.sStatus = 'Not-Completed'
|
|
else
|
|
Strategy.RatingResult.sStatus = 'Completed'
|
|
end
|
|
Strategy.RatingResult.dCompletionIndex = min( 100, ( ( Proc.MainFaces.BottomFace.dElevation + ToolInfo.dMaxMatReduction) / Proc.MainFaces.BottomFace.dElevation) * 100)
|
|
Strategy.RatingResult.dRating = FeatureData.GetFeatureRating( 'Mill', Strategy.RatingResult.dCompletionIndex)
|
|
Strategy.RatingResult.sInfo = ''
|
|
|
|
-- se richiesto applico lavorazione
|
|
if AddMachining then
|
|
-- TODO gestione spezzatura da completare
|
|
-- le lunghezza richiede spezzatura
|
|
if ( Proc.b3Box:getDimX() > BeamData.LONGCUT_MAXLEN) or ( Proc.b3Box:getDimX() > 0.7 * Part.b3Solid:getDimX() and Proc.b3Box:getDimX() > BeamData.LONGCUT_ENDLEN) then
|
|
-- recupero gruppo per geometria aggiuntiva
|
|
local nAddGrpId = BeamLib.GetAddGroup( Part.idPart)
|
|
local vAddId = {}
|
|
local bStartLeft, bStartRight
|
|
|
|
-- se feature inizia al di sotto del limite sinistro
|
|
if Proc.b3Box:getMin():getX() < Part.b3Solid:getMin():getX() + BeamData.LONGCUT_ENDLEN then
|
|
bStartLeft = true
|
|
end
|
|
-- se feature inizia al di sotto del limite destro
|
|
if Proc.b3Box:getMax():getX() > Part.b3Solid:getMax():getX() - BeamData.LONGCUT_ENDLEN then
|
|
bStartRight = true
|
|
end
|
|
|
|
-- salvo valori
|
|
local dNewMinX = Proc.b3Box:getMin():getX()
|
|
local dNewMaxX = Proc.b3Box:getMax():getX()
|
|
local dNewRest = Proc.b3Box:getDimX()
|
|
-- creo primo spezzone sulla sinistra
|
|
if bStartLeft then
|
|
local AddId = EgtCopyGlob( Proc.iod, nAddGrpId) or GDB_ID.NULL
|
|
dNewMinX = max( ( Proc.b3Box:getMin():getX() + TOOLS[ToolInfo.nToolIndex].dDiameter * 2), Part.b3Solid:getMin():getX() + BeamData.LONGCUT_ENDLEN)
|
|
local ptOn = Point3d( dNewMinX, 0, 0)
|
|
dNewRest = abs( dNewMaxX - dNewMinX)
|
|
-- taglio della superficie lato sinistro
|
|
EgtCutSurfTmPlane( AddId, ptOn, X_AX(), true, GDB_RT.GLOB)
|
|
-- eseguo inserimento
|
|
table.insert( vAddId, AddId)
|
|
end
|
|
-- creo spezzone sulla destra
|
|
if bStartRight then
|
|
local AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL
|
|
dNewMaxX = min( ( Proc.b3Box:getMax():getX() - TOOLS[ToolInfo.nToolIndex].dDiameter * 2), Part.b3Solid:getMax():getX() - BeamData.LONGCUT_ENDLEN)
|
|
local ptOn = Point3d( dNewMaxX, 0, 0)
|
|
dNewRest = abs( dNewMaxX - dNewMinX)
|
|
-- taglio della superficie lato destro
|
|
EgtCutSurfTmPlane( AddId, ptOn, -X_AX(), true, GDB_RT.GLOB)
|
|
-- eseguo inserimento
|
|
table.insert( vAddId, EgtIf( BeamData.RIGHT_LOAD, 2, 1),AddId)
|
|
end
|
|
-- lavoro il restante
|
|
local nSplitParts = max( ceil( dNewRest / BeamData.LONGCUT_MAXLEN + 10 * GEO.EPS_SMALL), 2)
|
|
local dSplitPartsLen = dNewRest / nSplitParts
|
|
for i = 1, nSplitParts do
|
|
local AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL
|
|
local ptOn
|
|
-- eseguo trim sinistro
|
|
if i ~= 1 or bStartLeft then
|
|
ptOn = Point3d( dNewMinX, 0, 0)
|
|
-- taglio della superficie lato sinistro
|
|
EgtCutSurfTmPlane( AddId, ptOn, -X_AX(), true, GDB_RT.GLOB)
|
|
end
|
|
-- eseguo trim destro
|
|
dNewMaxX = dNewMinX + dSplitPartsLen
|
|
if i ~= nSplitParts or bStartRight then
|
|
ptOn = Point3d( dNewMaxX, 0, 0)
|
|
-- taglio della superficie lato destro
|
|
EgtCutSurfTmPlane( AddId, ptOn, X_AX(), true, GDB_RT.GLOB)
|
|
end
|
|
-- il nuovo minimo è il punto massimo del precedente
|
|
dNewMinX = dNewMaxX
|
|
-- eseguo inserimento in modo da ordinare da X- a X+
|
|
table.insert( vAddId, EgtIf( BeamData.RIGHT_LOAD, 1+i, EgtIf( bStartLeft, 1, 2)), AddId)
|
|
end
|
|
-- si applicano le lavorazioni
|
|
for i = 1, #vAddId do
|
|
EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.nToolIndex].sName)
|
|
EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.nToolIndex].dStep)
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, ToolInfo.dMaxMatReduction))
|
|
EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.nToolIndex].dSideStep)
|
|
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT)
|
|
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.ZIGZAG)
|
|
EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.nToolIndex].dDiameter/2)
|
|
EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.nToolIndex].dDiameter/2)
|
|
for j=1, Proc.nFct do
|
|
local vtNSplitFace
|
|
_, vtNSplitFace = EgtSurfTmFacetCenter( vAddId[i], j - 1, GDB_ID.ROOT)
|
|
if vtNSplitFace and AreSameVectorExact( vtNSplitFace, Proc.MainFaces.BottomFace.vtN) then
|
|
EgtSetMachiningGeometry( {{ vAddId[i], j - 1}})
|
|
EgtApplyMachining( true, true)
|
|
break
|
|
end
|
|
end
|
|
end
|
|
else
|
|
EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.nToolIndex].sName)
|
|
EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.nToolIndex].dStep)
|
|
EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, ToolInfo.dMaxMatReduction))
|
|
EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.nToolIndex].dSideStep)
|
|
EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT)
|
|
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.ZIGZAG)
|
|
EgtSetMachiningParam( MCH_MP.LITANG, TOOLS[ToolInfo.nToolIndex].dDiameter/2)
|
|
EgtSetMachiningParam( MCH_MP.LIELEV, TOOLS[ToolInfo.nToolIndex].dDiameter/2)
|
|
EgtSetMachiningGeometry( {{ Proc.id, Proc.MainFaces.BottomFace.id}})
|
|
EgtApplyMachining( true, true)
|
|
end
|
|
end
|
|
else
|
|
Strategy.RatingResult.sStatus = 'Not-Applicable'
|
|
Strategy.RatingResult.dCompletionIndex = 0
|
|
Strategy.RatingResult.dRating = 0
|
|
Strategy.RatingResult.sInfo = 'Mill not found'
|
|
end
|
|
|
|
|
|
return Strategy.RatingResult
|
|
end
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
|
|
return STR0002 |