- In LapJoint -> MakeStaircaseStep aggiunta la lavorazione con fresa

This commit is contained in:
luca.mazzoleni
2023-10-25 15:56:53 +02:00
parent 5865192e23
commit a7e0c5a33d
+122 -9
View File
@@ -5668,20 +5668,133 @@ local function TestTwoFacesDownHead( Proc)
end
---------------------------------------------------------------------
local function MakeStaircaseStep( Proc)
local function MakeStaircaseStep( Proc, nRawId, b3Raw, b3Solid)
-- angolo tra le facce
local _, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
-- se l'angolo tra le facce è maggiore di 90.5 o minore di 80 esco
if ( dAng > -80 + 10 * GEO.EPS_ANG_SMALL) or ( dAng < -90.5 - 10 * GEO.EPS_ANG_SMALL) then return false end
local _, _, _, dAng2 = EgtSurfTmFacetsContact( Proc.Id, 1, 0, GDB_ID.ROOT)
-- l'angolo tra le facce deve essere compreso tra 80 e 90.5 deg
if ( dAng > -89.5 + 10 * GEO.EPS_ANG_SMALL) or ( dAng < -100 - 10 * GEO.EPS_ANG_SMALL) then return false end
-- normali delle facce
local vtNRiser = EgtSurfTmFacetNormVersor( Proc.Id, 0, GDB_ID.ROOT)
local vtNTread = EgtSurfTmFacetNormVersor( Proc.Id, 1, GDB_ID.ROOT)
-- identifico quale faccia è l'alzata e quale la pedata
local nFaceRiser, nFaceTread = 0, 1
if vtNRiser:getZ() > vtNTread:getZ() then
nFaceRiser, nFaceTread = 1, 0
-- la faccia 0 è l'alzata (faccia più verticale), la 1 la pedata; se così non è le scambio
local nFacetRiser, nFacetTread = 0, 1
if abs( vtNRiser:getZ()) > abs( vtNTread:getZ()) then
EgtSurfTmSwapFacets( Proc.Id, 0, 1)
vtNRiser, vtNTread = vtNTread, vtNRiser
end
-- riferimenti e dimensioni delle facce
local rfFacRiser, dHRiser, dVRiser = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacetRiser, GDB_ID.ROOT)
local rfFacTread, dHTread, dVTread = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacetTread, GDB_ID.ROOT)
-- recupero la fresatura
-- verifico se fresatura da sopra
local bIsMillingUpward = ( vtNTread:getZ() >= BD.NZ_MINA)
-- fresatura
local sMilling = ML.FindMilling( 'BirdsMouth', nil, nil, nil, nil, bIsMillingUpward, not bIsMillingUpward)
if not sMilling then
local sErr = 'Error : BirdsMouth not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- dati utensile
local dMillDiam = 50
local dMillMaxMat = 0
local dMillRotationSpeed = 0
if EgtMdbSetCurrMachining( sMilling) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMillMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or dMillMaxMat
dMillRotationSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) or dMillRotationSpeed
end
end
-- recupero la lavorazione con lama
-- verifico se uso lama da sotto
local bCutDown = ( BD.DOWN_HEAD and rfFacTread:getVersZ():getZ() < - 0.5)
-- lavorazione con lama
local sCutting = ML.FindCutting( 'HeadSide', not bCutDown, bCutDown)
-- dati utensile
local dSawMaxDepth = 0
local dSawDiam = 400
local dSawRotationSpeed = 0
if sCutting then
if EgtMdbSetCurrMachining( sCutting) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dSawMaxDepth = EgtTdbGetCurrToolMaxDepth() or dSawMaxDepth
dSawRotationSpeed = EgtMdbGetCurrMachiningParam( MCH_MP.SPEED)or dSawRotationSpeed
end
end
end
-- fresatura pedata per fare spazio alla lama
local dMillingDepth = dVTread - dSawMaxDepth + dMillDiam/2 - 10
-- divido in passate orizzontali
local nHorizontalStepMilling = ceil( ( dMillingDepth - 100 * GEO.EPS_SMALL) / ( dMillDiam * 0.6))
local dHorizontalStepMilling = 0
if nHorizontalStepMilling > 1 then
dHorizontalStepMilling = ( dMillingDepth - dMillDiam * 0.6) / ( nHorizontalStepMilling - 1)
end
for i = nHorizontalStepMilling, 1, -1 do
-- inserisco la lavorazione
local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sMilling)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacetTread}})
-- imposto uso faccia
local nFaceUse = BL.GetNearestOrthoOpposite( vtNTread)
EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse)
-- imposto lato di lavoro e eventuale inversione
local bInvert = dMillRotationSpeed < 0
local nWorkSide = MCH_MILL_WS.LEFT
if bInvert then
nWorkSide = MCH_MILL_WS.RIGHT
end
EgtSetMachiningParam( MCH_MP.WORKSIDE, nWorkSide)
EgtSetMachiningParam( MCH_MP.INVERT, bInvert)
-- imposto posizione braccio porta testa
if vtNTread:getY() < GEO.EPS_SMALL then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
else
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- imposto attacchi e allungamenti
if nFacetTread then
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dMillDiam/2 + 10)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dMillDiam/2 + 10)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR)
EgtSetMachiningParam( MCH_MP.LITANG, 0)
EgtSetMachiningParam( MCH_MP.LOTANG, 0)
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
EgtSetMachiningParam( MCH_MP.LOPERP, 0)
end
-- imposto eventuale offset
EgtSetMachiningParam( MCH_MP.OFFSR, dVTread - dMillingDepth + i * dHorizontalStepMilling)
-- se step verticale non presente, lo setto
local dVerticalStepMilling = EgtGetMachiningParam( MCH_MP.STEP, 'd')
if not dVerticalStepMilling or dVerticalStepMilling <= 10 * GEO.EPS_SMALL then
dVerticalStepMilling = 0.25 * dMillDiam
end
EgtSetMachiningParam( MCH_MP.STEP, dVerticalStepMilling)
-- dichiaro non si generano sfridi per VMill
EgtSetMachiningParam( MCH_MP.USERNOTES, 'VMRS=0;')
-- eseguo
if not ML.ApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
-- eventuale segnalazione ingombro di testa o coda
UpdateEncumbrance( Proc, nRawId, b3Raw, b3Solid)
end
end
---------------------------------------------------------------------
@@ -5841,8 +5954,8 @@ function ProcessLapJoint.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
-- due facce
elseif Proc.Fct == 2 then
-- se V passante e attiva Q per lavorazione speciale scala
if Q_STAIRCASE == 1 and Proc.Topology == 'Groove' and Proc.IsThrough == true then
return MakeStaircaseStep( Proc)
if EgtGetInfo( Proc.Id, Q_STAIRCASE, 'i') == 1 and Proc.Topology == 'Groove' and Proc.IsThrough == true then
return MakeStaircaseStep( Proc, nRawId, b3Raw, b3Solid)
end
-- se praticamente è lunga come la trave e sono due facce lunghe
local b3Fac1 = EgtSurfTmGetFacetBBoxGlob( Proc.Id, 0, GDB_BB.STANDARD)