DataBeam :

- migliorie e correzioni varie
- unificati BirdsMouth con LapJoint.
This commit is contained in:
Dario Sassi
2019-07-03 10:27:55 +00:00
parent 9ac596d5d7
commit 7c1a4ba546
20 changed files with 473 additions and 511 deletions
+76 -23
View File
@@ -1,4 +1,4 @@
-- BatchProcess.lua by Egaltech s.r.l. 2019/04/01
-- BatchProcess.lua by Egaltech s.r.l. 2019/07/01
-- Gestione calcolo batch disposizione e lavorazioni per Travi
@@ -7,6 +7,12 @@ require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Per test
--BEAM = {}
--BEAM.FILE = 'c:\\TechnoEssetre7\\EgtBtl\\Part_15_116.btl'
--BEAM.MACHINE = 'FAST'
--BEAM.FLAG = 3
-- Log dati di generazione
local sLog = 'BatchProcess : ' .. BEAM.FILE .. ', ' .. BEAM.MACHINE .. ', ' .. tostring( BEAM.FLAG)
EgtOutLog( sLog)
@@ -16,22 +22,30 @@ local sLogFile = EgtChangePathExtension( BEAM.FILE, '.txt')
EgtEraseFile( sLogFile)
-- Funzione per scrittura su file di log specifico
local function WriteLogFile( nErr, sErr, nCutId, nTaskId)
if nErr ~= 0 then
EgtOutLog( sErr .. ' (' .. tostring( nErr) ..')')
end
local hFile = io.open( sLogFile, 'w')
local function WriteLogFile( nErr, sMsg, nCutId, nTaskId)
local hFile = io.open( sLogFile, 'a')
hFile:write( 'ERR=' .. tostring( nErr) .. '\n')
if nErr ~= 0 then
hFile:write( 'CUTID=' .. tostring( nCutId or 0) .. '\n')
hFile:write( 'TASKID=' .. tostring( nTaskId or 0) .. '\n')
hFile:write( sErr .. '\n')
end
hFile:write( sMsg .. '\n')
hFile:write( 'CUTID=' .. tostring( nCutId or 0) .. '\n')
hFile:write( 'TASKID=' .. tostring( nTaskId or 0) .. '\n')
hFile:close()
end
-- Funzione per gestire visualizzazione dopo errore
local function PostErrView( nErr, sMsg)
if nErr ~= 0 and ( BEAM.FLAG == 1 or BEAM.FLAG == 2) then
EgtSetView( SCE_VD.ISO_SW, false)
EgtZoom( SCE_ZM.ALL)
EgtOutBox( sErr .. ' (error ' .. tostring( nErr) .. ')', 'BatchProcess', 'ERROR')
EgtOutBox( sMsg .. ' (error ' .. tostring( nErr) .. ')', 'BatchProcess', 'ERRORS')
end
end
-- Funzione per gestire visualizzazione dopo errore
local function PostWarnView( nWarn, sMsg)
if nWarn ~= 0 and ( BEAM.FLAG == 1 or BEAM.FLAG == 2) then
EgtSetView( SCE_VD.ISO_SW, false)
EgtZoom( SCE_ZM.ALL)
EgtOutBox( sMsg .. ' (warning ' .. tostring( nWarn) .. ')', 'BatchProcess', 'WARNINGS')
end
end
@@ -46,6 +60,7 @@ if not EgtSetCurrMachine( sMachine) then
BEAM.ERR = 11
BEAM.MSG = 'Error selecting machine : ' .. sMachine
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -55,6 +70,7 @@ if not EgtExistsFile( sMachDir .. '\\Beam\\BeamData.lua') then
BEAM.ERR = 12
BEAM.MSG = 'Error not configured for beams machine : ' .. sMachine
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -79,6 +95,7 @@ if not EgtImportBtl( BEAM.FILE, EIB_FL.TS3_POS) then
BEAM.ERR = 13
BEAM.MSG = 'Error importing BTL file : ' .. BEAM.FILE
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -93,6 +110,7 @@ if #vBeam == 0 then
BEAM.ERR = 14
BEAM.MSG = 'Error no beams in the file : ' .. BEAM.FILE
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
else
local sOut = ''
@@ -111,6 +129,7 @@ for i = 1, #vBeam do
BEAM.ERR = 15
BEAM.MSG = 'Box undefined for beam ' .. vBeam[i].Name
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
else
vBeam[i].Box = b3Solid
@@ -156,6 +175,7 @@ if #vBeamErr > 0 then
BEAM.ERR = 16
BEAM.MSG = sOut
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -166,6 +186,7 @@ if dRawW > BD.MAX_WIDTH + 10 * GEO.EPS_SMALL or dRawH > BD.MAX_HEIGHT + 10 * GEO
BEAM.ERR = 17
BEAM.MSG = sOut
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -180,6 +201,7 @@ if not bPbOk then
BEAM.ERR = 18
BEAM.MSG = sPbErr
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
@@ -191,14 +213,42 @@ EgtSetInfo( EgtGetCurrMachGroup(), 'NcName', sName .. '.cnc')
EgtSetInfo( EgtGetCurrMachGroup(), 'Vm', '1')
-- Lavoro le features
local bPfOk, sPfErr, nPfCutId, nPfTaskId = BE.ProcessFeatures()
if not bPfOk then
BEAM.ERR = 19
BEAM.MSG = sPfErr
BEAM.CUTID = nPfCutId
BEAM.TASKID = nPfTaskId
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
local bPfOk, Stats = BE.ProcessFeatures()
local nErrCnt = 0
local nWarnCnt = 0
local sOutput = ''
for i = 1, #Stats do
if Stats[i].Err == 0 then
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d Ok\n', Stats[i].CutId, Stats[i].TaskId)
BEAM.ERR = 0
BEAM.MSG = ''
BEAM.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
elseif Stats[i].Err > 0 then
nErrCnt = nErrCnt + 1
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg)
BEAM.ERR = 19
BEAM.MSG = Stats[i].Msg
BEAM.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
elseif Stats[i].Err < 0 then
nWarnCnt = nWarnCnt + 1
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg)
BEAM.ERR = -19
BEAM.MSG = Stats[i].Msg
BEAM.CUTID = Stats[i].CutId
BEAM.TASKID = Stats[i].TaskId
WriteLogFile( BEAM.ERR, BEAM.MSG, BEAM.CUTID, BEAM.TASKID)
end
end
if #sOutput > 0 then EgtOutLog( sOutput) end
if nErrCnt > 0 then
PostErrView( 19, sOutput)
return
elseif nWarnCnt > 0 then
PostWarnView( 19, sOutput)
end
-- Salvo il progetto
@@ -211,6 +261,7 @@ if BEAM.FLAG == 0 then
BEAM.ERR = 20
BEAM.MSG = 'Error generating NC part program : ' .. sName
WriteLogFile( BEAM.ERR, BEAM.MSG)
PostErrView( BEAM.ERR, BEAM.MSG)
return
end
end
@@ -220,7 +271,9 @@ if BEAM.FLAG == 1 or BEAM.FLAG == 2 then
EgtSetView( SCE_VD.ISO_SW, false)
end
-- Completamento senza errori
BEAM.ERR = 0
BEAM.MSG = ''
WriteLogFile( BEAM.ERR, BEAM.MSG)
-- Completamento senza errori e avvisi
if nWarnCnt == 0 then
BEAM.ERR = 0
BEAM.MSG = ''
WriteLogFile( BEAM.ERR, BEAM.MSG)
end
+83 -54
View File
@@ -1,4 +1,4 @@
-- BeamExec.lua by Egaltech s.r.l. 2019/06/14
-- BeamExec.lua by Egaltech s.r.l. 2019/07/01
-- Libreria esecuzione lavorazioni per Travi
-- Tabella per definizione modulo
@@ -37,8 +37,6 @@ _G.package.loaded.ProcessLongCut = nil
local LongCut = require( 'ProcessLongCut')
_G.package.loaded.ProcessLongDoubleCut = nil
local Long2Cut = require( 'ProcessLongDoubleCut')
_G.package.loaded.ProcessBirdsMouth = nil
local BirdsMouth = require( 'ProcessBirdsMouth')
_G.package.loaded.ProcessRidgeLap = nil
local RidgeLap = require( 'ProcessRidgeLap')
_G.package.loaded.ProcessLapJoint = nil
@@ -205,9 +203,6 @@ local function IsHeadFeature( Proc, b3Raw, dCurrOvmH)
return ( Proc.Box:getCenter():getX() > b3Raw:getCenter():getX())
end
-- gestioni speciali
if BirdsMouth.Identify( Proc) then
return BirdsMouth.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
end
if LapJoint.Identify( Proc) then
return LapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
end
@@ -236,9 +231,6 @@ local function IsTailFeature( Proc, b3Raw)
return ( Proc.Box:getCenter():getX() < b3Raw:getCenter():getX())
end
-- gestioni speciali
if BirdsMouth.Identify( Proc) then
return BirdsMouth.IsTailFeature( Proc, b3Raw)
end
if LapJoint.Identify( Proc) then
return LapJoint.IsTailFeature( Proc, b3Raw)
end
@@ -271,6 +263,8 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH)
local nGrp = EgtGetInfo( ProcId, 'GRP', 'i')
local nPrc = EgtGetInfo( ProcId, 'PRC', 'i')
local nDo = EgtGetInfo( ProcId, 'DO', 'i') or 1
local nCutId = EgtGetInfo( EgtGetParent( EgtGetParent( ProcId)), 'CUTID', 'i') or 0
local nTaskId = EgtGetInfo( ProcId, 'TASKID', 'i') or 0
if nGrp and nPrc and nDo == 1 then
local Proc = {}
Proc.Id = ProcId
@@ -284,6 +278,8 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH)
Proc.Diam = 0
Proc.Fcs = 0
Proc.Fce = 0
Proc.CutId = nCutId
Proc.TaskId = nTaskId
table.insert( vProc, Proc)
-- se foro
if Drill.Identify( Proc) then
@@ -309,6 +305,8 @@ local function CollectFeatures( PartId, b3Raw, dCurrOvmH)
Proc2.Tail = Drill.IsTailFeature( Proc2, b3Raw)
Proc2.Fcs = Proc.Fce
Proc2.Fce = Proc.Fcs
Proc2.CutId = Proc.CutId
Proc2.TaskId = Proc.TaskId
table.insert( vProc, Proc2)
end
end
@@ -358,7 +356,7 @@ local function OrderFeatures( vProc, b3Raw)
return B1.Box:getMax():getX() + 100 > B2.Box:getCenter():getX()
end
-- se sono fori e hanno posizione praticamente uguale ordino secondo diametro e faccia di inizio (Fcs)
if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < 200 then
if B1.Prc == 40 and B2.Prc == 40 and abs( B1.Box:getCenter():getX() - B2.Box:getCenter():getX()) < 400 then
if abs( B1.Diam - B2.Diam) < 1.0 then
if B1.Fcs == B2.Fcs then
return B1.Box:getCenter():getX() > B2.Box:getCenter():getX()
@@ -404,10 +402,12 @@ local function OrderFeatures( vProc, b3Raw)
end
-------------------------------------------------------------------------------------------------------------
local function ClassifyFeatures( vProc, b3Raw)
local function ClassifyFeatures( vProc, b3Raw, Stats)
local bAllOk = true
local bSomeDown = false
local bSplitRot = false
local nHeading
local nSplitting
for i = 1, #vProc do
local Proc = vProc[i]
local bOk = true
@@ -415,6 +415,9 @@ local function ClassifyFeatures( vProc, b3Raw)
-- se intestatura
if Hcut.Identify( Proc) then
nHeading = i
-- se separazione
elseif Split.Identify( Proc) then
nSplitting = i
-- se doppio taglio
elseif DoubleCut.Identify( Proc) then
bOk, bDown = DoubleCut.Classify( Proc)
@@ -424,13 +427,10 @@ local function ClassifyFeatures( vProc, b3Raw)
-- se doppio taglio longitudinale
elseif Long2Cut.Identify( Proc) then
bOk, bDown = Long2Cut.Classify( Proc)
-- se tacca
elseif BirdsMouth.Identify( Proc) then
bOk, bDown = BirdsMouth.Classify( Proc)
-- se mezzo-legno di testa
elseif RidgeLap.Identify( Proc) then
bOk, bDown = RidgeLap.Classify( Proc)
-- se mezzo-legno, fessura, fessura frontale, notch, tasca
-- se mezzo-legno, fessura, fessura frontale, notch, tasca, tacca
elseif LapJoint.Identify( Proc) then
bOk, bDown = LapJoint.Classify( Proc)
-- se foratura
@@ -469,11 +469,17 @@ local function ClassifyFeatures( vProc, b3Raw)
end
-- assegno risultato
if bOk then
-- non ammessa feature di testa o di coda da lavorare ribaltata
if ( Proc.Head or Proc.Tail) and bDown then
-- non ammessa feature di testa da lavorare ribaltata
if Proc.Head and bDown then
Proc.Flg = 0
Proc.Down = true
bAllOk = false
table.insert( Stats, {Err = 1, Msg='Error : impossible to machine by orientation', CutId=Proc.CutId, TaskId=Proc.TaskId})
-- gestione feature di coda da lavorare ribaltata
elseif Proc.Tail and bDown then
Proc.Down = true
bSomeDown = true
bSplitRot = true
-- caso normale
else
Proc.Down = bDown
@@ -488,7 +494,11 @@ local function ClassifyFeatures( vProc, b3Raw)
if bSomeDown and nHeading then
vProc[nHeading].Down = true
end
return bAllOk, bSomeDown
-- se necessaria rotazione del ribaltato, assegno separazione alla fase ribaltata
if bSplitRot then
vProc[nSplitting].Down = true
end
return bAllOk, bSomeDown, bSplitRot
end
-------------------------------------------------------------------------------------------------------------
@@ -496,8 +506,9 @@ local function PrintFeatures( vProc, b3Raw)
EgtOutLog( ' RawBox=' .. tostring( b3Raw))
for i = 1, #vProc do
local Proc = vProc[i]
local sOut = string.format( ' Proc=%3d Grp=%1d Prc=%3d Flg=%2d Down=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s',
Proc.Id, Proc.Grp, Proc.Prc, Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', 'F'),
local sOut = string.format( ' Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Down=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s',
Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId,
Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', 'F'),
Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, tostring( Proc.Box))
EgtOutLog( sOut)
end
@@ -544,15 +555,11 @@ local function AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3
else
bOk, sErr = LongCut.Make( Proc, nPhase, nRawId, nPartId)
end
-- se tacca ( 3/4-020-X)
elseif BirdsMouth.Identify( Proc) then
-- esecuzione tacca
bOk, sErr = BirdsMouth.Make( Proc, nPhase, nRawId, nPartId)
-- se mezzo-legno di testa ( 1/2-030-X)
elseif RidgeLap.Identify( Proc) then
-- esecuzione mezzo-legno di testa
bOk, sErr = RidgeLap.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
-- se mezzo-legno ( 3/4-030-X) o scanalatura ( 3/4-016-X)
-- se mezzo-legno ( 3/4-030-X) o scanalatura ( 3/4-016-X) o tacca ( 3/4-020-X)
elseif LapJoint.Identify( Proc) then
-- esecuzione mezzo-legno o scanalatura
bOk, sErr = LapJoint.Make( Proc, nPhase, nRawId, nPartId, dCurrOvmH)
@@ -635,10 +642,8 @@ end
-------------------------------------------------------------------------------------------------------------
function BeamExec.ProcessFeatures()
local bAddOk = true
local sAddErrors = ''
local nCutId
local nTaskId
local nTotErr = 0
local Stats = {}
local nOrd = 1
local nRawId = EgtGetFirstRawPart()
while nRawId do
@@ -664,10 +669,9 @@ function BeamExec.ProcessFeatures()
-- le ordino lungo X
OrderFeatures( vProc, b3Raw)
-- le classifico
local bOk, bSomeDown = ClassifyFeatures( vProc, b3Raw)
if not bOk then
bAddOk = false
sAddErrors = 'Warning : some features not machinable'
local bAllOk, bSomeDown, bSplitRot = ClassifyFeatures( vProc, b3Raw, Stats)
if not bAllOk then
nTotErr = nTotErr + 1
end
-- debug
if EgtGetDebugLevel() >= 1 then
@@ -687,22 +691,47 @@ function BeamExec.ProcessFeatures()
-- creo la lavorazione
local Proc = vProc[i]
if Proc.Flg ~= 0 and Proc.Down then
local bOk, sErr = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
local bOk, sMsg, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
if not bOk then
bAddOk = false
sAddErrors = sAddErrors .. sErr .. '\n'
if not nCutId then
nCutId = EgtGetInfo( EgtGetParent( EgtGetParent( Proc.Id)), 'CUTID', 'i')
nTaskId = EgtGetInfo( Proc.Id, 'TASKID', 'i')
end
nTotErr = nTotErr + 1
table.insert( Stats, {Err=1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId})
elseif sMsg and #sMsg > 0 then
table.insert( Stats, {Err=-1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId})
else
table.insert( Stats, {Err=0, Msg='', CutId=Proc.CutId, TaskId=Proc.TaskId})
end
-- se era taglio di separazione, aggiungo nuova fase
if bNewPhase then
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, BD.RAW_OFFSET)
EgtRotateRawPart( nRawId, X_AX(), 180)
-- se grezzo successivo senza pezzi e finale, va tolto
local nNextRawId = EgtGetNextRawPart( nRawId)
if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BD.MinRaw then
EgtRemoveRawPartFromCurrPhase( nNextRawId)
end
nPhase = EgtGetCurrPhase()
nDispId = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( nDispId, 'TYPE', 'MID2')
EgtSetInfo( nDispId, 'ORD', nOrd)
EgtSetInfo( nDispId, 'ROT', -2)
end
end
end
-- aggiungo nuova fase con le travi in posizione standard
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, 0)
-- se separazione non ancora effettuata, aggiungo nuova fase con le travi in posizione standard
if not bSplitRot then
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, 0)
-- altrimenti
else
BL.AddPhaseWithRawParts( nRawId, BD.OriTR, BD.RAW_OFFSET)
-- se grezzo successivo senza pezzi e finale, va tolto
local nNextRawId = EgtGetNextRawPart( nRawId)
if nNextRawId and EgtGetPartInRawPartCount( nNextRawId) == 0 and EgtGetRawPartBBox( nNextRawId):getDimX() < BD.MinRaw then
EgtRemoveRawPartFromCurrPhase( nNextRawId)
end
end
nPhase = EgtGetCurrPhase()
nDispId = EgtGetPhaseDisposition( nPhase)
EgtSetInfo( nDispId, 'TYPE', 'MID')
EgtSetInfo( nDispId, 'TYPE', EgtIf( not bSplitRot, 'MID', 'END2'))
EgtSetInfo( nDispId, 'ORD', nOrd)
end
-- inserisco le lavorazioni non ribaltate della trave
@@ -710,14 +739,14 @@ function BeamExec.ProcessFeatures()
-- creo la lavorazione
local Proc = vProc[i]
if Proc.Flg ~= 0 and not Proc.Down then
local bOk, sErr, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
local bOk, sMsg, bNewPhase = AddFeatureMachining( Proc, nPhase, nRawId, nPartId, dCurrOvmH, b3Raw)
if not bOk then
bAddOk = false
sAddErrors = sAddErrors .. sErr .. '\n'
if not nCutId then
nCutId = EgtGetInfo( EgtGetParent( EgtGetParent( Proc.Id)), 'CUTID', 'i')
nTaskId = EgtGetInfo( Proc.Id, 'TASKID', 'i')
end
nTotErr = nTotErr + 1
table.insert( Stats, {Err=1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId})
elseif sMsg and #sMsg > 0 then
table.insert( Stats, {Err=-1, Msg=sMsg, CutId=Proc.CutId, TaskId=Proc.TaskId})
else
table.insert( Stats, {Err=0, Msg='', CutId=Proc.CutId, TaskId=Proc.TaskId})
end
-- se era taglio di separazione, aggiungo nuova fase
if bNewPhase then
@@ -742,12 +771,12 @@ function BeamExec.ProcessFeatures()
-- Aggiornamento finale di tutto
EgtSetCurrPhase( 1)
local bApplOk, sApplErrors = EgtApplyAllMachinings()
if not bAddOk or not bApplOk then
local sErrors = ( sAddErrors or '') .. ( sApplErrors or '')
return false, sErrors, nCutId, nTaskId
if not bApplOk then
nTotErr = nTotErr + 1
table.insert( Stats, {Err = 1, Msg=sApplErrors, CutId=0, TaskId=0})
end
return true
return ( nTotErr == 0), Stats
end
-------------------------------------------------------------------------------------------------------------
+3 -3
View File
@@ -164,7 +164,7 @@ function BeamLib.GetPointDirDepth( nRawId, ptP, vtDir)
local nSolId = EgtGetFirstNameInGroup( nRawId, 'RawSolid')
if not nSolId then return end
-- interseco con la retta
local bOk, vType, vPar = EgtSurfTmLineInters( nSolId, ptP, vtDir, GDB_RT.GLOB)
local bOk, vType, vPar = EgtLineSurfTmInters( ptP, vtDir, nSolId, GDB_RT.GLOB)
if not bOk then return end
if not vPar or #vPar == 0 then return -2 end
local dLenIn, dLenOut
@@ -593,7 +593,7 @@ function BeamLib.CalcLeadInOutTangGeom( ptP1, ptP2, vtN, dRad, vtRef, dCutExtra,
end
---------------------------------------------------------------------
function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, nOrthoOpposite, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, sNotes, b3Raw)
function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, nOrthoOpposite, dVzLimDwnUp, dCutExtra, dCutSic, dCutOffset, dAccStart, sNotes, b3Raw)
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, nFacet, GDB_ID.ROOT)
-- linea o bilinea di lavorazione
@@ -700,7 +700,7 @@ function BeamLib.MakeOneFaceBySaw( nSurfId, nFacet, sCutting, dSawDiam, nOrthoOp
EgtSetMachiningParam( MCH_MP.LOTANG, dLoTang)
EgtSetMachiningParam( MCH_MP.LOPERP, dLoPerp)
-- imposto allungamenti iniziale e finale
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dAllStart)
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dAllStart - dAccStart)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dAllEnd)
-- eventuali note
if sNotes and #sNotes > 0 then EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) end
+12 -3
View File
@@ -1,4 +1,4 @@
-- DiceCut.lua by Egaltech s.r.l. 2019/04/13
-- DiceCut.lua by Egaltech s.r.l. 2019/07/01
-- Gestione dei piano paralleli nei tagli lunghi
-- Tabella per definizione modulo
@@ -357,10 +357,19 @@ function DiceCut.GetDice( nParent, BBoxRawPart, ptCPlanes, vtNPlanes, bGetOrtoPl
ptCOuter, vtNOuter = EgtSurfTmFacetCenter( TabellaTmSurfP[PlnInd-1], 0, GDB_ID.ROOT)
vtNOuter = -vtNOuter
end
-- calcolo la direzione dei piano ortogonali
-- calcolo la direzione dei piani ortogonali
local vtO = VectorFromUprightOrtho( vtNInner)
vtO:rotate( vtNInner, 90)
if abs( vtO:getY()) > abs( vtO:getX()) then vtO:rotate( vtNInner, 90) end
-- se diretto troppo ortogonalmente all'asse trave e taglio non da sotto, lo ruoto ulteriormente
if abs( vtO:getY()) > abs( vtO:getX()) and vtNInner:getZ() > -0.5 then
vtO:rotate( vtNInner, 90)
else
if ptCInner:getX() > BBoxRawPart:getCenter():getX() then
if vtO:getX() < 0 then vtO = - vtO end
else
if vtO:getX() > 0 then vtO = - vtO end
end
end
-- calcolo le dimensioni dell'offset e se dove posizionare la prima faccia:
-- CopyPlane: 0 => crea la prima faccia direttamente sul punto passato
-- CopyPlane: 1 => crea la prima faccia e tutte le altre con l'offset passato
+3 -3
View File
@@ -115,7 +115,7 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, sCutName)
local nOrtOpp = EgtIf( ( i % 2) == 1, nOrthoOpposite[nSmaInd], nOrthoOpposite[nBigInd])
-- lavoro la faccia
for j = 1, #vCuts[i] do
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrtOpp, nil, dCutExtra, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrtOpp, nil, dCutExtra, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
@@ -124,10 +124,10 @@ function FacesBySaw.MakeTwo( Proc, nPhase, nRawId, nPartId, sCutName)
return true
else
-- lavoro la prima faccia
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite[1], nil, dCutExtra, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite[1], nil, dCutExtra, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then return bOk, sErr end
-- lavoro seconda faccia
bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 1, sCutting, dSawDiam, nOrthoOpposite[2], nil, dCutExtra, BD.CUT_SIC, 0, nil, b3Raw)
bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 1, sCutting, dSawDiam, nOrthoOpposite[2], nil, dCutExtra, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then return bOk, sErr end
return true
end
+4 -2
View File
@@ -38,11 +38,13 @@ function MachiningLib.FindMilling( sType)
end
---------------------------------------------------------------------
function MachiningLib.FindPocketing( sType)
function MachiningLib.FindPocketing( sType, dMaxMat)
for i = 1, #Pocketings do
local Pocketing = Pocketings[i]
if Pocketing.Type == sType then
return Pocketing.Name
if not dMaxMat or dMaxMat < Pocketing.MaxMat then
return Pocketing.Name
end
end
end
end
-280
View File
@@ -1,280 +0,0 @@
-- ProcessMortise.lua by Egaltech s.r.l. 2019/04/26
-- Gestione calcolo tacche per Travi
-- Tabella per definizione modulo
local ProcessBirdsMouth = {}
-- Include
require( 'EgtBase')
local BL = require( 'BeamLib')
local Fbs = require( 'FacesBySaw')
EgtOutLog( ' ProcessBirdsMouth started', 1)
-- Dati
local BD = require( 'BeamData')
local ML = require( 'MachiningLib')
---------------------------------------------------------------------
-- Riconoscimento della feature
function ProcessBirdsMouth.Identify( Proc)
return ( ( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 20)
end
---------------------------------------------------------------------
-- Verifica se feature di testa
function ProcessBirdsMouth.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
-- verifico se è in testa
if Proc.Box:getMax():getX() < b3Raw:getMax():getX() - dCurrOvmH - BD.MAX_DIST_HTFEA then
return false
end
-- è di testa
return true
end
---------------------------------------------------------------------
-- Verifica se feature di coda
function ProcessBirdsMouth.IsTailFeature( Proc, b3Raw)
-- verifico se è in coda
if Proc.Box:getMin():getX() > b3Raw:getMin():getX() + BD.MAX_DIST_HTFEA then
return false
end
-- è di coda
return true
end
---------------------------------------------------------------------
-- Classificazione della feature
function ProcessBirdsMouth.Classify( Proc)
-- recupero il numero di facce della tacca
local nFacCnt = EgtSurfTmFacetCount( Proc.Id)
-- se 1 faccia
if nFacCnt == 1 then
return false
-- se 2 facce
elseif nFacCnt == 2 then
-- dati delle facce
local ptC = {}
local vtN = {}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
-- verifico se è lavorabile solo dal basso
--local bDown = (( vtN[1]:getZ() < BD.NZ_MINB and vtN[2]:getZ() < BD.NZ_MINB) or vtN[1]:getZ() < BD.NZ_MINA or vtN[2]:getZ() < BD.NZ_MINA)
local bDown = ( vtN[1]:getZ() < BD.NZ_MINB and vtN[2]:getZ() < BD.NZ_MINB)
return true, bDown
-- se più di due facce
else
-- recupero la faccia con il maggior numero di adiacenze più grande
local nFacInd = BL.GetFaceWithMostAdj( Proc.Id)
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
-- verifico se è lavorabile solo dal basso
local bDown = ( vtN:getZ() < BD.NZ_MINA)
return true, bDown
end
end
---------------------------------------------------------------------
-- Lavorazione con fresa
---------------------------------------------------------------------
local function Make2FacesByMill( Proc, nPhase, nRawId, nPartId)
-- recupero l'ingombro del grezzo di appartenenza
local b3Raw = EgtGetRawPartBBox( nRawId)
-- recupero il numero di facce della tacca
local nFacCnt = EgtSurfTmFacetCount( Proc.Id)
-- per ora solo caso con due facce
if nFacCnt ~= 2 then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' BirdsMouth facet number not supported'
EgtOutLog( sErr)
return false, sErr
end
-- dati delle facce
local ptC = {}
local vtN = {}
ptC[1], vtN[1] = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
ptC[2], vtN[2] = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
-- dati medi
local ptM = ( ptC[1] + ptC[2]) / 2
-- verifico non siano orientate verso il basso
local bFaceOk = {}
bFaceOk[1] = ( vtN[1]:getZ() >= BD.NZ_MINB)
bFaceOk[2] = ( vtN[2]:getZ() >= BD.NZ_MINB)
if not bFaceOk[1] and not bFaceOk[2] then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' BirdsMouth from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- scelta faccia da lavorare
local nFacInd
-- se entrambe possibili, scelgo quella con la normale più perpendicolare all'asse trave (se uguali, quella verso X+)
if bFaceOk[1] and bFaceOk[2] then
if abs( abs( vtN[1]:getX()) - abs( vtN[2]:getX())) < GEO.EPS_SMALL then
if ptM:getX() > b3Raw:getCenter():getX() then
nFacInd = EgtIf( vtN[1]:getX() > vtN[2]:getX(), 0, 1)
else
nFacInd = EgtIf( vtN[1]:getX() < vtN[2]:getX(), 0, 1)
end
else
nFacInd = EgtIf( abs( vtN[1]:getX()) < abs( vtN[2]:getX()), 0, 1)
end
elseif bFaceOk[1] then
nFacInd = 0
else
nFacInd = 1
end
local nOthInd = 1 - nFacInd
-- recupero la lavorazione
local sMilling = ML.FindMilling( 'BirdsMouth')
if not sMilling then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' milling not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- inserisco la lavorazione di fresatura
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, nFacInd}})
-- imposto uso faccia e lato correzione
if vtN[nOthInd+1]:getX() > 0 then
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_LEFT)
else
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_RIGHT)
end
-- imposto lato di correzione
EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT)
-- imposto posizione braccio porta testa
if vtN[nFacInd+1]:getY() <= 0 then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
else
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
return true
end
---------------------------------------------------------------------
local function MakeMoreFacesByMill( Proc, nPhase, nRawId, nPartId)
-- recupero l'ingombro del grezzo di appartenenza
local b3Raw = EgtGetRawPartBBox( nRawId)
-- recupero il numero di facce della tacca
local nFacCnt = EgtSurfTmFacetCount( Proc.Id)
assert( ( nFacCnt > 2), 'Error : MakeMoreFacesByMill in BirdsMouth with ' .. tostring( nFacCnt) .. ' faces')
-- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa
local nFacInd, dFacElev = BL.GetFaceWithMostAdj( Proc.Id)
assert( nFacInd, 'Error : MakeMoreFacesByMill could not find reference face')
-- dati della faccia
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
-- verifico non sia orientata verso il basso
local bFaceOk = ( vtN:getZ() >= BD.NZ_MINB)
if not bFaceOk then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' BirdsMouth from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- eventuali tagli preliminari
-- per ora non previsti
-- recupero la lavorazione
local sPocketing = ML.FindPocketing( 'Mortise')
if not sPocketing then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sPocketing) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
end
end
-- inserisco la lavorazione di svuotatura
local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sPocketing)
if not nMchFId then
local sErr = 'Error adding machining ' .. sName .. '-' .. sPocketing
EgtOutLog( sErr)
return false, sErr
end
-- aggiungo geometria
EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}})
-- imposto uso faccia
EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT)
-- imposto posizione braccio porta testa
if vtN:getY() <= 0 then
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM)
else
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente
if dFacElev > dMaxDepth + 10 * GEO.EPS_SMALL then
EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth - dFacElev)
dFacElev = dMaxDepth
local sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth'
EgtOutLog( sWarn)
end
-- imposto elevazione
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dFacElev, 1) .. ';')
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
end
return true
end
---------------------------------------------------------------------
local function MakeByMill( Proc, nPhase, nRawId, nPartId)
-- recupero il numero di facce
local nFacCnt = EgtSurfTmFacetCount( Proc.Id)
-- richiamo la routine di lavorazione opportuna a seconda del numero di facce
if nFacCnt <= 2 then
return Make2FacesByMill( Proc, nPhase, nRawId, nPartId)
else
return MakeMoreFacesByMill( Proc, nPhase, nRawId, nPartId)
end
end
---------------------------------------------------------------------
-- Applicazione della lavorazione
function ProcessBirdsMouth.Make( Proc, nPhase, nRawId, nPartId)
-- recupero l'ingombro del grezzo di appartenenza
local b3Raw = EgtGetRawPartBBox( nRawId)
-- dimensioni della feature
local b3Fea = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD)
-- numero di facce
local nFacCnt = EgtSurfTmFacetCount( Proc.Id)
-- se con due facce verifico che angolo non sia concavo e minore di - 90 deg
local bConcClosed = false
if nFacCnt == 2 then
local _, _, _, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
bConcClosed = ( dAng < - 92)
end
-- con fresa
local MAX_MILL_X = 80
local MAX_MILL_VOL = ( 80 * 240 * 20) / 2
-- se più di due facce o ( piccola o in coda e non concava chiusa)
if nFacCnt > 2 or
((( b3Fea:getDimX() < MAX_MILL_X and b3Fea:getDimX() * b3Fea:getDimY() * b3Fea:getDimZ() < MAX_MILL_VOL) or
b3Fea:getMin():getX() < b3Raw:getMin():getX() + 10) and not bConcClosed) then
return MakeByMill( Proc, nPhase, nRawId, nPartId)
-- con lama
else
return Fbs.MakeTwo( Proc, nPhase, nRawId, nPartId, 'HeadSide')
end
end
---------------------------------------------------------------------
return ProcessBirdsMouth
+15 -7
View File
@@ -1,4 +1,4 @@
-- ProcessCut.lua by Egaltech s.r.l. 2019/04/13
-- ProcessCut.lua by Egaltech s.r.l. 2019/06/29
-- Gestione calcolo singoli tagli di lama per Travi
-- Tabella per definizione modulo
@@ -131,7 +131,7 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
if j ~= 1 then
nNewOrthoOpposite = EgtIf( nOrthoOpposite == MCH_MILL_FU.ORTHO_FRONT, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
end
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nNewOrthoOpposite, nil, 0.1, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nNewOrthoOpposite, nil, 0.1, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
@@ -139,7 +139,7 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
-- tutti gli altri casi vengono saltati
-- caso generale
else
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, - 0.1, 0.1, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, - 0.1, -0.5, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
@@ -157,17 +157,25 @@ function ProcessCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
else
nOrthoOpposite = MCH_MILL_FU.ORTHO_BACK
end
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
end
-- eventuale segnalazione ingombro di testa o coda
if abs( vtN:getY()) > GEO.EPS_SMALL or b3Raw:getDimZ() - Proc.Box:getDimZ() < BD.MIN_HEIGHT then
if abs( vtN:getY()) > 0.1 or ( b3Raw:getDimZ() - Proc.Box:getDimZ()) < BD.MIN_HEIGHT then
if Proc.Head then
BL.UpdateHCING( nRawId, b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX())
local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX()
if vtN:getZ() > 0.5 then
dOffs = dOffs / 2
end
BL.UpdateHCING( nRawId, dOffs)
elseif Proc.Tail then
BL.UpdateTCING( nRawId, Proc.Box:getMax():getX() - b3Raw:getMin():getX())
local dOffs = Proc.Box:getMax():getX() - b3Raw:getMin():getX()
if vtN:getZ() > 0.5 then
dOffs = dOffs / 2
end
BL.UpdateTCING( nRawId, dOffs)
end
end
return true
+109 -68
View File
@@ -8,6 +8,7 @@ local ProcessDoubleCut = {}
require( 'EgtBase')
local BL = require( 'BeamLib')
local DC = require( 'DiceCut')
local Cut = require( 'ProcessCut')
EgtOutLog( ' ProcessDoubleCut started', 1)
@@ -92,10 +93,8 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
end
end
-- verifico se necessari tagli supplementari
local vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[nBigInd], vtN[nBigInd], false, ptC[nSmaInd], vtN[nSmaInd])
--DC.PrintOrderCut( vCuts)
if #vCuts > 0 then
-- se convesso, lo tratto come due tagli singoli
if bConvex then
-- recupero gruppo per geometria addizionale
local nAddGrpId = BL.GetAddGroup( nPartId)
if not nAddGrpId then
@@ -103,87 +102,129 @@ function ProcessDoubleCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
EgtOutLog( sErr)
return false, sErr
end
-- sistemo posizione nel DB e nome
for i = 1, #vCuts do
for j = 1, #vCuts[i] do
EgtRelocateGlob( vCuts[i][j], nAddGrpId)
EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id))
end
-- creo piano di taglio coincidente con la prima faccia e lo lavoro
local AddId = EgtSurfTmPlaneInBBox( EgtGetParent( Proc.Id), ptC[1], vtN[1], b3Solid, GDB_RT.GLOB)
if AddId then
EgtRelocate( AddId, nAddGrpId)
EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id))
-- applico lavorazione
local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg}
local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0)
if not bOk then return bOk, sErr end
end
-- eseguo
for i = 1, #vCuts do
-- determino il modo di tagliare
local k, l = nBigInd, nSmaInd
if ( i % 2 == 1) == ( not bConvex) then
k, l = l, k
-- creo piano di taglio coincidente con la seconda faccia e lo lavoro
local AddId = EgtSurfTmPlaneInBBox( EgtGetParent( Proc.Id), ptC[2], vtN[2], b3Solid, GDB_RT.GLOB)
if AddId then
EgtRelocate( AddId, nAddGrpId)
EgtSetName( AddId, 'AddCut_' .. tostring( Proc.Id))
-- applico lavorazione
local CutProc = { Id = AddId, Grp = Proc.Grp, Prc = Proc.Prc, Box = Proc.Box, Fct = Proc.Fct, Flg = Proc.Flg}
local bOk, sErr = Cut.Make( CutProc, nPhase, nRawId, nPartId, 0)
if not bOk then return bOk, sErr end
end
-- altrimenti
else
-- verifico se necessari tagli supplementari
local vCuts = DC.GetDice( EgtGetParent( Proc.Id), b3Solid, ptC[nBigInd], vtN[nBigInd], false, ptC[nSmaInd], vtN[nSmaInd])
--DC.PrintOrderCut( vCuts)
if #vCuts > 0 then
-- recupero gruppo per geometria addizionale
local nAddGrpId = BL.GetAddGroup( nPartId)
if not nAddGrpId then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' missing AddGroup'
EgtOutLog( sErr)
return false, sErr
end
local nOrthoOpposite
if bOnY then
local bFront = ( ptC[k]:getY() < ptPs:getY())
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
else
if bConvex then
if dLen < dMaxDepth then
local bFront = ( vtN[k]:getY() < 0.02)
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
-- sistemo posizione nel DB e nome
for i = 1, #vCuts do
for j = 1, #vCuts[i] do
EgtRelocateGlob( vCuts[i][j], nAddGrpId)
EgtSetName( vCuts[i][j], 'AddCut_' .. tostring( Proc.Id))
end
end
-- eseguo
for i = 1, #vCuts do
-- determino il modo di tagliare
local k, l = nBigInd, nSmaInd
if ( i % 2 == 1) == ( not bConvex) then
k, l = l, k
end
local nOrthoOpposite
if bOnY then
local bFront = ( ptC[k]:getY() < ptPs:getY())
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
else
if bConvex then
if dLen < dMaxDepth then
local bFront = ( vtN[k]:getY() < 0.02)
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
else
local bOver = ( ptC[k]:getZ() > ptC[l]:getZ())
nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP)
end
else
local bOver = ( ptC[k]:getZ() > ptC[l]:getZ())
nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP)
end
else
local bOver = ( ptC[k]:getZ() > ptC[l]:getZ())
nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP)
end
-- lavoro la faccia
for j = 1, #vCuts[i] do
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
end
end
-- lavoro la faccia
for j = 1, #vCuts[i] do
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, nil, b3Raw)
end
-- se non ci sono tagli supplementari o convesso, tagli diretti delle facce
if #vCuts == 0 then
-- imposto eventuale affondamento aggiuntivo
local dExtraCut = EgtIf( bConvex, BD.CUT_EXTRA, 0)
-- eseguo sulle due facce
for j = 1, 2 do
-- determino ordine dei tagli
local i = j
if not bOnY and ptC[1]:getZ() > ptC[2]:getZ() then
i = 3 - j
end
-- lavoro la faccia
local nOrthoOpposite
if bOnY then
local bFront = ( ptC[i]:getY() < ptPs:getY())
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
else
if bConvex then
if dLen < dMaxDepth then
local bFront = ( vtN[i]:getY() < 0.02)
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
else
nOrthoOpposite = MCH_MILL_FU.ORTHO_DOWN
end
else
local bOver = ( ptC[i]:getZ() > ptC[3-i]:getZ())
nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP)
end
end
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, i - 1, sCutting, dSawDiam, nOrthoOpposite, nil, dExtraCut, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
end
end
end
-- se non ci sono tagli supplementari o convesso, tagli diretti delle facce
if #vCuts == 0 or bConvex then
-- imposto eventuale affondamento aggiuntivo
local dExtraCut = EgtIf( bConvex, BD.CUT_EXTRA, 0)
-- eseguo sulle due facce
for j = 1, 2 do
-- determino ordine dei tagli
local i = j
if not bOnY and ptC[1]:getZ() > ptC[2]:getZ() then
i = 3 - j
end
-- lavoro la faccia
local nOrthoOpposite
if bOnY then
local bFront = ( ptC[i]:getY() < ptPs:getY())
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
else
if bConvex then
if dLen < dMaxDepth then
local bFront = ( vtN[i]:getY() < 0.02)
nOrthoOpposite = EgtIf( bFront, MCH_MILL_FU.ORTHO_BACK, MCH_MILL_FU.ORTHO_FRONT)
else
nOrthoOpposite = MCH_MILL_FU.ORTHO_DOWN
end
else
local bOver = ( ptC[i]:getZ() > ptC[3-i]:getZ())
nOrthoOpposite = EgtIf( bOver, MCH_MILL_FU.ORTHO_DOWN, MCH_MILL_FU.ORTHO_TOP)
end
end
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, i - 1, sCutting, dSawDiam, nOrthoOpposite, nil, dExtraCut, BD.CUT_SIC, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
end
end
-- eventuale segnalazione ingombro di testa o coda
if Proc.Head then
BL.UpdateHCING( nRawId, b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX())
local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX()
if vtNm:getZ() > 0.5 then
dOffs = 0.5 * dOffs
end
BL.UpdateHCING( nRawId, dOffs)
elseif Proc.Tail then
BL.UpdateTCING( nRawId, Proc.Box:getMax():getX() - b3Raw:getMin():getX())
if vtNm:getZ() > 0.5 then
dOffs = 0.5 * dOffs
end
local dOffs = Proc.Box:getMax():getX() - b3Raw:getMin():getX()
BL.UpdateTCING( nRawId, dOffs)
end
return true
end
+10 -2
View File
@@ -1,4 +1,4 @@
-- ProcessDrill.lua by Egaltech s.r.l. 2019/06/19
-- ProcessDrill.lua by Egaltech s.r.l. 2019/07/02
-- Gestione calcolo forature per Travi
-- Tabella per definizione modulo
@@ -192,7 +192,15 @@ function ProcessDrill.Make( Proc, nPhase, nRawId, nPartId)
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchId, false)
return false, sErr
end
else
local _, sWarn = EgtGetMachMgrWarning( 0)
if EgtIsMachiningEmpty() then
EgtSetOperationMode( nMchFId, false)
return false, sWarn
else
return true, sWarn
end
end
return true
end
+5 -7
View File
@@ -1,4 +1,4 @@
-- ProcessTenon.lua by Egaltech s.r.l. 2019/03/23
-- ProcessTenon.lua by Egaltech s.r.l. 2019/06/29
-- Gestione calcolo tenone a coda di rondine per Travi
-- Tabella per definizione modulo
@@ -119,12 +119,10 @@ function ProcessDtTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
EgtErase( nLoopId + i - 1)
end
EgtOutLog( 'MaxDist=' .. EgtNumToString( dMaxDist, 3), 3)
-- Cicli di lavorazione
local nStep = ceil( dMaxDist / ( 0.7 * dTDiam))
local dStep = 0
if nStep > 1 then
dStep = ( dMaxDist - 0.7 * dTDiam) / ( nStep - 1)
end
-- Cicli di lavorazione (max 4)
local MAX_PASS = 4
local nStep = min( ceil( dMaxDist / ( 0.7 * dTDiam)), MAX_PASS)
local dStep = min( dMaxDist, 0.7 * dTDiam * MAX_PASS) / nStep
for i = nStep, 1, -1 do
-- inserisco la passata di sgrossatura della lavorazione
local sNameR = 'DtTn_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) .. '_' .. tostring( i)
+7 -7
View File
@@ -1,4 +1,4 @@
-- ProcessFreeContour.lua by Egaltech s.r.l. 2019/06/13
-- ProcessFreeContour.lua by Egaltech s.r.l. 2019/06/29
-- Gestione calcolo profilo libero per Travi
-- Tabella per definizione modulo
@@ -66,13 +66,13 @@ function ProcessFreeContour.Classify( Proc)
if not bPocket then
return true, false
end
-- è pocket, devo verificare la normale del piano di svuotatura (sempre ultima faccia)
local nFacet = Proc.Fct - 1
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT)
-- verifico sia una superficie
if not vtN then
-- è pocket, devo verificare la normale del piano di svuotatura (versore estrusione del contorno)
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
if not AuxId then
return false
end
AuxId = AuxId + Proc.Id
local vtN = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
-- verifico se la feature è lavorabile solo da sotto (tasca con normale verso il basso)
local bDown = ( vtN:getZ() < - 0.1)
return true, bDown
@@ -219,7 +219,7 @@ local function MakeByPocket( Proc, nPhase, nRawId, nPartId, dOvmHead)
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
--local bToolInv = ( vtExtr:getZ() < -0.1)
-- recupero la lavorazione
local sPocketing = ML.FindPocketing( 'Mortise')
local sPocketing = ML.FindPocketing( 'Pocket', dDepth)
if not sPocketing then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' pocketing not found in library'
EgtOutLog( sErr)
+15 -5
View File
@@ -1,4 +1,4 @@
-- ProcessSplit.lua by Egaltech s.r.l. 2019/04/08
-- ProcessSplit.lua by Egaltech s.r.l. 2019/06/29
-- Gestione calcolo tagli di testa per Travi
-- Tabella per definizione modulo
@@ -54,20 +54,30 @@ function ProcessHeadCut.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam
end
end
-- calcolo extra taglio
local dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY(), 0) + BD.CUT_EXTRA
-- calcolo extra taglio ed accorciamento
local dCutExtra = 0
local dAccStart = 0
if b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then
dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY(), 0) + BD.CUT_EXTRA
dAccStart = 0
else
dCutExtra = - ( b3Raw:getDimY() - BD.MAX_DIM_HTCUT - BD.CUT_EXTRA)
local dSawRad = dSawDiam / 2
local dKL = dSawRad - ( BD.MAX_DIM_HTCUT + BD.CUT_EXTRA) + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN
dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL)
end
-- se necessari tagli in doppio, eseguo gli opposti
if bDoubleCut then
for i = nCuts, 1, -1 do
local dCutOffset = ( i - 1) * dOffsL
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, nil, dCutExtra, BD.CUT_SIC, dCutOffset, '', b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw)
if not bOk then return false, sErr end
end
end
-- eseguo i tagli necessari
for i = nCuts, 1, -1 do
local dCutOffset = ( i - 1) * dOffsL
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, '', b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, '', b3Raw)
if not bOk then return false, sErr end
end
return true
+13 -4
View File
@@ -1,4 +1,4 @@
-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/06/20
-- ProcessLapJoint.lua by Egaltech s.r.l. 2019/07/01
-- Gestione calcolo mezzo-legno per Travi
-- Tabella per definizione modulo
@@ -22,6 +22,7 @@ local ML = require( 'MachiningLib')
function ProcessLapJoint.Identify( Proc)
return ( (( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 16) or
(( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 17) or
(( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 20) or
(( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 30) or
(( Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 32) or
( Proc.Grp == 4 and Proc.Prc == 39))
@@ -43,6 +44,8 @@ function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH)
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
if vtN:getX() < 0.5 then
return false
elseif Proc.Fct >= 5 then
return true
end
-- deve occupare la maggior parte dell'area
if Proc.Box:getDimY() > 0.75 * b3Raw:getDimY() or Proc.Box:getDimZ() > 0.75 * b3Raw:getDimZ() then
@@ -68,6 +71,8 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw)
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT)
if vtN:getX() > -0.5 then
return false
elseif Proc.Fct >= 5 then
return true
end
-- deve occupare la maggior parte dell'area
if Proc.Box:getDimY() > 0.75 * b3Raw:getDimY() or Proc.Box:getDimZ() > 0.75 * b3Raw:getDimZ() then
@@ -359,7 +364,7 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac,
end
for i = 1, nStep do
local dOffs = ( i - 1) * dStep
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, nFacAdj, sCutting, dSawDiam, nFaceUse, nil, 0, BD.CUT_SIC, dOffs, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, nFacAdj, sCutting, dSawDiam, nFaceUse, nil, 0, BD.CUT_SIC, dOffs, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
@@ -422,6 +427,10 @@ local function MakeByChainOrSaw( Proc, nPhase, nRawId, nPartId, nFacInd, rfFac,
local _, sErr = EgtGetLastMachMgrError()
EgtSetOperationMode( nMchFId, false)
return false, sErr
elseif EgtIsMachiningEmpty() then
local _, sWarn = EgtGetMachMgrWarning( 0)
EgtSetOperationMode( nMchFId, false)
return false, sWarn
end
end
end
@@ -468,7 +477,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMaxDepth = EgtTdbGetCurrToolMaxDepth() or dMaxDepth
dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) - BD.COLL_SIC
end
end
-- se una dimensione della faccia è più piccola del diametro utensile, va usata la sega a catena o la lama
@@ -507,7 +516,7 @@ local function MakeMoreFaces( Proc, nPhase, nRawId, nPartId)
EgtOutLog( sWarn)
end
-- imposto elevazione
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dMaxDepth, 1) .. ';')
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dFacElev, 1) .. ';')
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
+28 -3
View File
@@ -6,6 +6,7 @@ local ProcessMortise = {}
-- Include
require( 'EgtBase')
local BL = require( 'BeamLib')
EgtOutLog( ' ProcessMortise started', 1)
@@ -58,9 +59,7 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
EgtCloseCurveCompo( AuxId)
end
end
-- recupero i dati della curva e del top
local dDepth = abs( EgtCurveThickness( AuxId))
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
-- recupero i dati del bottom
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 0, GDB_ID.ROOT)
EgtOutLog( 'ptC=' .. tostring( ptC) ..' vtN=' .. tostring( vtN), 3)
-- verifico che la mortasa non sia orientata verso il basso (-5 deg)
@@ -69,6 +68,13 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
EgtOutLog( sErr)
return false, sErr
end
-- determino altezza della mortasa
local frMor = Frame3d( ptC, vtN)
local b3Mor = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frMor)
local dMorH = b3Mor:getDimZ()
-- elevazione del punto centro
local _, dCenElev = BL.GetPointDirDepth( nRawId, ptC, vtN)
dMorH = max( dMorH, dCenElev or 0)
-- recupero la lavorazione
local sPocketing = ML.FindPocketing( 'Mortise')
if not sPocketing then
@@ -76,6 +82,16 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati dell'utensile
local dMillDiam = 20
local dMaxDepth = 0
if EgtMdbSetCurrMachining( sPocketing) then
local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID)
if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
dMaxDepth = ( EgtTdbGetCurrToolMaxDepth() or dMaxDepth) - BD.COLL_SIC
end
end
-- inserisco la lavorazione di svuotatura
local sName = 'Mort_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
local nMchFId = EgtAddMachining( sName, sPocketing)
@@ -92,6 +108,15 @@ function ProcessMortise.Make( Proc, nPhase, nRawId, nPartId)
else
EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP)
end
-- se elevazione superiore a massimo affondamento della fresa, riduco opportunamente
if dMorH > dMaxDepth + 10 * GEO.EPS_SMALL then
EgtSetMachiningParam( MCH_MP.DEPTH, dMaxDepth - dMorH)
dMorH = dMaxDepth
local sWarn = 'Warning in process ' .. tostring( Proc.Id) .. ' : elevation bigger than max tool depth'
EgtOutLog( sWarn)
end
-- imposto elevazione
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dMorH, 1) .. ';')
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
+4 -4
View File
@@ -118,7 +118,7 @@ function ProcessRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
-- se va fatto, inserisco la lavorazione
if bCut then
local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtN[vFaceOrd[3]])
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then return bOk, sErr end
end
end
@@ -155,7 +155,7 @@ function ProcessRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
end
-- lavoro la faccia
for j = 1, #vCuts[i] do
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
@@ -166,14 +166,14 @@ function ProcessRidgeLap.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
if vFaceOrd[2] ~= 0 then
-- inserisco la lavorazione
local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtN[vFaceOrd[3]])
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[2] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[2] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then return bOk, sErr end
end
-- taglio sulla faccia intermedia
if vFaceOrd[3] ~= 0 then
-- inserisco la lavorazione
local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtN[vFaceOrd[2]])
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then return bOk, sErr end
end
end
+4 -4
View File
@@ -117,7 +117,7 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
-- se va fatto, inserisco la lavorazione
if bCut then
local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef)
local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[1] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, BD.CUT_EXTRA, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then return bOk, sNameOrErr end
end
end
@@ -153,7 +153,7 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
end
-- lavoro la faccia
for j = 1, #vCuts[i] do
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( vCuts[i][j], 0, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then
return bOk, sErr
end
@@ -165,7 +165,7 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
if vFaceOrd[2] ~= 0 then
-- inserisco la lavorazione
local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef)
local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[2] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sNameOrErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[2] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then return bOk, sNameOrErr end
if #sNameOrErr > 0 then bIntCut = true end
end
@@ -182,7 +182,7 @@ function ProcessSimpleScarf.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
end
end
local nOrthoOpposite = BL.GetNearestOrthoOpposite( vtRef2)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, nil, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, vFaceOrd[3] - 1, sCutting, dSawDiam, nOrthoOpposite, nil, 0, BD.CUT_SIC, 0, 0, nil, b3Raw)
if not bOk then return bOk, sErr end
end
end
+15 -5
View File
@@ -1,4 +1,4 @@
-- ProcessSplit.lua by Egaltech s.r.l. 2019/04/25
-- ProcessSplit.lua by Egaltech s.r.l. 2019/06/29
-- Gestione calcolo tagli di separazione per Travi
-- Tabella per definizione modulo
@@ -63,14 +63,24 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId)
dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam
end
end
-- calcolo extra taglio
local dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY(), 0) + BD.CUT_EXTRA
-- calcolo extra taglio ed accorciamento
local dCutExtra = 0
local dAccStart = 0
if b3Raw:getDimZ() < BD.MIN_DIM_HBEAM + 10 * GEO.EPS_SMALL or b3Raw:getDimY() < 2 * BD.MAX_DIM_HTCUT_HBEAM + 10 * GEO.EPS_SMALL then
dCutExtra = EgtIf( bDoubleCut, - 0.5 * b3Raw:getDimY(), 0) + BD.CUT_EXTRA
dAccStart = 0
else
dCutExtra = - ( b3Raw:getDimY() - BD.MAX_DIM_HTCUT - BD.CUT_EXTRA)
local dSawRad = dSawDiam / 2
local dKL = dSawRad - ( BD.MAX_DIM_HTCUT + BD.CUT_EXTRA) + b3Raw:getDimY() / 2 + BD.CUT_EXTRA_MIN
dAccStart = sqrt( dSawRad * dSawRad - dKL * dKL)
end
-- se necessari tagli in doppio, eseguo gli opposti
if bDoubleCut then
for i = nCuts, 1, -1 do
local dCutOffset = ( i - 1) * dOffsL
local sNotes = EgtIf( bSplit, 'Presplit;', 'Precut;')
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, nil, dCutExtra, BD.CUT_SIC, dCutOffset, sNotes, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, MCH_MILL_FU.ORTHO_BACK, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw)
if not bOk then return false, true, sErr end
end
end
@@ -83,7 +93,7 @@ function ProcessSplit.Make( Proc, nPhase, nRawId, nPartId)
else
sNotes = EgtIf( i == 1, 'Cut;', 'Precut;')
end
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, sNotes, b3Raw)
local bOk, sErr = BL.MakeOneFaceBySaw( Proc.Id, 0, sCutting, dSawDiam, nOrthoOpposite, nil, dCutExtra, BD.CUT_SIC, dCutOffset, dAccStart, sNotes, b3Raw)
if not bOk then return false, true, sErr end
end
-- ritorno anche flag di passaggio a fase successiva
+44 -22
View File
@@ -1,4 +1,4 @@
-- ProcessTenon.lua by Egaltech s.r.l. 2019/03/23
-- ProcessTenon.lua by Egaltech s.r.l. 2019/07/01
-- Gestione calcolo tenone per Travi
-- Tabella per definizione modulo
@@ -25,14 +25,13 @@ end
---------------------------------------------------------------------
-- Classificazione della feature
function ProcessTenon.Classify( Proc)
-- recupero i dati della faccia top
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
-- verifico sia una superficie
if not vtN then
return false
end
-- recupero i dati della curva di contorno della faccia top
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
if not AuxId then return false end
AuxId = AuxId + Proc.Id
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
-- verifico se il tenone è lavorabile solo da sotto
local bDown = ( vtN:getZ() < - 0.1)
local bDown = ( vtExtr:getZ() < - 0.1)
return true, bDown
end
@@ -57,24 +56,29 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
EgtOutLog( sErr)
return false, sErr
end
-- recupero i dati della curva e del top
local dDepth = abs( EgtCurveThickness( AuxId))
-- recupero i dati della curva di contorno della faccia top
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, 1, GDB_ID.ROOT)
EgtOutLog( 'ptC=' .. tostring( ptC) ..' vtN=' .. tostring( vtN), 3)
local ptBC = EgtGP( AuxId, GDB_RT.GLOB)
local bClosed = EgtCurveIsClosed( AuxId)
-- verifico che il tenone non sia orientato verso il basso (-5 deg)
if vtN:getZ() < - 0.1 then
if vtExtr:getZ() < - 0.1 then
local sErr = 'Error on process ' .. tostring( Proc.Id) .. ' Tenon from bottom impossible'
EgtOutLog( sErr)
return false, sErr
end
-- determino altezza del tenone
local frTen = Frame3d( ptC, vtN)
local frTen = Frame3d( ptBC, vtExtr)
local b3Ten = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frTen)
local dTenH = b3Ten:getDimZ()
-- assegno centro e normale della faccia top
local vtN = vtExtr
local ptC = ptBC + vtN * dTenH
EgtOutLog( 'ptC=' .. tostring( ptC) ..' vtN=' .. tostring( vtN), 3)
-- determino larghezza massima di svuotatura
local b3Aux = EgtGetBBoxRef( AuxId, GDB_BB.STANDARD, frTen)
local dPockL = 0.5 * max( b3Ten:getDimX() - b3Aux:getDimX(), b3Ten:getDimY() - b3Aux:getDimY())
local dPockX = max( b3Ten:getMax():getX() - b3Aux:getMax():getX(), b3Aux:getMin():getX() - b3Ten:getMin():getX())
local dPockY = max( b3Ten:getMax():getY() - b3Aux:getMax():getY(), b3Aux:getMin():getY() - b3Ten:getMin():getY())
local dPockL = max( dPockX, dPockY)
-- porto inizio curva il più possibile sul bordo
BL.PutStartNearestToEdge( AuxId, b3Solid)
-- se vero tenone inclinato o non esattamente alle estremità, necessario taglio di lama sulla testa
@@ -116,9 +120,10 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam
end
end
-- determino il numero di passate concentriche
local nPass = ceil( dPockL / ( 0.5 * dMillDiam))
local dStep = dPockL / nPass
-- determino il numero di passate concentriche (max 4)
local MAX_PASS = 4
local nPass = min( ceil( dPockL / ( 0.7 * dMillDiam)), MAX_PASS)
local dStep = min( dPockL, 0.7 * dMillDiam * MAX_PASS) / nPass
for i = nPass, 1, -1 do
-- inserisco la passata finale della lavorazione
local sNameF = 'TenF_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id))
@@ -134,6 +139,13 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
EgtSetMachiningParam( MCH_MP.USERNOTES, 'MaxElev=' .. EgtNumToString( dTenH, 1) .. ';')
local dOffset = ( i - 1) * dStep
EgtSetMachiningParam( MCH_MP.OFFSR, dOffset)
-- se contorno aperto, cambio parametri di attacco/uscita
if not bClosed then
EgtSetMachiningParam( MCH_MP.LITANG, 0.7 * dMillDiam)
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
EgtSetMachiningParam( MCH_MP.LOTANG, 0.7 * dMillDiam)
EgtSetMachiningParam( MCH_MP.LOPERP, 0)
end
-- eseguo
if not EgtApplyMachining( true, false) then
local _, sErr = EgtGetLastMachMgrError()
@@ -142,10 +154,20 @@ function ProcessTenon.Make( Proc, nPhase, nRawId, nPartId, dOvmHead)
end
end
-- eventuale segnalazione ingombro di testa o coda
if Proc.Head then
BL.UpdateHCING( nRawId, b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX())
elseif Proc.Tail then
BL.UpdateTCING( nRawId, Proc.Box:getMax():getX() - b3Raw:getMin():getX())
if abs( vtN:getY()) > 0.1 or ( b3Raw:getDimZ() - Proc.Box:getDimZ()) < BD.MIN_HEIGHT then
if Proc.Head then
local dOffs = b3Raw:getMax():getX() - dOvmHead - Proc.Box:getMin():getX()
if abs( vtN:getY()) < 0.1 and vtN:getZ() > 0.5 then
dOffs = dOffs / 2
end
BL.UpdateHCING( nRawId, dOffs)
elseif Proc.Tail then
local dOffs = Proc.Box:getMax():getX() - b3Raw:getMin():getX()
if abs( vtN:getY()) < 0.1 and vtN:getZ() > 0.5 then
dOffs = dOffs / 2
end
BL.UpdateTCING( nRawId, dOffs)
end
end
return true
end
+23 -5
View File
@@ -1,4 +1,4 @@
-- Process.lua by Egaltech s.r.l. 2019/01/15
-- Process.lua by Egaltech s.r.l. 2019/07/02
-- Gestione calcolo disposizione e lavorazioni per Travi
-- Si opera sulla macchina corrente
@@ -196,12 +196,30 @@ end
-------------------------------------------------------------------------------------------------------------
local function MyProcessFeatures()
local bOk, sErr = BE.ProcessFeatures()
if not bOk then
EgtOutLog( sErr)
EgtOutBox( sErr, 'Lavora Travi', 'ERROR')
local bOk, Stats = BE.ProcessFeatures()
local nErrCnt = 0
local nWarnCnt = 0
local sOutput = ''
for i = 1, #Stats do
if Stats[i].Err == 0 then
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d Ok\n', Stats[i].CutId, Stats[i].TaskId)
elseif Stats[i].Err > 0 then
nErrCnt = nErrCnt + 1
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg)
elseif Stats[i].Err < 0 then
nWarnCnt = nWarnCnt + 1
sOutput = sOutput .. string.format( 'Cut=%d Tsk=%d %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg)
end
end
if #sOutput > 0 then EgtOutLog( sOutput) end
if nErrCnt > 0 then
EgtOutBox( sOutput, 'Lavora Travi', 'ERRORS')
EgtDraw()
return false
elseif nWarnCnt > 0 then
EgtOutBox( sOutput, 'Lavora Travi', 'WARNINGS')
EgtDraw()
return true
end
return true