Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a301ca8c9f |
+236
-190
@@ -1,4 +1,4 @@
|
||||
-- 2026/04/29 19:00:00
|
||||
-- 2026/02/23 16: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.1d3'
|
||||
local CAMAUTO_VER = 'ver 3.1c1'
|
||||
|
||||
-- Determino il tipo di macchina
|
||||
local bIsMultiCut = ( EgtGetHeadId( 'H101') ~= nil)
|
||||
@@ -77,6 +77,13 @@ 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))
|
||||
|
||||
@@ -134,8 +141,6 @@ 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)
|
||||
@@ -188,6 +193,8 @@ 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
|
||||
@@ -317,7 +324,7 @@ function CAM.AnalyzePart( nPartId)
|
||||
nOutLayId = EgtGetNextName( nOutLayId, 'OutLoop')
|
||||
end
|
||||
-- Ciclo sui layer di contorno interno del pezzo
|
||||
local bAllCrv = (( bMillingOnSinks and sMill ~= "") or ( bWaterJetOnSinks and sWaterJet ~= "") or sSaw == "")
|
||||
local bAllCrv = ( bMillingOnSinks and ( sMill ~= "" or sWaterJet ~= ""))
|
||||
local dDrillDiam = CAM.GetToolDiameterFromMdb( sDrill)
|
||||
local dMillDiam = CAM.GetToolDiameterFromMdb( sMill)
|
||||
local dDripDrillDiam = CAM.GetToolDiameterFromMdb( sDripDrill)
|
||||
@@ -381,6 +388,102 @@ 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
|
||||
@@ -1296,8 +1399,12 @@ 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]
|
||||
@@ -1417,32 +1524,6 @@ 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
|
||||
@@ -1457,8 +1538,10 @@ 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
|
||||
@@ -1506,20 +1589,21 @@ 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)..
|
||||
-- ', 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
|
||||
--[[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]]
|
||||
--
|
||||
|
||||
-- Ciclo sui tratti concatenabili
|
||||
for i = 1, #TabMPartC do
|
||||
@@ -1577,13 +1661,7 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
|
||||
-- aggiusto inizio
|
||||
local dStartAddLen = 0
|
||||
if RecMPartCs.OperId == 0 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
|
||||
if 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)
|
||||
@@ -1604,12 +1682,7 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
|
||||
-- aggiusto fine
|
||||
local dEndAddLen = 0
|
||||
if RecMPartCe.OperId == 0 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
|
||||
if 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)
|
||||
@@ -1762,13 +1835,7 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
|
||||
if bInvert then dStWhiExt, dEdWhiExt = dEdWhiExt, dStWhiExt end
|
||||
-- aggiusto inizio
|
||||
local dStartAddLen = 0
|
||||
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
|
||||
if 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)
|
||||
@@ -1778,12 +1845,7 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
|
||||
EgtSetMachiningParam( MCH_MP.STARTADDLEN, - dStartAddLen)
|
||||
-- aggiusto fine
|
||||
local dEndAddLen = 0
|
||||
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
|
||||
if 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)
|
||||
@@ -1858,11 +1920,6 @@ 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
|
||||
@@ -2058,9 +2115,9 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
|
||||
end
|
||||
-- FINE: Ciclo sui tratti singoli rimasti
|
||||
|
||||
-- Preparo tabella collegamenti : **TabBridges** (per contorni esterni e interni)
|
||||
-- Preparo tabella collegamenti : **TabBridges** (solo per contorni esterni)
|
||||
local TabBridges = {}
|
||||
if sLay == 'OutLoop' or sLay == 'InLoop' then
|
||||
if sLay == 'OutLoop' or sLay == 'PartStart' then
|
||||
local BriGrpId = EgtGetFirstNameInGroup( EgtGetCurrMachGroup(), 'Bridges')
|
||||
local BriId = EgtGetFirstNameInGroup( BriGrpId or GDB_ID.NULL, 'BridgeLine')
|
||||
while BriId do
|
||||
@@ -2098,6 +2155,7 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
-- Se ci sono lavorazioni e collegamenti unisco le lavorazioni collegate
|
||||
@@ -2140,8 +2198,9 @@ 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.ErasePreview( WjOtherId)
|
||||
CAM.ErasePreviewInPiece( WjOtherId, TabBridges[BriInd][sOtherPart])
|
||||
EgtRemoveOperation( WjOtherId)
|
||||
-- sistemo la lavorazione principale
|
||||
EgtSetCurrMachining( TabWjOper[i])
|
||||
@@ -2152,6 +2211,7 @@ function CAM.ApplyWaterJettings( TabEnt, TabPartMch, sLay)
|
||||
CAM.CopyPreviewToPiece( TabWjOper[i], PartId)
|
||||
-- dichiaro lavorazioni unite
|
||||
bJoined = true
|
||||
EgtDraw()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3012,17 +3072,22 @@ function CAM.UpdateOperations( TabData, bPreview, bClPath)
|
||||
return 250
|
||||
end
|
||||
|
||||
-- assegno valore di flusso e imposto feed da Q*
|
||||
-- assegno valore di flusso (da ver. 2.7f1)
|
||||
if vThickFeed then
|
||||
local dDepth = dRawHeight / cos( dSideAng)
|
||||
local dDepth = dRawHeight / cos( RecMPartCs.SideAng)
|
||||
local dFlux = GetWjFlux( dDepth)
|
||||
if dFlux then
|
||||
EgtSetInfo( nOperId, 'Flux', dFlux)
|
||||
end
|
||||
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 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
|
||||
@@ -3174,19 +3239,16 @@ function CAM.CopyPreviewToPiece( nSaw, nPartId)
|
||||
EgtSetInfo( nSouId, 'PvId', nDestId)
|
||||
return true
|
||||
end
|
||||
-- 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
|
||||
-- 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)
|
||||
end
|
||||
-- cancello
|
||||
EgtErase( nPvId)
|
||||
end
|
||||
-- Funzione che recupera il colore da sCurrTool e lo applica alla lavorazione nSaw
|
||||
function CAM.ApplyPvColor( sCurrTool, nSaw)
|
||||
@@ -3196,7 +3258,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: in tool '..sCurrTool..' color does not exist or is not valid!')
|
||||
EgtOutLog('-- WARNING: color setted in tool '..sCurrTool..' does not exist or is not valid!')
|
||||
end
|
||||
end
|
||||
-- Funzione che cambia colore al preview ancora nella lavorazione
|
||||
@@ -3786,14 +3848,13 @@ 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', EgtIf( bSymmetricC, 'START=XP', 'START=YP'))
|
||||
local sInitPos = EgtIf( dMyWjStartC > 0, 'START=XM', '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
|
||||
@@ -4735,7 +4796,7 @@ local function CreateExitPreCuts( TabUpdate)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-------------------------------------------------------------------------------
|
||||
------ Inserimento delle lavorazioni ---------------------
|
||||
function CAM.Add()
|
||||
@@ -4759,7 +4820,6 @@ function CAM.Add()
|
||||
CAM.ApplyMachinings()
|
||||
end
|
||||
|
||||
----------------------------------------------------------
|
||||
function CAM.UpdateSawing()
|
||||
EgtOutLog( 'CAM.UpdateSawing ' .. CAMAUTO_VER)
|
||||
local TabEnt = {}
|
||||
@@ -4767,10 +4827,6 @@ 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
|
||||
@@ -4779,53 +4835,27 @@ 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
|
||||
-- cancello la preview nel pezzo
|
||||
CAM.ErasePreview( CAM.OPERID)
|
||||
-- recupero la preview dal pezzo (taglio di lama) e la elimino
|
||||
local IdPart = EgtGetFirstNameInGroup( CAM.OPERID, "PV")
|
||||
IdPart = EgtGetInfo( IdPart, 'PvId', 'i')
|
||||
EgtErase( IdPart)
|
||||
-- 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
|
||||
-- aggiorno lavorazione
|
||||
-- **DA GESTIRE MEGLIO** l'attacco dei tagli: EgtSetMachiningParam( MCH_MP.LIHOLE, false) -anche per i tagli TabEnt?-
|
||||
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
|
||||
@@ -4904,6 +4934,16 @@ 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
|
||||
@@ -4927,6 +4967,8 @@ function CAM.Erase()
|
||||
-- Passo al grezzo successivo
|
||||
nPartId = EgtGetNextPartInRawPart( nPartId)
|
||||
end
|
||||
-- cancello WjDrill
|
||||
EraseWjDrill( TabErase)
|
||||
-- cancello wjRectification
|
||||
EraseWjRectification( TabErase)
|
||||
-- Cancello le lavorazioni
|
||||
@@ -4939,6 +4981,8 @@ 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
|
||||
@@ -5482,69 +5526,71 @@ end
|
||||
-------------------------------------------------------------------------------
|
||||
local function SortWaterJets( nPhase, LastMch, sLay)
|
||||
-- dichiarazione tabella
|
||||
local TabWj = {}
|
||||
local TabMill = {}
|
||||
local TabDrill = {}
|
||||
-- recupero i tagli ad acqua e i loro centri
|
||||
local nWjId = EgtGetPhaseDisposition( nPhase)
|
||||
while nWjId do
|
||||
local nMillId = EgtGetPhaseDisposition( nPhase)
|
||||
while nMillId do
|
||||
-- Se appartiene alla fase corrente e taglio ad acqua non vuoto del layer voluto
|
||||
if EgtGetOperationPhase( nWjId) == nPhase and EgtGetOperationType( nWjId) == MCH_OY.WATERJETTING and
|
||||
( not sLay or EgtGetInfo( nWjId, 'Lay') == sLay) then
|
||||
if EgtGetOperationPhase( nMillId) == nPhase and EgtGetOperationType( nMillId) == MCH_OY.WATERJETTING and
|
||||
( not sLay or EgtGetInfo( nMillId, 'Lay') == sLay) then
|
||||
-- imposto come lavorazione corrente
|
||||
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')
|
||||
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)
|
||||
local dAng = EgtGetMachiningParam( MCH_MP.SIDEANGLE)
|
||||
table.insert( TabWj, {Id=nWjId, Start=ptStart, End=ptEnd, Ang=abs( dAng)})
|
||||
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
|
||||
end
|
||||
end
|
||||
nWjId = EgtGetNextOperation( nWjId)
|
||||
nMillId = EgtGetNextOperation( nMillId)
|
||||
end
|
||||
-- se non ci sono lavorazioni waterjet, esco
|
||||
if #TabWj == 0 then
|
||||
return LastMch
|
||||
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
|
||||
-- calcolo ordinamento
|
||||
EgtSpInit()
|
||||
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)
|
||||
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)
|
||||
end
|
||||
EgtSpSetAngularParams( 1000, 40, 2000, 60)
|
||||
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)
|
||||
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, 0, -4000, 0, 0, 90)
|
||||
local vMillOrd = 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 vWjOrd then
|
||||
for i = 1, #vWjOrd do
|
||||
EgtRelocateGlob( TabWj[vWjOrd[i]].Id, LastMch, GDB_IN.AFTER)
|
||||
LastMch = TabWj[vWjOrd[i]].Id
|
||||
if vMillOrd then
|
||||
for i = 1, #vMillOrd do
|
||||
EgtRelocateGlob( TabDrill[vMillOrd[i]].Id, LastMch, GDB_IN.AFTER)
|
||||
LastMch = TabDrill[vMillOrd[i]].Id
|
||||
end
|
||||
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)
|
||||
end
|
||||
EgtSpSetAngularParams( 1000, 40, 2000, 60)
|
||||
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, 0, -4000, 0, 0, 90)
|
||||
vMillOrd = EgtSpCalculate( SHP_TY.OPEN)
|
||||
EgtSpTerminate()
|
||||
-- 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
|
||||
end
|
||||
end
|
||||
return LastMch
|
||||
|
||||
Reference in New Issue
Block a user