11 Commits

Author SHA1 Message Date
Dario Sassi 499d06227c CamAuto 3.1d3 :
- correzioni in calcolo preview per UpdateSawing.
2026-04-30 17:47:20 +02:00
Dario Sassi 6205ef4963 CamAuto 3.1d2 :
- aggiunta gestione ponticelli in WJ anche tra pezzi in buchi e pezzo contenitore.
2026-04-22 08:25:56 +02:00
Dario Sassi fdeffb0478 CamAuto 3.1c6 :
- miglioria waterjet per attacchi/uscite su lati staccati.
2026-03-31 12:26:56 +02:00
Dario Sassi f4360664ef CamAuto :
- corretta e migliorata gestione Preview per Waterjet.
2026-03-23 08:27:47 +01:00
Dario Sassi 3f8314cdf5 CamAuto 3.1c5 :
- modifiche per fare cerchi esterni e interni con angolo di fianco con macchine Water5 con un unico percorso di lavorazioni senza extracorse di C.
2026-03-20 13:28:29 +01:00
Dario Sassi 3628f8a515 CamAuto :
- correzione in ordinamento lavorazioni waterjet.
2026-03-17 12:50:50 +01:00
Dario Sassi 5d0976b689 CamAuto 3.1c4 :
- corretta assegnazione Q particolare a lavorazione WJ che mandava in crash CamAuto.
2026-03-17 11:40:44 +01:00
Dario Sassi cf7217a4dc CamAuto :
- aggiunta gestione WaterJetOptimize per evitare tagli verticali sovrapposti.
2026-03-16 12:30:34 +01:00
Dario Sassi cf3b42a33d CamAuto 3.1c3 :
- aggiunta gestione parametro WaterJetOnSinks (per macchine Combinate Lama+WJ)
- aggiunto parametro WaterJetOptimize (per evitare di fare passate sovrapposte, da gestire).
2026-03-15 18:40:37 +01:00
Dario Sassi 3488381355 CamAuto 3.1c2 :
- eliminati fori waterjet in angoli
- in aggiornamento taglio di lama si riportano parametri attacco e uscita.
2026-03-09 17:51:30 +01:00
SaraP 898b8b4134 Merge commit '2a3235f8858076f9ac221604153469a9262d5ce1' 2026-03-06 11:58:50 +01:00
+188 -234
View File
@@ -1,4 +1,4 @@
-- 2026/02/23 16:00:00
-- 2026/04/29 19:00:00
-- Programma per Cam automatico in OmagCut
-- Legenda codici errore (CAM.ERR) :
-- 0 = tutto bene
@@ -17,7 +17,7 @@ _ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Versione
local CAMAUTO_VER = 'ver 3.1c1'
local CAMAUTO_VER = 'ver 3.1d3'
-- Determino il tipo di macchina
local bIsMultiCut = ( EgtGetHeadId( 'H101') ~= nil)
@@ -77,13 +77,6 @@ local nManageLeadInOnIntCorner = tonumber( EgtGetStringFromIni( 'Nest', 'ManageL
-- parametro per forzare la creazione dei tagli sulle feature interne
local bStartEndModifyOnIntCorner = ( EgtGetStringFromIni( 'Nest', 'StartEndModifyOnIntCorner', '0', sMachIni) == '1')
-- parametri **PreForo** WaterJet
local bHoleWj = ( EgtGetStringFromIni( 'Nest', 'DrillingWJOnCorners', '0', sMachIni) == '1')
local dHoleDiamWj = tonumber( EgtGetStringFromIni( 'Nest', 'HolesDiameterWJ', '5', sMachIni))
local dOffsetHoleWj = tonumber( EgtGetStringFromIni( 'Nest', 'HolesOffsetWJ', '5', sMachIni))
-- minimo raggio raccordo (se entità arco ha un raggio maggiore non esegue il preforo)
local dMinRadiusWj = tonumber( EgtGetStringFromIni( 'Nest', 'MinRadiusWJ', '5', sMachIni))
-- parametro di altezza massima per abilitare **tagli speciali** per girare attorno al pezzo
local HighPieceZ = tonumber( EgtGetStringFromIni( 'RawMove', 'MaxHeightPiece', '800', sMachIni))
@@ -141,6 +134,8 @@ local dDeltaIntCorner = CAM.CORNERSAFETY
local bMillingOnCorners = CAM.MILLINGONCORNERS
local bMillingOnSinks = CAM.MILLINGONSINKS
local dDeltaLenPartMilling = - ( CAM.MILLINGSHORT or 0.0)
local bWaterJetOptimize = CAM.WATERJETOPTIMIZE
local bWaterJetOnSinks = CAM.WATERJETONSINKS
local dRawHeight = CAM.RAWHEIGHT
local dOffsAxisBlock = - ( CAM.REGROT or 0.0)
local colOnCut = Color3d( 255, 165, 0)
@@ -193,8 +188,6 @@ local function SquaringWJ( MyTabRtf, TabOutCrv, TabInCrv)
dOrigSideAng<0: SideAng1=a, Offset1=H*tan(a) | SideAng2=0, Offset2=0, Depth=H
]]--
EgtOutLog( 'Nuova gestione rettifica talloni con WJ')
local TabTrimCrvs = {}
for i = 1, #MyTabRtf do
@@ -324,7 +317,7 @@ function CAM.AnalyzePart( nPartId)
nOutLayId = EgtGetNextName( nOutLayId, 'OutLoop')
end
-- Ciclo sui layer di contorno interno del pezzo
local bAllCrv = ( bMillingOnSinks and ( sMill ~= "" or sWaterJet ~= ""))
local bAllCrv = (( bMillingOnSinks and sMill ~= "") or ( bWaterJetOnSinks and sWaterJet ~= "") or sSaw == "")
local dDrillDiam = CAM.GetToolDiameterFromMdb( sDrill)
local dMillDiam = CAM.GetToolDiameterFromMdb( sMill)
local dDripDrillDiam = CAM.GetToolDiameterFromMdb( sDripDrill)
@@ -388,102 +381,6 @@ function CAM.AnalyzePart( nPartId)
-- Passo all'entità successiva
nEntId = EgtGetNext( nEntId)
end
-- prima di passare al layer successivo verifico se inserire delle lavorazioni di tipo fori
if bHoleWj and sWaterJet ~= '' then
for index = 1 , #MyTabInLoop do
local nEntId = MyTabInLoop[index]
-- **verifico se esistono i presupposti per creare un foro**
local nType_1 = EgtGetType(nEntId)
local ptEnd_1 = EgtEP( nEntId, GDB_ID.ROOT)
local nType_2
local ptStr_2
local bMakeHole = false
local _, NextAng = CAM.GetNextAngle( nEntId)
-- solo spigolo concavo (in questa sezione valutare la dimensione dell'angolo per inserire il foro)
--if NextAng < 0 then
-- bMakeHole = true
--end
-- riconosco il tipo di entità
if index == #MyTabInLoop then
nType_2 = EgtGetType(MyTabInLoop[1])
ptStr_2 = EgtSP( MyTabInLoop[1], GDB_ID.ROOT)
else
nType_2 = EgtGetType(MyTabInLoop[index+1])
ptStr_2 = EgtSP( MyTabInLoop[index+1], GDB_ID.ROOT)
end
-- Se retta e retta
if nType_1 == GDB_TY.CRV_LINE and nType_2 == GDB_TY.CRV_LINE and AreSamePointExact( ptEnd_1, ptStr_2) then
bMakeHole = true
-- Se arco e retta
elseif nType_1 == GDB_TY.CRV_ARC and nType_2 == GDB_TY.CRV_LINE and AreSamePointExact( ptEnd_1, ptStr_2) then
if EgtArcRadius( nEntId) >= dMinRadiusWj then
bMakeHole = false
else
bMakeHole = true
end
end
-- **Procedo alla costruzione del foro**
if bMakeHole then
local InfoArc = {}
-- **costruisco i layers**
local ParentId = EgtGetParent( nEntId)
ParentId = EgtGetParent( ParentId)
local OutLoopLay = EgtGroup( ParentId, GDB_RT.GLOB)
EgtSetName( OutLoopLay, "WjDrill")
local RegionLay = EgtGroup( ParentId, GDB_RT.GLOB)
EgtSetName( RegionLay, "RegionWjDrill")
-- **recupero le info per il posizionamento** del foro
local ptEndEnt = EgtEP( nEntId, GDB_ID.ROOT)
local vtEndEnt = EgtEV( nEntId, GDB_ID.ROOT)
local dDelta = 0
-- se di tipo arco, verifico se il foro è tangente all'arco oppure ai lati del lavello
local bIgnoreArc = false
if nType_1 == GDB_TY.CRV_ARC then
ptEndEnt = EgtMP( nEntId, GDB_ID.ROOT)
vtEndEnt = EgtMV( nEntId, GDB_ID.ROOT)
-- se il raggio dell'arco è minore del foro
local dRadius = EgtArcRadius( nEntId)
if dRadius < dHoleDiamWj / 2 then
bIgnoreArc = true
local dAngCenter = EgtArcAngCenter( nEntId)
NextAng = ( -90 + abs( dAngCenter / 2)) * 2
-- distanza tra il punto medio dell'arco e il punto di intersezione dei lati tangenti all'arco
dDelta = dRadius / cos( dAngCenter / 2) - dRadius
end
end
-- **disegno il foro**
local Diam = dHoleDiamWj
local OffsetArc = dOffsetHoleWj
-- costruisco l'entità circonferenza e cerchio e li posiziono sulla bisettrice dell'angolo
local nEntArc = EgtCircle( OutLoopLay, ptEndEnt, Diam / 2)
local nCirc = EgtSurfFlatRegion( RegionLay, nEntArc)
EgtSetColor( nCirc, 'RED')
EgtSetAlpha( nCirc, 60)
EgtInvertCurve( nEntArc)
-- **posiziono il foro**
if nType_1 == GDB_TY.CRV_ARC and not bIgnoreArc then
vtEndEnt:rotate( Z_AX(), -90)
Lenght = Diam / 2 + OffsetArc - dDelta
elseif nType_1 == GDB_TY.CRV_ARC and bIgnoreArc then
vtEndEnt:rotate( Z_AX(), 90)
Lenght = ( Diam / 2 + OffsetArc) / sin( NextAng / 2) + dDelta
else
-- determino l'angolo compreso tra le due entità
NextAng = -180 - NextAng
vtEndEnt:rotate( Z_AX(), -NextAng/2)
Lenght = ( Diam / 2 + OffsetArc) / sin( NextAng / 2)
end
EgtMove( { nEntArc, nCirc}, vtEndEnt*Lenght, GDB_RT.GLOB)
-- definisco il punto di inizio della lavorazione opposta all'angolo
local ptStart = EgtCP( nEntArc, GDB_ID.ROOT) + vtEndEnt*Lenght
EgtSetInfo( OutLoopLay, "Start", ptStart)
table.insert( TabInCrv, nEntArc)
end
end
MyTabInLoop = {}
end
-- Passo al layer successivo
nInLayId = EgtGetNextName( nInLayId, 'InLoop')
end
@@ -1399,12 +1296,8 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
local nIntAngLoType = MCH_WJET_LO.LINEAR
local dIntAngLoTang = 0
local dIntAngLoPerp = 2
-- preparo tabella con info circonferenze preforo
local TabEntPreDrill = {}
local TabMPartC = {}
-- questa tabella contiene l'indice della tabella sopra che devono esseere ricopiate
local TabMNewPartC = {}
-- Preparo tabella info tagli completi: **TabMPartC** partendo dall'identificativo dell'entità
for i = 1, #TabEnt do
local nEntId = TabEnt[i]
@@ -1524,6 +1417,32 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
end
-- FINE: Preparo tabella info tagli parziali, solo se tipo operazione **MCH_OY.SAWING**
-- Se richiesta ottimizzazione, escludo i tagli verticali sovrapposti
if bWaterJetOptimize then
local dMaxDist = 1.4
for i = 1, #TabMPartC do
local CurrMPC = TabMPartC[i]
local ptStart = EgtSP( CurrMPC.EntId, GDB_ID.ROOT)
local ptEnd = EgtEP( CurrMPC.EntId, GDB_ID.ROOT)
local ptMid = EgtMP( CurrMPC.EntId, GDB_ID.ROOT)
if abs( CurrMPC.SideAng) < GEO.EPS_ANG_SMALL then
for j = 1, #TabMPartC do
if j ~= i then
local OtherMPC = TabMPartC[j]
if not OtherMPC.Skip and abs( OtherMPC.SideAng) < GEO.EPS_ANG_SMALL and
EgtPointCurveDist( ptStart, OtherMPC.EntId, GDB_RT.GLOB) < dMaxDist and
EgtPointCurveDist( ptEnd, OtherMPC.EntId, GDB_RT.GLOB) < dMaxDist and
EgtPointCurveDist( ptMid, OtherMPC.EntId, GDB_RT.GLOB) < dMaxDist then
CurrMPC.Skip = true
CurrMPC.Join = false
break
end
end
end
end
end
end
-- |CONGIUNZIONI TAGLI|
-- Cerco le congiunzioni -> aggiorno i campi della tabella **RecMPartC.PrevInd** e **RecMPartC2.NextInd** !ATTENZIONE! sono gli indici della tabella (NON dell'entità)
for i = 1, #TabMPartC do
@@ -1538,10 +1457,8 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
if ( RecMPartC2.OperId == 0 or RecMPartC2.EndStrict) and ( RecMPartC2.Join or #TabEnt == 0) then
local ptEnd = EgtEP( RecMPartC2.EntId, GDB_ID.ROOT)
-- se estremi e angoli coincidono
-- (tolti i positivi il 2021/03/24 per fare rettangoli con lati indipendenti anche con misure sul top, poi reintrodotti)
if AreSamePointEpsilon( ptStart, ptEnd, 10 * GEO.EPS_SMALL) and
abs( RecMPartC.SideAng - RecMPartC2.SideAng) < 10 * GEO.EPS_ANG_SMALL then
--and ( not bSizeAlwaysOnTop or RecMPartC.SideAng <= 10 * GEO.EPS_ANG_SMALL) then
RecMPartC.PrevInd = j
RecMPartC2.NextInd = i
break
@@ -1589,21 +1506,20 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
end
-- FINE: Cerco le congiunzioni
--[[Stampe di debug
for i = 1, #TabMPartC do
local RecMPartC = TabMPartC[i]
EgtOutLog( 'OperId='..tostring( RecMPartC.OperId)..
', StartStrict='..tostring(RecMPartC.StartStrict)..', EndStrict='..tostring(RecMPartC.EndStrict)..
', Sal='..EgtNumToString(RecMPartC.Sal,2)..', Eal='..EgtNumToString(RecMPartC.Eal,2)..
', DeltaT='..EgtNumToString(RecMPartC.DeltaT,2)..', DeltaTI='..EgtNumToString(RecMPartC.DeltaTI,2)..
', EntId='..tostring(RecMPartC.EntId)..', EntLen='..EgtNumToString(RecMPartC.EntLen,2)..
', PrevAng='..EgtNumToString(RecMPartC.PrevAng,2)..', NextAng='..EgtNumToString(RecMPartC.NextAng,2)..
', SideAng='..EgtNumToString(RecMPartC.SideAng,2)..
', PrevInd='..tostring(RecMPartC.PrevInd)..', NextInd='..tostring(RecMPartC.NextInd)..
', StartDone='..tostring(RecMPartC.StartDone)..', EndDone='..tostring(RecMPartC.EndDone)..
', Double='..tostring(RecMPartC.Double)..', Width='..EgtNumToString(RecMPartC.Width,2))
end]]
--
--Stampe di debug
--for i = 1, #TabMPartC do
-- local RecMPartC = TabMPartC[i]
-- EgtOutLog( 'OperId='..tostring( RecMPartC.OperId)..
-- ', Sstc='..tostring( RecMPartC.StartStrict)..', Estc='..tostring( RecMPartC.EndStrict)..
-- ', Sal='..EgtNumToString( RecMPartC.Sal, 2)..', Eal='..EgtNumToString( RecMPartC.Eal, 2)..
-- ', DeltaT='..EgtNumToString( RecMPartC.DeltaT, 2)..', DeltaTI='..EgtNumToString( RecMPartC.DeltaTI, 2)..
-- ', EntId='..tostring( RecMPartC.EntId)..', EntLen='..EgtNumToString( RecMPartC.EntLen, 2)..
-- ', PrevAng='..EgtNumToString( RecMPartC.PrevAng, 2)..', NextAng='..EgtNumToString( RecMPartC.NextAng, 2)..
-- ', SideAng='..EgtNumToString( RecMPartC.SideAng, 2)..', Join='..tostring( RecMPartC.Join)..', Skip='..tostring( RecMPartC.Skip or false)..
-- ', PrevInd='..tostring( RecMPartC.PrevInd)..', NextInd='..tostring( RecMPartC.NextInd)..
-- ', Sdone='..tostring( RecMPartC.StartDone)..', Edone='..tostring( RecMPartC.EndDone)..
-- ', Double='..tostring( RecMPartC.Double or false)..', Width='..EgtNumToString( RecMPartC.Width or 0, 2))
--end
-- Ciclo sui tratti concatenabili
for i = 1, #TabMPartC do
@@ -1661,7 +1577,13 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
-- aggiusto inizio
local dStartAddLen = 0
if RecMPartCs.OperId == 0 then
if RecMPartCs.PrevAng > - 175 and RecMPartCs.PrevAng < - 5 then
if bWaterJetOptimize and RecMPartCs.Join and abs( RecMPartCs.SideAng) < GEO.EPS_ANG_SMALL then
dStartAddLen = 0
EgtSetMachiningParam( MCH_MP.LIHOLE, false)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, nIntAngLiType)
EgtSetMachiningParam( MCH_MP.LITANG, dRad)
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
elseif RecMPartCs.PrevAng > - 175 and RecMPartCs.PrevAng < - 5 then
dStartAddLen = dRad * ( cos( 180 + RecMPartCs.PrevAng) + 1) / sin( 180 + RecMPartCs.PrevAng)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, nIntAngLiType)
EgtSetMachiningParam( MCH_MP.LITANG, dIntAngLiTang)
@@ -1682,7 +1604,12 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
-- aggiusto fine
local dEndAddLen = 0
if RecMPartCe.OperId == 0 then
if RecMPartCe.NextAng > - 175 and RecMPartCe.NextAng < - 5 then
if bWaterJetOptimize and RecMPartCs.Join and abs( RecMPartCs.SideAng) < GEO.EPS_ANG_SMALL then
dEndAddLen = 0
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nIntAngLoType)
EgtSetMachiningParam( MCH_MP.LOTANG, dRad)
EgtSetMachiningParam( MCH_MP.LOPERP, 0)
elseif RecMPartCe.NextAng > - 175 and RecMPartCe.NextAng < - 5 then
dEndAddLen = dRad * ( cos( 180 + RecMPartCe.NextAng) + 1) / sin( 180 + RecMPartCe.NextAng)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nIntAngLoType)
EgtSetMachiningParam( MCH_MP.LOTANG, dIntAngLoTang)
@@ -1835,7 +1762,13 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
if bInvert then dStWhiExt, dEdWhiExt = dEdWhiExt, dStWhiExt end
-- aggiusto inizio
local dStartAddLen = 0
if dPrevAng < - 5 and dPrevAng > - 175 then
if bWaterJetOptimize and RecMPartC.Join and abs( RecMPartC.SideAng) < GEO.EPS_ANG_SMALL then
dStartAddLen = 0
EgtSetMachiningParam( MCH_MP.LIHOLE, false)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, nIntAngLiType)
EgtSetMachiningParam( MCH_MP.LITANG, dRad)
EgtSetMachiningParam( MCH_MP.LIPERP, 0)
elseif dPrevAng < - 5 and dPrevAng > - 175 then
dStartAddLen = dRad * ( cos( 180 + dPrevAng) + 1) / sin( 180 + dPrevAng)
EgtSetMachiningParam( MCH_MP.LEADINTYPE, nIntAngLiType)
EgtSetMachiningParam( MCH_MP.LITANG, dIntAngLiTang)
@@ -1845,7 +1778,12 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
EgtSetMachiningParam( MCH_MP.STARTADDLEN, - dStartAddLen)
-- aggiusto fine
local dEndAddLen = 0
if dNextAng < - 5 and dNextAng > - 175 then
if bWaterJetOptimize and RecMPartC.Join and abs( RecMPartC.SideAng) < GEO.EPS_ANG_SMALL then
dEndAddLen = 0
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nIntAngLoType)
EgtSetMachiningParam( MCH_MP.LOTANG, dRad)
EgtSetMachiningParam( MCH_MP.LOPERP, 0)
elseif dNextAng < - 5 and dNextAng > - 175 then
dEndAddLen = dRad * ( cos( 180 + dNextAng) + 1) / sin( 180 + dNextAng)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nIntAngLoType)
EgtSetMachiningParam( MCH_MP.LOTANG, dIntAngLoTang)
@@ -1920,6 +1858,11 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
end
EgtSetOperationStatus( nMill, false)
EgtSetInfo( nMill, 'Lay', sLay)
if RecMPartC.Skip then
local nPartId = EgtGetParent(EgtGetParent( RecMPartC.EntId))
CAM.ErasePreview( nMill)
EgtRemoveOperation( nMill)
end
else
EgtRemoveOperation( nMill)
end
@@ -2115,9 +2058,9 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
end
-- FINE: Ciclo sui tratti singoli rimasti
-- Preparo tabella collegamenti : **TabBridges** (solo per contorni esterni)
-- Preparo tabella collegamenti : **TabBridges** (per contorni esterni e interni)
local TabBridges = {}
if sLay == 'OutLoop' or sLay == 'PartStart' then
if sLay == 'OutLoop' or sLay == 'InLoop' then
local BriGrpId = EgtGetFirstNameInGroup( EgtGetCurrMachGroup(), 'Bridges')
local BriId = EgtGetFirstNameInGroup( BriGrpId or GDB_ID.NULL, 'BridgeLine')
while BriId do
@@ -2155,7 +2098,6 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
return true
end
end
return false
end
-- Se ci sono lavorazioni e collegamenti unisco le lavorazioni collegate
@@ -2198,9 +2140,8 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
end
-- se trovata, unisco le due lavorazioni nella prima
if WjOtherId then
print(' -- WJ BRIDGE -- ELIMINO LAVORAZIONI PER CREARE COLLEGAMENTO')
-- elimino lavorazione collegata
CAM.ErasePreviewInPiece( WjOtherId, TabBridges[BriInd][sOtherPart])
CAM.ErasePreview( WjOtherId)
EgtRemoveOperation( WjOtherId)
-- sistemo la lavorazione principale
EgtSetCurrMachining( TabWjOper[i])
@@ -2211,7 +2152,6 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
CAM.CopyPreviewToPiece( TabWjOper[i], PartId)
-- dichiaro lavorazioni unite
bJoined = true
EgtDraw()
end
end
end
@@ -3072,22 +3012,17 @@ function CAM.UpdateOperations( TabData, bPreview, bClPath)
return 250
end
-- assegno valore di flusso (da ver. 2.7f1)
-- assegno valore di flusso e imposto feed da Q*
if vThickFeed then
local dDepth = dRawHeight / cos( RecMPartCs.SideAng)
local dFlux = GetWjFlux( dDepth)
if dFlux then EgtSetInfo( nOperId, 'Flux', dFlux) end
end
-- se previsto, imposto feed da Q*
if vThickFeed then
local dSideAng = EgtGetMachiningParam( MCH_MP.SIDEANGLE)
local dDepth = dRawHeight / cos( dSideAng)
local dFlux = GetWjFlux( dDepth)
if dFlux then
EgtSetInfo( nOperId, 'Flux', dFlux)
end
local dFeed, dThRef = GetWjSpeed( dDepth)
if dFeed and dThRef then
EgtSetMachiningParam( MCH_MP.FEED, dFeed)
EgtSetMachiningParam( MCH_MP.THICKREF, dThRef)
-- EgtOutLog(' UPDATE QUALITY → ' ..sWjQuality ..' - FEED → '..dFeed)
end
end
end
@@ -3239,16 +3174,19 @@ function CAM.CopyPreviewToPiece( nSaw, nPartId)
EgtSetInfo( nSouId, 'PvId', nDestId)
return true
end
-- Funzione che cancella il preview nel pezzo
function CAM.ErasePreviewInPiece( nSaw, nPartId)
-- verifico se esiste gruppo preview nel pezzo
local nPrevId = EgtGetFirstNameInGroup( nPartId, 'PV')
if not nPrevId then return end
-- se esiste sottogruppo con nome della lavorazione, lo cancello
local nDestId = EgtGetFirstNameInGroup( nPrevId, EgtGetName( nSaw))
if nDestId then
EgtErase( nDestId)
-- Funzione che cancella la preview (ovunque sia)
function CAM.ErasePreview( nMachId)
-- gruppo preview nella lavorazione
local nPvId = EgtGetFirstNameInGroup( nMachId, "PV")
if not nPvId then return end
-- eventuale reindirizzamento
local nPv2Id = EgtGetInfo( nPvId, 'PvId', 'i')
if nPv2Id then
EgtRemoveInfo( nPvId, 'PvId')
nPvId = nPv2Id
end
-- cancello
EgtErase( nPvId)
end
-- Funzione che recupera il colore da sCurrTool e lo applica alla lavorazione nSaw
function CAM.ApplyPvColor( sCurrTool, nSaw)
@@ -3258,7 +3196,7 @@ function CAM.ApplyPvColor( sCurrTool, nSaw)
if tbRGB then
CAM.ChangePvColor( nSaw, Color3d( tonumber(tbRGB[1]), tonumber(tbRGB[2]), tonumber(tbRGB[3])))
else
EgtOutLog('-- WARNING: color setted in tool '..sCurrTool..' does not exist or is not valid!')
EgtOutLog( '-- WARNING: in tool '..sCurrTool..' color does not exist or is not valid!')
end
end
-- Funzione che cambia colore al preview ancora nella lavorazione
@@ -3848,13 +3786,14 @@ end
--
function CAM.HintWaterJetAngC( dSideAng, bOutLoop, nEntId)
local bSymmetricC = ( EgtGetAxisMin( 'C') < -180 and EgtGetAxisMax( 'C') > 180)
local dHomeC = EgtGetAxisHomePos( 'C')
local dMyWjStartC = ( dWjStartC or dHomeC)
if abs( dSideAng) < 0.1 then
dMyWjStartC = dHomeC
end
-- posizione di inizio
local sInitPos = EgtIf( dMyWjStartC > 0, 'START=XM', 'START=YP')
local sInitPos = EgtIf( dMyWjStartC > 0, 'START=XM', EgtIf( bSymmetricC, 'START=XP', 'START=YP'))
if abs( dSideAng) < 0.1 then
local ptStart = EgtGetInfo( EgtGetParent( nEntId or GDB_ID.NULL) or GDB_ID.NULL, 'Start', 'p')
if ptStart then
@@ -4796,7 +4735,7 @@ local function CreateExitPreCuts( TabUpdate)
end
end
end
--
-------------------------------------------------------------------------------
------ Inserimento delle lavorazioni ---------------------
function CAM.Add()
@@ -4820,6 +4759,7 @@ function CAM.Add()
CAM.ApplyMachinings()
end
----------------------------------------------------------
function CAM.UpdateSawing()
EgtOutLog( 'CAM.UpdateSawing ' .. CAMAUTO_VER)
local TabEnt = {}
@@ -4827,6 +4767,10 @@ function CAM.UpdateSawing()
local TabCrv = {}
local TabPart = {}
local j = nil
local nLiType = nil
local dSal = nil
local nLoType = nil
local dEal = nil
EgtSetCurrMachining( CAM.OPERID)
local Geo = EgtGetMachiningGeometry()
if type( Geo) == 'table' and type( Geo[1]) == 'table' and type( Geo[1][1]) == 'number' then
@@ -4835,27 +4779,53 @@ function CAM.UpdateSawing()
-- recupero il nome del layer cui appartiene
local sName = EgtGetName( EgtGetParent( Geo[1][1]) or GDB_ID.NULL)
if sName then sLay = sName end
-- recupero la preview dal pezzo (taglio di lama) e la elimino
local IdPart = EgtGetFirstNameInGroup( CAM.OPERID, "PV")
IdPart = EgtGetInfo( IdPart, 'PvId', 'i')
EgtErase( IdPart)
-- cancello la preview nel pezzo
CAM.ErasePreview( CAM.OPERID)
-- recupero l'info da applicare in fase di costruzione della lavorazione
j = EgtGetInfo( CAM.OPERID, 'Index_j')
-- recupero variazioni su attacco e uscita
nLiType = EgtGetMachiningParam( MCH_MP.LEADINTYPE)
dSal = EgtGetMachiningParam( MCH_MP.STARTADDLEN)
nLoType = EgtGetMachiningParam( MCH_MP.LEADOUTTYPE)
dEal = EgtGetMachiningParam( MCH_MP.ENDADDLEN)
-- rimuovo la lavorazione
EgtRemoveOperation( CAM.OPERID)
end
-- **DA GESTIRE MEGLIO** l'attacco dei tagli: EgtSetMachiningParam( MCH_MP.LIHOLE, false) -anche per i tagli TabEnt?-
-- aggiorno lavorazione
CAM.ApplyCuts( TabEnt, sLay, TabCrv, TabPart, j)
-- inserisco variazioni di attacco e uscita
if CAM.NEW_OPERATION and EgtSetCurrMachining( CAM.NEW_OPERATION) then
EgtSetMachiningParam( MCH_MP.LEADINTYPE, nLiType)
EgtSetMachiningParam( MCH_MP.STARTADDLEN, dSal)
EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, nLoType)
EgtSetMachiningParam( MCH_MP.ENDADDLEN, dEal)
EgtApplyMachining()
if EgtPreviewMachining() then
if not EgtIsMachiningEmpty() then
local nEntId = CAM.GetEntIdFromMachining( CAM.NEW_OPERATION)
local nPartId = EgtGetParent( EgtGetParent( nEntId) or GDB_ID.NULL) or GDB_ID.NULL
CAM.CopyPreviewToPiece( CAM.NEW_OPERATION, nPartId)
local sCurrSaw = EgtTdbGetToolFromUUID( EgtGetMachiningParam( MCH_MP.TUUID) or '')
if sCurrSaw and EgtTdbSetCurrTool( sCurrSaw) then
CAM.ApplyPvColor( sCurrSaw, CAM.NEW_OPERATION)
end
end
end
else
CAM.ERR = 58
EgtOutLog( ' Error updating sawing')
end
end
------ Inserimento di una lavorazione Waterjet ---------------------
function CAM.AddWaterJet()
EgtOutLog( 'CAM.AddWaterJet ' .. CAMAUTO_VER .. ' Operation ID: ')
EgtOutLog( 'CAM.AddWaterJet ' .. CAMAUTO_VER .. ' Operation ID: ')
CAM.ApplyWaterJettings( {}, {CAM.OPERID}, 'OutLoop')
end
-- ver 2.6l1 di OmagCUT
----------------------------------------------------------
function CAM.AddWaterJets()
EgtOutLog( 'CAM.AddWaterJets ' .. CAMAUTO_VER .. '. Nuova gestione tagli collegati. ')
EgtOutLog( 'CAM.AddWaterJets ' .. CAMAUTO_VER .. '. Nuova gestione tagli collegati. ')
local TabEnt = {}
local TabPart = {}
for i=1, #CAM.TAB_OPERID, 1 do
@@ -4934,16 +4904,6 @@ function CAM.UpdateAllTp()
end
------ Cancellazione delle lavorazioni ---------------------
local function EraseWjDrill( TabPart)
if #TabPart < 1 then
return
end
for i = 1, #TabPart do
EgtErase( EgtGetNameInGroup( TabPart[i].Part, "WjDrill"))
EgtErase( EgtGetNameInGroup( TabPart[i].Part, "RegionWjDrill"))
end
end
local function EraseWjRectification( TabPart)
if #TabPart < 1 then
return
@@ -4967,8 +4927,6 @@ function CAM.Erase()
-- Passo al grezzo successivo
nPartId = EgtGetNextPartInRawPart( nPartId)
end
-- cancello WjDrill
EraseWjDrill( TabErase)
-- cancello wjRectification
EraseWjRectification( TabErase)
-- Cancello le lavorazioni
@@ -4981,8 +4939,6 @@ function CAM.Erase()
local TabErase = {}
-- Recupero gli identificativi
TabErase = CAM.FindPartMachinings( CAM.PARTID, TabErase)
-- cancello WjDrill
EraseWjDrill( TabErase)
-- cancello wjRectification
EraseWjRectification( TabErase)
-- Cancello le lavorazioni
@@ -5526,71 +5482,69 @@ end
-------------------------------------------------------------------------------
local function SortWaterJets( nPhase, LastMch, sLay)
-- dichiarazione tabella
local TabMill = {}
local TabDrill = {}
local TabWj = {}
-- recupero i tagli ad acqua e i loro centri
local nMillId = EgtGetPhaseDisposition( nPhase)
while nMillId do
local nWjId = EgtGetPhaseDisposition( nPhase)
while nWjId do
-- Se appartiene alla fase corrente e taglio ad acqua non vuoto del layer voluto
if EgtGetOperationPhase( nMillId) == nPhase and EgtGetOperationType( nMillId) == MCH_OY.WATERJETTING and
( not sLay or EgtGetInfo( nMillId, 'Lay') == sLay) then
if EgtGetOperationPhase( nWjId) == nPhase and EgtGetOperationType( nWjId) == MCH_OY.WATERJETTING and
( not sLay or EgtGetInfo( nWjId, 'Lay') == sLay) then
-- imposto come lavorazione corrente
EgtSetCurrMachining( nMillId)
local nStartId, nEndId = CAM.GetEntIdFromCurrMachining()
if nStartId ~= GDB_ID.NULL and EgtExistsObj( nStartId) and nEndId ~= GDB_ID.NULL and EgtExistsObj( nEndId) then
local ptStart = EgtSP( nStartId, GDB_ID.ROOT)
local ptEnd = EgtEP( nEndId, GDB_ID.ROOT)
local bInvert = EgtGetMachiningParam( MCH_MP.INVERT)
EgtSetCurrMachining( nWjId)
-- cerco il gruppo di preview
local nMchPvId = EgtGetFirstNameInGroup( nWjId, 'PV')
local nGeoPvId = EgtGetInfo( nMchPvId or GDB_ID.NULL, 'PvId', 'i')
local nP1PvId = EgtGetFirstNameInGroup( nGeoPvId or GDB_ID.NULL, 'P1')
if nP1PvId then
local ptStart = EgtGetInfo( nP1PvId, 'START', 'p')
local ptEnd = EgtGetInfo( nP1PvId, 'END', 'p')
local dAng = EgtGetMachiningParam( MCH_MP.SIDEANGLE)
if bInvert then
ptStart, ptEnd = ptEnd, ptStart
end
local ParentId = EgtGetParent( nStartId)
local sName = EgtGetName( ParentId)
if sName == "WjDrill" then
table.insert( TabDrill, {Id=nMillId, Start= ptStart, End = ptEnd, Ang=abs( dAng)})
else
table.insert( TabMill, {Id=nMillId, Start= ptStart, End = ptEnd, Ang=abs( dAng)})
end
table.insert( TabWj, {Id=nWjId, Start=ptStart, End=ptEnd, Ang=abs( dAng)})
end
end
nMillId = EgtGetNextOperation( nMillId)
nWjId = EgtGetNextOperation( nWjId)
end
-- calcolo ordinamento
EgtSpInit()
for i = 1, #TabDrill do
EgtSpAddPoint( TabDrill[i].Start:getX(), TabDrill[i].Start:getY(), 0, 0, TabDrill[i].Ang,
TabDrill[i].End:getX(), TabDrill[i].End:getY(), 0, 0, TabDrill[i].Ang)
-- se non ci sono lavorazioni waterjet, esco
if #TabWj == 0 then
return LastMch
end
EgtSpSetAngularParams( 1000, 40, 2000, 60)
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, 0, -4000, 0, 0, 90)
local vMillOrd = EgtSpCalculate( SHP_TY.OPEN)
EgtSpTerminate()
-- applico ordinamento calcolato
-- parto da LastMch precedente
if vMillOrd then
for i = 1, #vMillOrd do
EgtRelocateGlob( TabDrill[vMillOrd[i]].Id, LastMch, GDB_IN.AFTER)
LastMch = TabDrill[vMillOrd[i]].Id
end
end
-- log dei dati lavorazioni per debug
--EgtOutLog( 'Dati lavorazioni :')
--for i = 1, #TabWj do
-- EgtOutLog( 'WjId='..tostring( TabWj[i].Id)..
-- ' Start='..tostring( TabWj[i].Start)..' End='..tostring( TabWj[i].End)..' Ang='..EgtNumToString( TabWj[i].Ang, 3))
--end
-- calcolo ordinamento
EgtSpInit()
for i = 1, #TabMill do
EgtSpAddPoint( TabMill[i].Start:getX(), TabMill[i].Start:getY(), 0, 0, TabMill[i].Ang,
TabMill[i].End:getX(), TabMill[i].End:getY(), 0, 0, TabMill[i].Ang)
for i = 1, #TabWj do
EgtSpAddPoint( TabWj[i].Start:getX(), TabWj[i].Start:getY(), 0, 0, TabWj[i].Ang,
TabWj[i].End:getX(), TabWj[i].End:getY(), 0, 0, TabWj[i].Ang)
end
EgtSpSetAngularParams( 1000, 40, 2000, 60)
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, 0, -4000, 0, 0, 90)
vMillOrd = EgtSpCalculate( SHP_TY.OPEN)
local dSpStartX = 0
local dSpStartY = -4000
if bWaterJetOptimize then
for i = 1, #TabWj do
if ( AreSamePointEpsilon( TabWj[i].Start, TabWj[i].End, 1)) then
dSpStartX = TabWj[i].Start:getX()
dSpStartY = TabWj[i].Start:getY()
break
end
end
end
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, dSpStartX, dSpStartY, 0, 0, 90)
vWjOrd = EgtSpCalculate( SHP_TY.OPEN)
EgtSpTerminate()
-- log dell'ordinamento per debug
--if vWjOrd then
-- EgtOutLog( 'Ordinamento :'..table.concat( vWjOrd, ','))
--end
-- applico ordinamento calcolato
-- parto da LastMch precedente
if vMillOrd then
for i = 1, #vMillOrd do
EgtRelocateGlob( TabMill[vMillOrd[i]].Id, LastMch, GDB_IN.AFTER)
LastMch = TabMill[vMillOrd[i]].Id
if vWjOrd then
for i = 1, #vWjOrd do
EgtRelocateGlob( TabWj[vWjOrd[i]].Id, LastMch, GDB_IN.AFTER)
LastMch = TabWj[vWjOrd[i]].Id
end
end
return LastMch